Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:43:26

0001 // Copyright David Abrahams, Daniel Wallin 2003.
0002 // Copyright Cromwell D. Enage 2018.
0003 // Distributed under the Boost Software License, Version 1.0.
0004 // (See accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef BOOST_PARAMETER_AUX_PACK_MAKE_ARG_LIST_HPP
0008 #define BOOST_PARAMETER_AUX_PACK_MAKE_ARG_LIST_HPP
0009 
0010 namespace boost { namespace parameter { namespace aux {
0011 
0012     template <
0013         typename List
0014       , typename DeducedArgs
0015       , typename TagFn
0016       , typename IsPositional
0017       , typename UsedArgs
0018       , typename ArgumentPack
0019       , typename Error
0020       , typename EmitsErrors
0021     >
0022     struct make_arg_list_aux;
0023 }}} // namespace boost::parameter::aux
0024 
0025 #include <boost/parameter/aux_/arg_list.hpp>
0026 #include <boost/parameter/aux_/void.hpp>
0027 #include <boost/parameter/aux_/pack/unmatched_argument.hpp>
0028 #include <boost/parameter/aux_/pack/tag_type.hpp>
0029 #include <boost/parameter/aux_/pack/is_named_argument.hpp>
0030 #include <boost/parameter/aux_/pack/insert_tagged.hpp>
0031 #include <boost/parameter/aux_/pack/deduce_tag.hpp>
0032 #include <boost/parameter/deduced.hpp>
0033 #include <boost/parameter/config.hpp>
0034 
0035 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0036 #include <boost/mp11/integral.hpp>
0037 #include <boost/mp11/list.hpp>
0038 #include <boost/mp11/utility.hpp>
0039 #include <type_traits>
0040 #else
0041 #include <boost/mpl/bool.hpp>
0042 #include <boost/mpl/pair.hpp>
0043 #include <boost/mpl/if.hpp>
0044 #include <boost/mpl/eval_if.hpp>
0045 #include <boost/mpl/apply_wrap.hpp>
0046 #include <boost/mpl/identity.hpp>
0047 #include <boost/type_traits/is_same.hpp>
0048 #include <boost/type_traits/remove_const.hpp>
0049 #include <boost/type_traits/remove_reference.hpp>
0050 #endif
0051 
0052 namespace boost { namespace parameter { namespace aux {
0053 
0054 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0055     template <typename ArgumentPack, typename TaggedArg, typename EmitsErrors>
0056     struct append_to_make_arg_list
0057     {
0058         using type = ::boost::mp11::mp_push_front<
0059             ArgumentPack
0060           , ::boost::parameter::aux::flat_like_arg_tuple<
0061                 typename TaggedArg::key_type
0062               , TaggedArg
0063               , EmitsErrors
0064             >
0065         >;
0066     };
0067 #endif
0068 
0069     // Borland needs the insane extra-indirection workaround below so that
0070     // it doesn't magically drop the const qualifier from the argument type.
0071     template <
0072         typename List
0073       , typename DeducedArgs
0074       , typename TagFn
0075       , typename IsPositional
0076       , typename UsedArgs
0077       , typename ArgumentPack
0078 #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
0079       , typename _argument
0080 #endif
0081       , typename Error
0082       , typename EmitsErrors
0083     >
0084 #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
0085     class make_arg_list00
0086 #else
0087     class make_arg_list0
0088 #endif
0089     {
0090 #if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
0091         typedef typename List::arg _argument;
0092 #endif
0093 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0094         using _arg_type = typename ::std::remove_const<
0095             typename ::std::remove_reference<_argument>::type
0096         >::type;
0097         using _is_tagged = ::boost::parameter::aux
0098         ::is_named_argument<_argument>;
0099 #else
0100         typedef typename ::boost::remove_const<
0101             typename ::boost::remove_reference<_argument>::type
0102         >::type _arg_type;
0103         typedef ::boost::parameter::aux
0104         ::is_named_argument<_argument> _is_tagged;
0105 #endif
0106         typedef typename List::spec _parameter_spec;
0107         typedef typename ::boost::parameter::aux
0108         ::tag_type<_parameter_spec>::type _tag;
0109 
0110         // If this argument is either explicitly tagged or a deduced
0111         // parameter, then turn off positional matching.
0112 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0113         using _is_positional = ::boost::mp11::mp_if<
0114             IsPositional
0115           , ::boost::mp11::mp_if<
0116                 ::boost::parameter::aux::is_deduced<_parameter_spec>
0117               , ::boost::mp11::mp_false
0118               , ::boost::mp11::mp_if<
0119                     _is_tagged
0120                   , ::boost::mp11::mp_false
0121                   , ::boost::mp11::mp_true
0122                 >
0123             >
0124           , ::boost::mp11::mp_false
0125         >;
0126 #else   // !defined(BOOST_PARAMETER_CAN_USE_MP11)
0127         typedef typename ::boost::mpl::eval_if<
0128             IsPositional
0129           , ::boost::mpl::eval_if<
0130                 ::boost::parameter::aux::is_deduced<_parameter_spec>
0131               , ::boost::mpl::false_
0132               , ::boost::mpl::if_<
0133                     _is_tagged
0134                   , ::boost::mpl::false_
0135                   , ::boost::mpl::true_
0136                 >
0137             >
0138           , ::boost::mpl::false_
0139         >::type _is_positional;
0140 #endif  // BOOST_PARAMETER_CAN_USE_MP11
0141 
0142         // If this parameter is explicitly tagged, then add it to the
0143         // used-parmeters set.  We only really need to add parameters
0144         // that are deduced, but we would need a way to check if
0145         // a given tag corresponds to a deduced parameter spec.
0146 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0147         using _used_args = typename ::boost::mp11::mp_if<
0148             _is_tagged
0149           , ::boost::parameter::aux::insert_tagged<UsedArgs,_arg_type>
0150           , ::boost::mp11::mp_identity<UsedArgs>
0151         >::type;
0152 #else
0153         typedef typename ::boost::mpl::eval_if<
0154             _is_tagged
0155           , ::boost::parameter::aux::insert_tagged<UsedArgs,_arg_type>
0156           , ::boost::mpl::identity<UsedArgs>
0157         >::type _used_args;
0158 #endif
0159 
0160         // If this parameter is neither explicitly tagged nor positionally
0161         // matched, then deduce the tag from the deduced parameter specs.
0162 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0163         using _deduced_data = typename ::boost::mp11::mp_if<
0164             ::boost::mp11::mp_if<
0165                 _is_tagged
0166               , ::boost::mp11::mp_true
0167               , _is_positional
0168             >
0169           , ::boost::mp11::mp_identity<
0170                 ::boost::mp11::mp_list< ::boost::parameter::void_,_used_args>
0171             >
0172 #else
0173         typedef typename ::boost::mpl::eval_if<
0174             typename ::boost::mpl::if_<
0175                 _is_tagged
0176               , ::boost::mpl::true_
0177               , _is_positional
0178             >::type
0179           , ::boost::mpl::pair< ::boost::parameter::void_,_used_args>
0180 #endif
0181           , ::boost::parameter::aux::deduce_tag<
0182                 _argument
0183               , ArgumentPack
0184               , DeducedArgs
0185               , _used_args
0186               , TagFn
0187               , EmitsErrors
0188             >
0189 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0190         >::type;
0191 #else
0192         >::type _deduced_data;
0193 #endif
0194 
0195 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0196         // If this parameter is explicitly tagged ...
0197         using _tagged = ::boost::mp11::mp_if<
0198             _is_tagged
0199             // ... just use it
0200           , _arg_type
0201             // ... else ...
0202           , ::boost::mp11::mp_if<
0203                 // if positional matching is turned on ...
0204                 _is_positional
0205                 // ... tag it positionally
0206               , ::boost::mp11::mp_apply_q<
0207                     TagFn
0208                   , ::boost::mp11::mp_list<_tag,_argument>
0209                 >
0210                 // ... else, use the deduced tag
0211               , ::boost::mp11::mp_at_c<_deduced_data,0>
0212             >
0213         >;
0214 #else   // !defined(BOOST_PARAMETER_CAN_USE_MP11)
0215         // If this parameter is explicitly tagged ...
0216         typedef typename ::boost::mpl::eval_if<
0217             _is_tagged
0218             // ... just use it
0219           , ::boost::mpl::identity<_arg_type>
0220             // ... else ...
0221           , ::boost::mpl::eval_if<
0222                 // if positional matching is turned on ...
0223                 _is_positional
0224                 // ... tag it positionally
0225               , ::boost::mpl::apply_wrap2<TagFn,_tag,_argument>
0226                 // ... else, use the deduced tag
0227               , ::boost::mpl::first<_deduced_data>
0228             >
0229         >::type _tagged;
0230 #endif  // BOOST_PARAMETER_CAN_USE_MP11
0231 
0232         // Build the arg_list incrementally, prepending new nodes.
0233 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0234         using _error = ::boost::mp11::mp_if<
0235             ::boost::mp11::mp_if<
0236                 ::std::is_same<Error,::boost::parameter::void_>
0237               , ::std::is_same<_tagged,::boost::parameter::void_>
0238               , ::boost::mp11::mp_false
0239             >
0240 #else
0241         typedef typename ::boost::mpl::if_<
0242             typename ::boost::mpl::if_<
0243                 ::boost::is_same<Error,::boost::parameter::void_>
0244               , ::boost::is_same<_tagged,::boost::parameter::void_>
0245               , ::boost::mpl::false_
0246             >::type
0247 #endif
0248           , ::boost::parameter::aux::unmatched_argument<_argument>
0249           , ::boost::parameter::void_
0250 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0251         >;
0252 #else
0253         >::type _error;
0254 #endif
0255 
0256 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0257         using _argument_pack = typename ::boost::mp11::mp_if<
0258             ::std::is_same<_tagged,::boost::parameter::void_>
0259           , ::boost::mp11::mp_identity<ArgumentPack>
0260           , ::boost::parameter::aux
0261             ::append_to_make_arg_list<ArgumentPack,_tagged,EmitsErrors>
0262         >::type;
0263 #else   // !defined(BOOST_PARAMETER_CAN_USE_MP11)
0264         typedef typename ::boost::mpl::if_<
0265             ::boost::is_same<_tagged,::boost::parameter::void_>
0266           , ArgumentPack
0267 #if defined(BOOST_NO_SFINAE) || BOOST_WORKAROUND(BOOST_MSVC, < 1800)
0268           , ::boost::parameter::aux::arg_list<_tagged,ArgumentPack>
0269 #else
0270           , ::boost::parameter::aux
0271             ::arg_list<_tagged,ArgumentPack,EmitsErrors>
0272 #endif
0273         >::type _argument_pack;
0274 #endif  // BOOST_PARAMETER_CAN_USE_MP11
0275 
0276      public:
0277         typedef typename ::boost::parameter::aux::make_arg_list_aux<
0278             typename List::tail
0279           , DeducedArgs
0280           , TagFn
0281           , _is_positional
0282 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0283           , ::boost::mp11::mp_at_c<_deduced_data,1>
0284 #else
0285           , typename _deduced_data::second
0286 #endif
0287           , _argument_pack
0288           , _error
0289           , EmitsErrors
0290         >::type type;
0291     };
0292 
0293 #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
0294     template <
0295         typename List
0296       , typename DeducedArgs
0297       , typename TagFn
0298       , typename IsPositional
0299       , typename UsedArgs
0300       , typename ArgumentPack
0301       , typename Error
0302       , typename EmitsErrors
0303     >
0304     struct make_arg_list0
0305     {
0306         typedef typename ::boost::mpl::eval_if<
0307             typename List::is_arg_const
0308           , ::boost::parameter::aux::make_arg_list00<
0309                 List
0310               , DeducedArgs
0311               , TagFn
0312               , IsPositional
0313               , UsedArgs
0314               , ArgumentPack
0315               , typename List::arg const
0316               , Error
0317               , EmitsErrors
0318             >
0319           , ::boost::parameter::aux::make_arg_list00<
0320                 List
0321               , DeducedArgs
0322               , TagFn
0323               , IsPositional
0324               , UsedArgs
0325               , ArgumentPack
0326               , typename List::arg
0327               , Error
0328               , EmitsErrors
0329             >
0330         >::type type;
0331     };
0332 #endif  // Borland workarounds needed.
0333 
0334     // Returns an ArgumentPack where the list of arguments has been tagged
0335     // with keyword tags.
0336     //
0337     //   List:         A specialization of item<> (see below). Contains both
0338     //                 the ordered ParameterSpecs, and the given arguments.
0339     //
0340     //   DeducedArgs:  A specialization of deduced_item<> (see below).
0341     //                 A list containing only the deduced ParameterSpecs.
0342     //
0343     //   TagFn:        A metafunction class used to tag positional or deduced
0344     //                 arguments with a keyword tag.
0345     //
0346     //   IsPositional: An mpl::bool_<> specialization indicating if positional
0347     //                 matching is to be performed.
0348     //
0349     //   DeducedSet:   An mpl::set<> containing the keyword tags used so far.
0350     //
0351     //   ArgumentPack: The ArgumentPack built so far. This is initially an
0352     //                 empty_arg_list and is built incrementally.
0353     template <
0354         typename List
0355       , typename DeducedArgs
0356       , typename TagFn
0357       , typename IsPositional
0358       , typename DeducedSet
0359       , typename ArgumentPack
0360       , typename Error
0361       , typename EmitsErrors
0362     >
0363     struct make_arg_list_aux
0364 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0365       : ::boost::mp11::mp_if<
0366             ::std::is_same<List,::boost::parameter::void_>
0367           , ::boost::mp11::mp_identity<
0368                 ::boost::mp11::mp_list<ArgumentPack,Error>
0369             >
0370 #else
0371       : ::boost::mpl::eval_if<
0372             ::boost::is_same<List,::boost::parameter::void_>
0373           , ::boost::mpl::identity< ::boost::mpl::pair<ArgumentPack,Error> >
0374 #endif
0375           , ::boost::parameter::aux::make_arg_list0<
0376                 List
0377               , DeducedArgs
0378               , TagFn
0379               , IsPositional
0380               , DeducedSet
0381               , ArgumentPack
0382               , Error
0383               , EmitsErrors
0384             >
0385         >
0386     {
0387     };
0388 }}} // namespace boost::parameter::aux
0389 
0390 #include <boost/parameter/aux_/set.hpp>
0391 
0392 namespace boost { namespace parameter { namespace aux {
0393 
0394     // VC6.5 was choking on the default parameters for make_arg_list_aux,
0395     // so this just forwards to that adding in the defaults.
0396     template <
0397         typename List
0398       , typename DeducedArgs
0399       , typename TagFn
0400 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0401       , typename EmitsErrors = ::boost::mp11::mp_true
0402 #else
0403       , typename EmitsErrors = ::boost::mpl::true_
0404 #endif
0405     >
0406 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0407     using make_arg_list = ::boost::parameter::aux::make_arg_list_aux<
0408 #else
0409     struct make_arg_list
0410       : ::boost::parameter::aux::make_arg_list_aux<
0411 #endif
0412             List
0413           , DeducedArgs
0414           , TagFn
0415 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0416           , ::boost::mp11::mp_true
0417 #else
0418           , ::boost::mpl::true_
0419 #endif
0420           , ::boost::parameter::aux::set0
0421 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0422           , ::boost::parameter::aux::flat_like_arg_list<>
0423 #else
0424           , ::boost::parameter::aux::empty_arg_list
0425 #endif
0426           , ::boost::parameter::void_
0427           , EmitsErrors
0428 #if defined(BOOST_PARAMETER_CAN_USE_MP11)
0429     >;
0430 #else
0431         >
0432     {
0433     };
0434 #endif
0435 }}} // namespace boost::parameter::aux
0436 
0437 #endif  // include guard
0438