From 2169c5adb4c15c87384b1f6c90caf78ee964a905 Mon Sep 17 00:00:00 2001 From: CromwellEnage <32967088+CromwellEnage@users.noreply.github.com> Date: Wed, 24 Oct 2018 12:09:26 -0400 Subject: [PATCH 1/4] Restructure code : Move forward declarations to their own header files. : * Move boost::parameter::aux::tagged_argument_base, boost::parameter::aux::is_tagged_argument_aux, and boost::parameter::aux::is_tagged_argument to * Remove unnecessary forward declarations. : * Move support metafunction definitions to their own header files in directory boost/parameter/aux_/pack. * Move support macro definitions to and their corresponding #undef statements to . works at the preprocessor level, so move to . : * Move voidstar type definition to . * Move support metafunctions to their own header files in directory boost/parameter/aux_/pp_impl. * Move support macros to header files in directory boost/parameter/aux_/preprocessor/impl. --- include/boost/parameter/aux_/arg_list.hpp | 17 +- include/boost/parameter/aux_/cast.hpp | 143 +- .../parameter/aux_/is_tagged_argument.hpp | 46 + include/boost/parameter/aux_/lambda_tag.hpp | 16 + .../aux_/pack/as_parameter_requirements.hpp | 32 + .../boost/parameter/aux_/pack/deduce_tag.hpp | 129 ++ .../parameter/aux_/pack/deduced_item.hpp | 34 + .../parameter/aux_/pack/insert_tagged.hpp | 23 + .../parameter/aux_/pack/is_named_argument.hpp | 28 + include/boost/parameter/aux_/pack/item.hpp | 47 + .../parameter/aux_/pack/make_arg_list.hpp | 276 ++++ .../aux_/pack/make_deduced_items.hpp | 34 + .../boost/parameter/aux_/pack/make_items.hpp | 30 + .../aux_/pack/parameter_requirements.hpp | 25 + .../boost/parameter/aux_/pack/predicate.hpp | 67 + .../boost/parameter/aux_/pack/satisfies.hpp | 92 ++ .../boost/parameter/aux_/pack/tag_deduced.hpp | 37 + .../parameter/aux_/pack/tag_keyword_arg.hpp | 24 + .../aux_/pack/tag_template_keyword_arg.hpp | 24 + .../boost/parameter/aux_/pack/tag_type.hpp | 59 + .../aux_/pack/unmatched_argument.hpp | 31 + .../parameter/aux_/parameter_requirements.hpp | 23 +- .../parameter/aux_/parenthesized_type.hpp | 39 +- .../parameter/aux_/pp_impl/argument_pack.hpp | 47 + .../boost/parameter/aux_/pp_impl/match.hpp | 36 + .../aux_/pp_impl/unwrap_predicate.hpp | 75 ++ .../parameter/aux_/preprocessor/flatten.hpp | 117 +- .../aux_/preprocessor/impl/argument_specs.hpp | 24 + .../aux_/preprocessor/impl/arity_range.hpp | 42 + .../aux_/preprocessor/impl/flatten.hpp | 116 ++ .../impl/forwarding_overloads.hpp | 283 ++++ .../aux_/preprocessor/impl/function_cast.hpp | 154 +++ .../impl/function_dispatch_layer.hpp | 350 +++++ .../impl/function_dispatch_tuple.hpp | 29 + .../impl/function_forward_match.hpp | 33 + .../aux_/preprocessor/impl/function_name.hpp | 115 ++ .../preprocessor/impl/parenthesized_type.hpp | 34 + .../aux_/preprocessor/impl/specification.hpp | 95 ++ .../aux_/preprocessor/impl/split_args.hpp | 71 + .../parameter/aux_/preprocessor/is_binary.hpp | 30 + .../aux_/preprocessor/is_nullary.hpp | 31 + .../no_perfect_forwarding_begin.hpp | 80 ++ .../no_perfect_forwarding_end.hpp | 18 + .../aux_/{ => preprocessor}/overloads.hpp | 56 +- .../parameter/aux_/preprocessor/qualifier.hpp | 46 + .../boost/parameter/aux_/tagged_argument.hpp | 29 +- .../parameter/aux_/tagged_argument_fwd.hpp | 16 + include/boost/parameter/aux_/use_default.hpp | 17 + .../boost/parameter/aux_/use_default_tag.hpp | 21 + include/boost/parameter/aux_/void.hpp | 47 +- include/boost/parameter/deduced.hpp | 92 ++ include/boost/parameter/keyword_fwd.hpp | 16 + include/boost/parameter/optional.hpp | 52 + include/boost/parameter/parameters.hpp | 1157 ++++------------- include/boost/parameter/preprocessor.hpp | 1140 ++-------------- include/boost/parameter/required.hpp | 51 + test/preprocessor.cpp | 1 + 57 files changed, 3485 insertions(+), 2312 deletions(-) create mode 100755 include/boost/parameter/aux_/is_tagged_argument.hpp create mode 100755 include/boost/parameter/aux_/lambda_tag.hpp create mode 100755 include/boost/parameter/aux_/pack/as_parameter_requirements.hpp create mode 100755 include/boost/parameter/aux_/pack/deduce_tag.hpp create mode 100755 include/boost/parameter/aux_/pack/deduced_item.hpp create mode 100755 include/boost/parameter/aux_/pack/insert_tagged.hpp create mode 100755 include/boost/parameter/aux_/pack/is_named_argument.hpp create mode 100755 include/boost/parameter/aux_/pack/item.hpp create mode 100755 include/boost/parameter/aux_/pack/make_arg_list.hpp create mode 100755 include/boost/parameter/aux_/pack/make_deduced_items.hpp create mode 100755 include/boost/parameter/aux_/pack/make_items.hpp create mode 100755 include/boost/parameter/aux_/pack/parameter_requirements.hpp create mode 100755 include/boost/parameter/aux_/pack/predicate.hpp create mode 100755 include/boost/parameter/aux_/pack/satisfies.hpp create mode 100755 include/boost/parameter/aux_/pack/tag_deduced.hpp create mode 100755 include/boost/parameter/aux_/pack/tag_keyword_arg.hpp create mode 100755 include/boost/parameter/aux_/pack/tag_template_keyword_arg.hpp create mode 100755 include/boost/parameter/aux_/pack/tag_type.hpp create mode 100755 include/boost/parameter/aux_/pack/unmatched_argument.hpp create mode 100755 include/boost/parameter/aux_/pp_impl/argument_pack.hpp create mode 100755 include/boost/parameter/aux_/pp_impl/match.hpp create mode 100755 include/boost/parameter/aux_/pp_impl/unwrap_predicate.hpp create mode 100755 include/boost/parameter/aux_/preprocessor/impl/argument_specs.hpp create mode 100755 include/boost/parameter/aux_/preprocessor/impl/arity_range.hpp create mode 100755 include/boost/parameter/aux_/preprocessor/impl/flatten.hpp create mode 100755 include/boost/parameter/aux_/preprocessor/impl/forwarding_overloads.hpp create mode 100755 include/boost/parameter/aux_/preprocessor/impl/function_cast.hpp create mode 100755 include/boost/parameter/aux_/preprocessor/impl/function_dispatch_layer.hpp create mode 100755 include/boost/parameter/aux_/preprocessor/impl/function_dispatch_tuple.hpp create mode 100755 include/boost/parameter/aux_/preprocessor/impl/function_forward_match.hpp create mode 100755 include/boost/parameter/aux_/preprocessor/impl/function_name.hpp create mode 100755 include/boost/parameter/aux_/preprocessor/impl/parenthesized_type.hpp create mode 100755 include/boost/parameter/aux_/preprocessor/impl/specification.hpp create mode 100755 include/boost/parameter/aux_/preprocessor/impl/split_args.hpp create mode 100755 include/boost/parameter/aux_/preprocessor/is_binary.hpp create mode 100755 include/boost/parameter/aux_/preprocessor/is_nullary.hpp create mode 100755 include/boost/parameter/aux_/preprocessor/no_perfect_forwarding_begin.hpp create mode 100755 include/boost/parameter/aux_/preprocessor/no_perfect_forwarding_end.hpp rename include/boost/parameter/aux_/{ => preprocessor}/overloads.hpp (53%) mode change 100644 => 100755 create mode 100755 include/boost/parameter/aux_/preprocessor/qualifier.hpp create mode 100755 include/boost/parameter/aux_/tagged_argument_fwd.hpp create mode 100755 include/boost/parameter/aux_/use_default.hpp create mode 100755 include/boost/parameter/aux_/use_default_tag.hpp create mode 100755 include/boost/parameter/deduced.hpp create mode 100755 include/boost/parameter/keyword_fwd.hpp create mode 100755 include/boost/parameter/optional.hpp create mode 100755 include/boost/parameter/required.hpp diff --git a/include/boost/parameter/aux_/arg_list.hpp b/include/boost/parameter/aux_/arg_list.hpp index 721ce04..5b82ccd 100644 --- a/include/boost/parameter/aux_/arg_list.hpp +++ b/include/boost/parameter/aux_/arg_list.hpp @@ -12,6 +12,9 @@ #include #include #include +#include +#include +#include #include #include @@ -26,15 +29,7 @@ #include #include -namespace boost { namespace parameter { - -// Forward declaration for aux::arg_list, below. -template struct keyword; - -namespace aux { - -// Tag type passed to MPL lambda. -struct lambda_tag; +namespace boost { namespace parameter { namespace aux { // // Structures used to build the tuple of actual arguments. The @@ -146,10 +141,6 @@ struct empty_arg_list typedef arg_list_tag tag; // For dispatching to sequence intrinsics }; -// Forward declaration for arg_list::operator, -template -struct tagged_argument; - template struct get_reference { diff --git a/include/boost/parameter/aux_/cast.hpp b/include/boost/parameter/aux_/cast.hpp index bd3de2b..0125e22 100644 --- a/include/boost/parameter/aux_/cast.hpp +++ b/include/boost/parameter/aux_/cast.hpp @@ -1,141 +1,12 @@ -// Copyright Daniel Wallin 2006. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_PARAMETER_CAST_060902_HPP -# define BOOST_PARAMETER_CAST_060902_HPP +#define BOOST_PARAMETER_CAST_060902_HPP -# include +#include -# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -# include -# include -# endif - -namespace boost { namespace parameter { namespace aux { - -struct use_default_tag {}; - -# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - -# define BOOST_PARAMETER_FUNCTION_CAST(value, predicate) value - -# else - -// Handles possible implicit casts. Used by preprocessor.hpp to -// normalize user input. -// -// cast::execute() is identity -// cast::execute() is identity -// cast::execute() casts to X -// -// preprocessor.hpp uses this like this: -// -// #define X(value, predicate) -// cast::execute(value) -// -// X(something, *) -// X(something, *(predicate)) -// X(something, (int)) - -template -struct cast; - -template -struct cast -{ - static use_default_tag execute(use_default_tag) - { - return use_default_tag(); - } - - static use_default_tag remove_const(use_default_tag) - { - return use_default_tag(); - } - - template - static U& execute(U& value) - { - return value; - } - - template - static U& remove_const(U& x) - { - return x; - } -}; - -#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) - -typedef void* voidstar; - -template -struct cast - : cast -{ -}; - -#else - -template -struct cast - : cast -{ -}; - -#endif - -// This is a hack used in cast<> to turn the user supplied type, -// which may or may not be a placeholder expression into one, so -// that it will be properly evaluated by mpl::apply. -template -struct as_placeholder_expr -{ - typedef T type; -}; - -template -struct cast -{ - typedef typename mpl::apply2< - as_placeholder_expr, Args, Args>::type type0; - - typedef typename boost::add_reference< - typename boost::remove_const::type - >::type reference; - - static use_default_tag execute(use_default_tag) - { - return use_default_tag(); - } - - static use_default_tag remove_const(use_default_tag) - { - return use_default_tag(); - } - - static type0 execute(type0 value) - { - return value; - } - - template - static reference remove_const(U const& x) - { - return const_cast(x); - } -}; - -# define BOOST_PARAMETER_FUNCTION_CAST(value, predicate, args) \ - boost::parameter::aux::cast::remove_const( \ - boost::parameter::aux::cast::execute(value) \ - ) - -# endif - -}}} // namespace boost::parameter::aux - -#endif // BOOST_PARAMETER_CAST_060902_HPP +#endif // include guard diff --git a/include/boost/parameter/aux_/is_tagged_argument.hpp b/include/boost/parameter/aux_/is_tagged_argument.hpp new file mode 100755 index 0000000..e2cb35c --- /dev/null +++ b/include/boost/parameter/aux_/is_tagged_argument.hpp @@ -0,0 +1,46 @@ +// Copyright Daniel Wallin, David Abrahams 2005. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_IS_TAGGED_ARGUMENT_HPP +#define BOOST_PARAMETER_IS_TAGGED_ARGUMENT_HPP + +namespace boost { namespace parameter { namespace aux { + + struct tagged_argument_base + { + }; +}}} // namespace boost::parameter::aux + +#include +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + template + struct is_tagged_argument_aux + : ::boost::is_convertible< + T* + , ::boost::parameter::aux::tagged_argument_base const* + > + { + }; + + // This metafunction identifies tagged_argument specializations + // and their derived classes. + template + struct is_tagged_argument + : ::boost::mpl::if_< + ::boost::is_lvalue_reference + , ::boost::mpl::false_ + , ::boost::parameter::aux::is_tagged_argument_aux + >::type + { + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/lambda_tag.hpp b/include/boost/parameter/aux_/lambda_tag.hpp new file mode 100755 index 0000000..77759a2 --- /dev/null +++ b/include/boost/parameter/aux_/lambda_tag.hpp @@ -0,0 +1,16 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_LAMBDA_TAG_HPP +#define BOOST_PARAMETER_AUX_LAMBDA_TAG_HPP + +namespace boost { namespace parameter { namespace aux { + + // Tag type passed to MPL lambda. + struct lambda_tag; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/as_parameter_requirements.hpp b/include/boost/parameter/aux_/pack/as_parameter_requirements.hpp new file mode 100755 index 0000000..65fae4c --- /dev/null +++ b/include/boost/parameter/aux_/pack/as_parameter_requirements.hpp @@ -0,0 +1,32 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_AS_PARAMETER_REQUIREMENTS_HPP +#define BOOST_PARAMETER_AUX_PACK_AS_PARAMETER_REQUIREMENTS_HPP + +#include +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + // Converts a ParameterSpec into a specialization of + // parameter_requirements. We need to do this in order to get the + // tag_type into the type in a way that can be conveniently matched + // by a satisfies(...) member function in arg_list. + template + struct as_parameter_requirements + { + typedef ::boost::parameter::aux::parameter_requirements< + typename ::boost::parameter::aux::tag_type::type + , typename ::boost::parameter::aux::predicate::type + , ::boost::parameter::aux::has_default + > type; + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/deduce_tag.hpp b/include/boost/parameter/aux_/pack/deduce_tag.hpp new file mode 100755 index 0000000..d95b94b --- /dev/null +++ b/include/boost/parameter/aux_/pack/deduce_tag.hpp @@ -0,0 +1,129 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_DEDUCE_TAG_HPP +#define BOOST_PARAMETER_AUX_PACK_DEDUCE_TAG_HPP + +namespace boost { namespace parameter { namespace aux { + + template < + typename Argument + , typename ArgumentPack + , typename DeducedArgs + , typename UsedArgs + , typename TagFn + > + struct deduce_tag; +}}} // namespace boost::parameter::aux + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + // Helper for deduce_tag<...>, below. + template < + typename Argument + , typename ArgumentPack + , typename DeducedArgs + , typename UsedArgs + , typename TagFn + > + struct deduce_tag0 + { + typedef typename DeducedArgs::spec spec; + + typedef typename ::boost::mpl::apply_wrap2< + typename ::boost::mpl::lambda< + typename spec::predicate + , ::boost::parameter::aux::lambda_tag + >::type + , Argument + , ArgumentPack + >::type condition; + + // Deduced parameter matches several arguments. + BOOST_MPL_ASSERT(( + typename ::boost::mpl::eval_if< + typename ::boost::parameter::aux::has_key_< + UsedArgs + , typename ::boost::parameter::aux::tag_type::type + >::type + , ::boost::mpl::if_< + condition + , ::boost::mpl::false_ + , ::boost::mpl::true_ + > + , ::boost::mpl::true_ + >::type + )); + + typedef typename ::boost::mpl::eval_if< + condition + , ::boost::parameter::aux::tag_deduced + , ::boost::parameter::aux::deduce_tag< + Argument + , ArgumentPack + , typename DeducedArgs::tail + , UsedArgs + , TagFn + > + >::type type; + }; +}}} // namespace boost::parameter::aux + +#include +#include + +namespace boost { namespace parameter { namespace aux { + + // Tries to deduced a keyword tag for a given Argument. + // Returns an mpl::pair<> consisting of the tagged_argument<>, + // and an mpl::set<> where the new tag has been inserted. + // + // Argument: The argument type to be tagged. + // + // ArgumentPack: The ArgumentPack built so far. + // + // DeducedArgs: A specialization of deduced_item<> (see below). + // A list containing only the deduced ParameterSpecs. + // + // UsedArgs: An mpl::set<> containing the keyword tags used so far. + // + // TagFn: A metafunction class used to tag positional or deduced + // arguments with a keyword tag. + template < + typename Argument + , typename ArgumentPack + , typename DeducedArgs + , typename UsedArgs + , typename TagFn + > + struct deduce_tag + : ::boost::mpl::eval_if< + ::boost::is_same + , ::boost::mpl::pair< ::boost::parameter::void_,UsedArgs> + , ::boost::parameter::aux::deduce_tag0< + Argument + , ArgumentPack + , DeducedArgs + , UsedArgs + , TagFn + > + > + { + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/deduced_item.hpp b/include/boost/parameter/aux_/pack/deduced_item.hpp new file mode 100755 index 0000000..280e6ea --- /dev/null +++ b/include/boost/parameter/aux_/pack/deduced_item.hpp @@ -0,0 +1,34 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_DEDUCED_ITEM_HPP +#define BOOST_PARAMETER_AUX_PACK_DEDUCED_ITEM_HPP + +#include + +namespace boost { namespace parameter { namespace aux { + + // A typelist that stored deduced parameter specs. + template < + typename ParameterSpec + , typename Tail = ::boost::parameter::void_ + > + struct deduced_item + { + typedef ParameterSpec spec; + typedef Tail tail; + }; + + // Evaluate Tail and construct deduced_item list. + template + struct make_deduced_item + { + typedef ::boost::parameter::aux + ::deduced_item type; + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/insert_tagged.hpp b/include/boost/parameter/aux_/pack/insert_tagged.hpp new file mode 100755 index 0000000..bef47b1 --- /dev/null +++ b/include/boost/parameter/aux_/pack/insert_tagged.hpp @@ -0,0 +1,23 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_INSERT_TAGGED_HPP +#define BOOST_PARAMETER_AUX_PACK_INSERT_TAGGED_HPP + +#include + +namespace boost { namespace parameter { namespace aux { + + // Inserts Tagged::key_type into the UserArgs set. + // Extra indirection to lazily evaluate Tagged::key_type. + template + struct insert_tagged + : ::boost::parameter::aux::insert_ + { + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/is_named_argument.hpp b/include/boost/parameter/aux_/pack/is_named_argument.hpp new file mode 100755 index 0000000..6c9be3c --- /dev/null +++ b/include/boost/parameter/aux_/pack/is_named_argument.hpp @@ -0,0 +1,28 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_IS_NAMED_ARGUMENT_HPP +#define BOOST_PARAMETER_AUX_PACK_IS_NAMED_ARGUMENT_HPP + +#include +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + template + struct is_named_argument + : ::boost::mpl::if_< + ::boost::parameter::aux::is_template_keyword + , ::boost::mpl::true_ + , ::boost::parameter::aux::is_tagged_argument + >::type + { + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/item.hpp b/include/boost/parameter/aux_/pack/item.hpp new file mode 100755 index 0000000..b408051 --- /dev/null +++ b/include/boost/parameter/aux_/pack/item.hpp @@ -0,0 +1,47 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_ITEM_HPP +#define BOOST_PARAMETER_AUX_PACK_ITEM_HPP + +#include +#include +#include + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +#include +#include +#endif + +namespace boost { namespace parameter { namespace aux { + + // A parameter spec item typelist. + template < + typename Spec + , typename Arg + , typename Tail = ::boost::parameter::void_ + > + struct item + { + typedef Spec spec; +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + typedef ::boost::is_const< + typename ::boost::remove_reference::type + > is_arg_const; +#endif + typedef Arg arg; + typedef Tail tail; + }; + + template + struct make_item + { + typedef boost::parameter::aux + ::item type; + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/make_arg_list.hpp b/include/boost/parameter/aux_/pack/make_arg_list.hpp new file mode 100755 index 0000000..17eb0ed --- /dev/null +++ b/include/boost/parameter/aux_/pack/make_arg_list.hpp @@ -0,0 +1,276 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_MAKE_ARG_LIST_HPP +#define BOOST_PARAMETER_AUX_PACK_MAKE_ARG_LIST_HPP + +namespace boost { namespace parameter { namespace aux { + + template < + typename List + , typename DeducedArgs + , typename TagFn + , typename Positional + , typename UsedArgs + , typename ArgumentPack + , typename Error + > + struct make_arg_list_aux; +}}} // namespace boost::parameter::aux + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + // Borland needs the insane extra-indirection workaround below so that + // it doesn't magically drop the const qualifier from the argument type. + template < + typename List + , typename DeducedArgs + , typename TagFn + , typename Positional + , typename UsedArgs + , typename ArgumentPack +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + , typename argument +#endif + , typename Error + > +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + struct make_arg_list00 +#else + struct make_arg_list0 +#endif + { +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + typedef typename List::arg argument; +#endif + typedef typename ::boost::remove_const< + typename ::boost::remove_reference::type + >::type arg_type; + typedef typename List::spec parameter_spec; + typedef typename ::boost::parameter::aux + ::tag_type::type tag_; + typedef ::boost::parameter::aux + ::is_named_argument is_tagged; + + // If this argument is either explicitly tagged or a deduced + // parameter, then turn off positional matching. + typedef typename ::boost::mpl::eval_if< + Positional + , ::boost::mpl::eval_if< + ::boost::parameter::aux::is_deduced + , ::boost::mpl::false_ + , ::boost::mpl::if_< + is_tagged + , ::boost::mpl::false_ + , ::boost::mpl::true_ + > + > + , ::boost::mpl::false_ + >::type positional; + + // If this parameter is explicitly tagged, then add it to the + // used-parmeters set. We only really need to add parameters + // that are deduced, but we would need a way to check if + // a given tag corresponds to a deduced parameter spec. + typedef typename ::boost::mpl::eval_if< + is_tagged + , ::boost::parameter::aux::insert_tagged + , ::boost::mpl::identity + >::type used_args; + + // If this parameter is neither explicitly tagged nor positionally + // matched, then deduce the tag from the deduced parameter specs. + typedef typename ::boost::mpl::eval_if< + typename ::boost::mpl::if_< + is_tagged + , ::boost::mpl::true_ + , positional + >::type + , ::boost::mpl::pair< ::boost::parameter::void_,used_args> + , ::boost::parameter::aux::deduce_tag< + argument + , ArgumentPack + , DeducedArgs + , used_args + , TagFn + > + >::type deduced_data; + + // If this parameter is explicitly tagged ... + typedef typename ::boost::mpl::eval_if< + is_tagged + // ... just use it + , ::boost::mpl::identity + // ... else ... + , ::boost::mpl::eval_if< + // if positional matching is turned on ... + positional + // ... tag it positionally + , ::boost::mpl::apply_wrap2 + // ... else, use the deduced tag + , ::boost::mpl::first + > + >::type tagged; + + // Build the arg_list incrementally, prepending new nodes. + typedef typename ::boost::mpl::if_< + typename ::boost::mpl::if_< + ::boost::is_same + , ::boost::is_same + , ::boost::mpl::false_ + >::type + , ::boost::parameter::aux::unmatched_argument + , ::boost::parameter::void_ + >::type error; + + typedef typename ::boost::mpl::if_< + ::boost::is_same + , ArgumentPack + , ::boost::parameter::aux::arg_list + >::type argument_pack; + + typedef typename ::boost::parameter::aux::make_arg_list_aux< + typename List::tail + , DeducedArgs + , TagFn + , positional + , typename deduced_data::second + , argument_pack + , error + >::type type; + }; + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + template < + typename List + , typename DeducedArgs + , typename TagFn + , typename Positional + , typename UsedArgs + , typename ArgumentPack + , typename Error + > + struct make_arg_list0 + { + typedef typename ::boost::mpl::eval_if< + typename List::is_arg_const + , ::boost::parameter::aux::make_arg_list00< + List + , DeducedArgs + , TagFn + , Positional + , UsedArgs + , ArgumentPack + , typename List::arg const + , Error + > + , ::boost::parameter::aux::make_arg_list00< + List + , DeducedArgs + , TagFn + , Positional + , UsedArgs + , ArgumentPack + , typename List::arg + , Error + > + >::type type; + }; +#endif // Borland workarounds needed. + + // Returns an ArgumentPack where the list of arguments has been tagged + // with keyword tags. + // + // List: A specialization of item<> (see below). Contains both + // the ordered ParameterSpecs, and the given arguments. + // + // DeducedArgs: A specialization of deduced_item<> (see below). + // A list containing only the deduced ParameterSpecs. + // + // TagFn: A metafunction class used to tag positional or deduced + // arguments with a keyword tag. + // + // Positional: An mpl::bool_<> specialization indicating if positional + // matching is to be performed. + // + // DeducedSet: An mpl::set<> containing the keyword tags used so far. + // + // ArgumentPack: The ArgumentPack built so far. This is initially an + // empty_arg_list and is built incrementally. + template < + typename List + , typename DeducedArgs + , typename TagFn + , typename Positional + , typename DeducedSet + , typename ArgumentPack + , typename Error + > + struct make_arg_list_aux + : ::boost::mpl::eval_if< + ::boost::is_same + , ::boost::mpl::identity< ::boost::mpl::pair > + , ::boost::parameter::aux::make_arg_list0< + List + , DeducedArgs + , TagFn + , Positional + , DeducedSet + , ArgumentPack + , Error + > + > + { + }; +}}} // namespace boost::parameter::aux + +#include + +namespace boost { namespace parameter { namespace aux { + + // VC6.5 was choking on the default parameters for make_arg_list_aux, + // so this just forwards to that adding in the defaults. + template < + typename List + , typename DeducedArgs + , typename TagFn + , typename EmitErrors = ::boost::mpl::true_ + > + struct make_arg_list + : ::boost::parameter::aux::make_arg_list_aux< + List + , DeducedArgs + , TagFn + , ::boost::mpl::true_ + , ::boost::parameter::aux::set0 + , ::boost::parameter::aux::empty_arg_list + , ::boost::parameter::void_ + > + { + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/make_deduced_items.hpp b/include/boost/parameter/aux_/pack/make_deduced_items.hpp new file mode 100755 index 0000000..140506c --- /dev/null +++ b/include/boost/parameter/aux_/pack/make_deduced_items.hpp @@ -0,0 +1,34 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_MAKE_DEDUCED_ITEMS_HPP +#define BOOST_PARAMETER_AUX_PACK_MAKE_DEDUCED_ITEMS_HPP + +#include +#include +#include +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + template + struct make_deduced_items + : ::boost::mpl::eval_if< + ::boost::is_same + , ::boost::mpl::identity< ::boost::parameter::void_> + , ::boost::mpl::eval_if< + ::boost::parameter::aux::is_deduced + , ::boost::parameter::aux::make_deduced_item + , Tail + > + > + { + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/make_items.hpp b/include/boost/parameter/aux_/pack/make_items.hpp new file mode 100755 index 0000000..8a9a847 --- /dev/null +++ b/include/boost/parameter/aux_/pack/make_items.hpp @@ -0,0 +1,30 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_MAKE_ITEMS_HPP +#define BOOST_PARAMETER_AUX_PACK_MAKE_ITEMS_HPP + +#include +#include +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + // Creates a item typelist. + template + struct make_items + : ::boost::mpl::eval_if< + ::boost::is_same + , ::boost::mpl::identity< ::boost::parameter::void_> + , ::boost::parameter::aux::make_item + > + { + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/parameter_requirements.hpp b/include/boost/parameter/aux_/pack/parameter_requirements.hpp new file mode 100755 index 0000000..709da21 --- /dev/null +++ b/include/boost/parameter/aux_/pack/parameter_requirements.hpp @@ -0,0 +1,25 @@ +// Copyright Daniel Wallin, David Abrahams 2005. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_PARAMETER_REQUIREMENTS_HPP +#define BOOST_PARAMETER_AUX_PACK_PARAMETER_REQUIREMENTS_HPP + +namespace boost { namespace parameter { namespace aux { + + // Used to pass static information about parameter requirements through + // the satisfies() overload set (below). The matched function is never + // invoked, but its type indicates whether a parameter matches at + // compile-time. + template + struct parameter_requirements + { + typedef Keyword keyword; + typedef Predicate predicate; + typedef HasDefault has_default; + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/predicate.hpp b/include/boost/parameter/aux_/pack/predicate.hpp new file mode 100755 index 0000000..0c3903b --- /dev/null +++ b/include/boost/parameter/aux_/pack/predicate.hpp @@ -0,0 +1,67 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_PREDICATE_HPP +#define BOOST_PARAMETER_AUX_PACK_PREDICATE_HPP + +namespace boost { namespace parameter { namespace aux { + + // helper for get_predicate<...>, below + template + struct get_predicate_or_default + { + typedef T type; + }; + + // helper for predicate<...>, below + template + struct get_predicate + : ::boost::parameter::aux + ::get_predicate_or_default + { + }; +}}} // namespace boost::parameter::aux + +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + template <> + struct get_predicate_or_default< ::boost::parameter::aux::use_default> + { + typedef ::boost::mpl::always< ::boost::mpl::true_> type; + }; +}}} // namespace boost::parameter::aux + +#include +#include +#include +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + template + struct predicate + : ::boost::mpl::eval_if< + typename ::boost::mpl::if_< + ::boost::parameter::aux::is_optional + , ::boost::mpl::true_ + , ::boost::parameter::aux::is_required + >::type + , ::boost::parameter::aux::get_predicate + , ::boost::mpl::identity< + ::boost::mpl::always< ::boost::mpl::true_> + > + > + { + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/satisfies.hpp b/include/boost/parameter/aux_/pack/satisfies.hpp new file mode 100755 index 0000000..f201a1e --- /dev/null +++ b/include/boost/parameter/aux_/pack/satisfies.hpp @@ -0,0 +1,92 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_SATISFIES_HPP +#define BOOST_PARAMETER_AUX_PACK_SATISFIES_HPP + +#include +#include +#include + +#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) +#include +#include +#include +#include +#include +#else +#include +#include +#endif + +namespace boost { namespace parameter { namespace aux { + + // Returns mpl::true_ iff the given ParameterRequirements are satisfied by + // ArgList. + template + struct satisfies + { +#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) + // VC7.1 can't handle the sizeof() implementation below, + // so we use this instead. + typedef typename ::boost::mpl::apply_wrap3< + typename ArgList::binding + , typename ParameterRequirements::keyword + , ::boost::parameter::void_ + , ::boost::mpl::false_ + >::type bound; + + typedef typename ::boost::mpl::eval_if< + ::boost::is_same + , typename ParameterRequirements::has_default + , ::boost::mpl::apply_wrap2< + ::boost::parameter::aux::augment_predicate< + typename ParameterRequirements::predicate + , typename ArgList::reference + , typename ArgList::key_type + > + , bound + , ArgList + > + >::type type; +#else // !BOOST_WORKAROUND(BOOST_MSVC, == 1310) + BOOST_STATIC_CONSTANT( + bool, value = ( + sizeof( + ::boost::parameter::aux::to_yesno( + ArgList::satisfies( + static_cast( + BOOST_TTI_DETAIL_NULLPTR + ) + , static_cast(BOOST_TTI_DETAIL_NULLPTR) + ) + ) + ) == sizeof(::boost::parameter::aux::yes_tag) + ) + ); + + typedef ::boost::mpl::bool_ type; +#endif // MSVC 7.1 workarounds needed. + }; +}}} // namespace boost::parameter::aux + +#include + +namespace boost { namespace parameter { namespace aux { + // Returns mpl::true_ if the requirements of the given ParameterSpec + // are satisfied by ArgList. + template + struct satisfies_requirements_of + : ::boost::parameter::aux::satisfies< + ArgList + , typename ::boost::parameter::aux + ::as_parameter_requirements::type + > + { + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/tag_deduced.hpp b/include/boost/parameter/aux_/pack/tag_deduced.hpp new file mode 100755 index 0000000..f0b1d4a --- /dev/null +++ b/include/boost/parameter/aux_/pack/tag_deduced.hpp @@ -0,0 +1,37 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_TAG_DEDUCED_HPP +#define BOOST_PARAMETER_AUX_PACK_TAG_DEDUCED_HPP + +#include +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + // Tags a deduced argument Arg with the keyword tag of Spec using TagFn. + // Returns the tagged argument and the mpl::set<> UsedArgs with the + // tag of Spec inserted. + template + struct tag_deduced + { + typedef ::boost::mpl::pair< + typename ::boost::mpl::apply_wrap2< + TagFn + , typename ::boost::parameter::aux::tag_type::type + , Arg + >::type + , typename ::boost::parameter::aux::insert_< + UsedArgs + , typename ::boost::parameter::aux::tag_type::type + >::type + > type; + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/tag_keyword_arg.hpp b/include/boost/parameter/aux_/pack/tag_keyword_arg.hpp new file mode 100755 index 0000000..91d3151 --- /dev/null +++ b/include/boost/parameter/aux_/pack/tag_keyword_arg.hpp @@ -0,0 +1,24 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_TAG_KEYWORD_ARG_HPP +#define BOOST_PARAMETER_AUX_PACK_TAG_KEYWORD_ARG_HPP + +#include + +namespace boost { namespace parameter { namespace aux { + + struct tag_keyword_arg + { + template + struct apply + { + typedef typename ::boost::parameter::aux::tag::type type; + }; + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/tag_template_keyword_arg.hpp b/include/boost/parameter/aux_/pack/tag_template_keyword_arg.hpp new file mode 100755 index 0000000..c9c8167 --- /dev/null +++ b/include/boost/parameter/aux_/pack/tag_template_keyword_arg.hpp @@ -0,0 +1,24 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_TAG_TEMPLATE_KEYWORD_ARG_HPP +#define BOOST_PARAMETER_AUX_PACK_TAG_TEMPLATE_KEYWORD_ARG_HPP + +#include + +namespace boost { namespace parameter { namespace aux { + + struct tag_template_keyword_arg + { + template + struct apply + { + typedef ::boost::parameter::template_keyword type; + }; + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/tag_type.hpp b/include/boost/parameter/aux_/pack/tag_type.hpp new file mode 100755 index 0000000..18b0589 --- /dev/null +++ b/include/boost/parameter/aux_/pack/tag_type.hpp @@ -0,0 +1,59 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_TAG_TYPE_HPP +#define BOOST_PARAMETER_AUX_PACK_TAG_TYPE_HPP + +namespace boost { namespace parameter { namespace aux { + + // helper for tag_type<...>, below. + template + struct get_tag_type0 + { + typedef typename T::key_type type; + }; +}}} // namespace boost::parameter::aux + +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + template + struct get_tag_type + : ::boost::mpl::eval_if< + ::boost::parameter::aux::is_deduced_aux + , ::boost::parameter::aux::get_tag_type0 + , ::boost::mpl::identity + > + { + }; +}}} // namespace boost::parameter::aux + +#include +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + template + struct tag_type + : ::boost::mpl::eval_if< + typename ::boost::mpl::if_< + ::boost::parameter::aux::is_optional + , ::boost::mpl::true_ + , ::boost::parameter::aux::is_required + >::type + , ::boost::parameter::aux::get_tag_type + , ::boost::mpl::identity + > + { + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pack/unmatched_argument.hpp b/include/boost/parameter/aux_/pack/unmatched_argument.hpp new file mode 100755 index 0000000..817a449 --- /dev/null +++ b/include/boost/parameter/aux_/pack/unmatched_argument.hpp @@ -0,0 +1,31 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PACK_UNMATCHED_ARGUMENT_HPP +#define BOOST_PARAMETER_AUX_PACK_UNMATCHED_ARGUMENT_HPP + +#include +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + template + struct unmatched_argument + { + BOOST_MPL_ASSERT(( + typename ::boost::mpl::if_< + ::boost::is_same + , ::boost::mpl::true_ + , ::boost::mpl::false_ + >::type + )); + typedef int type; + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/parameter_requirements.hpp b/include/boost/parameter/aux_/parameter_requirements.hpp index ad7a129..d372691 100644 --- a/include/boost/parameter/aux_/parameter_requirements.hpp +++ b/include/boost/parameter/aux_/parameter_requirements.hpp @@ -1,25 +1,12 @@ -// Copyright Daniel Wallin, David Abrahams 2005. Use, modification and -// distribution is subject to the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at +// Copyright Daniel Wallin, David Abrahams 2005. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef PARAMETER_REQUIREMENTS_050331_HPP #define PARAMETER_REQUIREMENTS_050331_HPP -namespace boost { namespace parameter { namespace aux { +#include -// Used to pass static information about parameter requirements -// through the satisfies() overload set (below). The -// matched function is never invoked, but its type indicates whether -// a parameter matches at compile-time -template -struct parameter_requirements -{ - typedef Keyword keyword; - typedef Predicate predicate; - typedef HasDefault has_default; -}; +#endif // include guard -}}} // namespace boost::parameter::aux - -#endif // PARAMETER_REQUIREMENTS_050331_HPP diff --git a/include/boost/parameter/aux_/parenthesized_type.hpp b/include/boost/parameter/aux_/parenthesized_type.hpp index 69e7a23..863e062 100644 --- a/include/boost/parameter/aux_/parenthesized_type.hpp +++ b/include/boost/parameter/aux_/parenthesized_type.hpp @@ -1,35 +1,12 @@ -// Copyright David Abrahams 2006. Distributed under the Boost -// Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// Copyright David Abrahams 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + #ifndef BOOST_PARAMETER_AUX_PARENTHESIZED_TYPE_DWA2006414_HPP -# define BOOST_PARAMETER_AUX_PARENTHESIZED_TYPE_DWA2006414_HPP +#define BOOST_PARAMETER_AUX_PARENTHESIZED_TYPE_DWA2006414_HPP -# include -# include +#include -namespace boost { namespace parameter { namespace aux { +#endif // include guard -// A macro that takes a parenthesized C++ type name (T) and transforms -// it into an un-parenthesized type expression equivalent to T. -# define BOOST_PARAMETER_PARENTHESIZED_TYPE(x) \ - boost::parameter::aux::unaryfunptr_arg_type< void(*)x >::type - -// A metafunction that transforms void(*)(T) -> T -template -struct unaryfunptr_arg_type; - -template -struct unaryfunptr_arg_type -{ - typedef Arg type; -}; - -template <> -struct unaryfunptr_arg_type -{ - typedef void type; -}; - -}}} // namespace boost::parameter::aux - -#endif // BOOST_PARAMETER_AUX_PARENTHESIZED_TYPE_DWA2006414_HPP diff --git a/include/boost/parameter/aux_/pp_impl/argument_pack.hpp b/include/boost/parameter/aux_/pp_impl/argument_pack.hpp new file mode 100755 index 0000000..c616e55 --- /dev/null +++ b/include/boost/parameter/aux_/pp_impl/argument_pack.hpp @@ -0,0 +1,47 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PP_IMPL_ARGUMENT_PACK_HPP +#define BOOST_PARAMETER_AUX_PP_IMPL_ARGUMENT_PACK_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + template < + typename Parameters + , BOOST_PP_ENUM_BINARY_PARAMS( + BOOST_PARAMETER_MAX_ARITY + , typename A + , = ::boost::parameter::void_ BOOST_PP_INTERCEPT + ) + > + struct argument_pack + { + typedef typename ::boost::parameter::aux::make_arg_list< + typename BOOST_PARAMETER_build_arg_list( + BOOST_PARAMETER_MAX_ARITY + , ::boost::parameter::aux::make_items + , typename Parameters::parameter_spec + , A + )::type + , typename Parameters::deduced_list + , ::boost::parameter::aux::tag_keyword_arg + , ::boost::mpl::false_ + >::type result; + typedef typename ::boost::mpl::first::type type; + }; +}}} // namespace boost::parameter::aux + +#include +#endif // include guard + diff --git a/include/boost/parameter/aux_/pp_impl/match.hpp b/include/boost/parameter/aux_/pp_impl/match.hpp new file mode 100755 index 0000000..8eefd79 --- /dev/null +++ b/include/boost/parameter/aux_/pp_impl/match.hpp @@ -0,0 +1,36 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PP_IMPL_MATCH_HPP +#define BOOST_PARAMETER_AUX_PP_IMPL_MATCH_HPP + +#include +#include +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + // Recast the ParameterSpec's nested match metafunction + // as a free metafunction. + template < + typename Parameters + , BOOST_PP_ENUM_BINARY_PARAMS( + BOOST_PARAMETER_MAX_ARITY + , typename A + , = ::boost::parameter::void_ BOOST_PP_INTERCEPT + ) + > + struct match + : Parameters::BOOST_NESTED_TEMPLATE match< + BOOST_PP_ENUM_PARAMS(BOOST_PARAMETER_MAX_ARITY, A) + > + { + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/pp_impl/unwrap_predicate.hpp b/include/boost/parameter/aux_/pp_impl/unwrap_predicate.hpp new file mode 100755 index 0000000..dcefc35 --- /dev/null +++ b/include/boost/parameter/aux_/pp_impl/unwrap_predicate.hpp @@ -0,0 +1,75 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PP_IMPL_UNWRAP_PREDICATE_HPP +#define BOOST_PARAMETER_AUX_PP_IMPL_UNWRAP_PREDICATE_HPP + +namespace boost { namespace parameter { namespace aux { + + // Given Match, which is "void x" where x is an argument matching + // criterion, extract a corresponding MPL predicate. + template + struct unwrap_predicate; +}}} // namespace boost::parameter::aux + +#include +#include + +namespace boost { namespace parameter { namespace aux { + + // Match anything + template <> + struct unwrap_predicate + { + typedef ::boost::mpl::always< ::boost::mpl::true_> type; + }; +}}} // namespace boost::parameter::aux + +#include +#include + +#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) +#include +#endif + +namespace boost { namespace parameter { namespace aux { + + // A matching predicate is explicitly specified. +#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) + template + struct unwrap_predicate< ::boost::parameter::aux::voidstar(Predicate)> + { + typedef Predicate type; + }; +#else + template + struct unwrap_predicate + { + typedef Predicate type; + }; +#endif // SunProCC workarounds needed. +}}} // namespace boost::parameter::aux + +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + // A type to which the argument is supposed to be convertible is + // specified. + template + struct unwrap_predicate + { + typedef ::boost::mpl::if_< + ::boost::is_convertible< ::boost::mpl::_,Target> + , ::boost::mpl::true_ + , ::boost::mpl::false_ + > type; + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/preprocessor/flatten.hpp b/include/boost/parameter/aux_/preprocessor/flatten.hpp index 5d7615e..876a928 100644 --- a/include/boost/parameter/aux_/preprocessor/flatten.hpp +++ b/include/boost/parameter/aux_/preprocessor/flatten.hpp @@ -1,115 +1,12 @@ -// Copyright Daniel Wallin 2005. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// Copyright Daniel Wallin 2005. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_PARAMETER_FLATTEN_051217_HPP -# define BOOST_PARAMETER_FLATTEN_051217_HPP +#define BOOST_PARAMETER_FLATTEN_051217_HPP -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include +#include -# define BOOST_PARAMETER_FLATTEN_SPLIT_required required, -# define BOOST_PARAMETER_FLATTEN_SPLIT_optional optional, -# define BOOST_PARAMETER_FLATTEN_SPLIT_deduced deduced, - -# define BOOST_PARAMETER_FLATTEN_SPLIT(sub) \ - BOOST_PP_CAT(BOOST_PARAMETER_FLATTEN_SPLIT_, sub) - -# define BOOST_PARAMETER_FLATTEN_QUALIFIER(sub) \ - BOOST_PP_SPLIT(0, BOOST_PARAMETER_FLATTEN_SPLIT(sub)) - -# define BOOST_PARAMETER_FLATTEN_ARGS(sub) \ - BOOST_PP_SPLIT(1, BOOST_PARAMETER_FLATTEN_SPLIT(sub)) - -# define BOOST_PARAMETER_FLATTEN_ARITY_optional(arities) \ - BOOST_PP_TUPLE_ELEM(3,0,arities) - -# define BOOST_PARAMETER_FLATTEN_ARITY_required(arities) \ - BOOST_PP_TUPLE_ELEM(3,1,arities) - -# define BOOST_PARAMETER_FLATTEN_SPEC0_DUMMY_ELEM(z, n, data) ~ -# define BOOST_PARAMETER_FLATTEN_SPEC0(r, n, elem, data) \ - (( \ - BOOST_PP_TUPLE_ELEM(3,2,data) \ - , BOOST_PP_TUPLE_REM(BOOST_PP_TUPLE_ELEM(3,0,data)) elem \ - BOOST_PP_ENUM_TRAILING( \ - BOOST_PP_SUB( \ - BOOST_PP_TUPLE_ELEM(3,1,data) \ - , BOOST_PP_TUPLE_ELEM(3,0,data) \ - ) \ - , BOOST_PARAMETER_FLATTEN_SPEC0_DUMMY_ELEM \ - , ~ \ - ) \ - )) - -# define BOOST_PARAMETER_FLATTEN_SPEC_AUX(r, arity, max_arity, spec, transform) \ - BOOST_PARAMETER_FOR_EACH_R( \ - r \ - , arity \ - , BOOST_PARAMETER_FLATTEN_ARGS(spec) \ - , (arity, max_arity, transform(BOOST_PARAMETER_FLATTEN_QUALIFIER(spec))) \ - , BOOST_PARAMETER_FLATTEN_SPEC0 \ - ) - -# define BOOST_PARAMETER_FLATTEN_IDENTITY(x) x - -# define BOOST_PARAMETER_FLATTEN_SPEC_optional(r, arities, spec) \ - BOOST_PARAMETER_FLATTEN_SPEC_AUX( \ - r \ - , BOOST_PP_CAT( \ - BOOST_PARAMETER_FLATTEN_ARITY_, BOOST_PARAMETER_FLATTEN_QUALIFIER(spec) \ - )(arities) \ - , BOOST_PP_TUPLE_ELEM(3,2,arities) \ - , spec \ - , BOOST_PARAMETER_FLATTEN_IDENTITY \ - ) - -# define BOOST_PARAMETER_FLATTEN_SPEC_required(r, arities, spec) \ - BOOST_PARAMETER_FLATTEN_SPEC_optional(r, arities, spec) - -# define BOOST_PARAMETER_FLATTEN_SPEC_AS_DEDUCED(x) BOOST_PP_CAT(deduced_,x) - -# define BOOST_PARAMETER_FLATTEN_SPEC_deduced_M(r, arities, n, spec) \ - BOOST_PARAMETER_FLATTEN_SPEC_AUX( \ - r \ - , BOOST_PP_CAT( \ - BOOST_PARAMETER_FLATTEN_ARITY_, BOOST_PARAMETER_FLATTEN_QUALIFIER(spec) \ - )(arities) \ - , BOOST_PP_TUPLE_ELEM(3,2,arities) \ - , spec \ - , BOOST_PARAMETER_FLATTEN_SPEC_AS_DEDUCED \ - ) - -# define BOOST_PARAMETER_FLATTEN_SPEC_deduced(r, arities, spec) \ - BOOST_PP_SEQ_FOR_EACH_I_R( \ - r \ - , BOOST_PARAMETER_FLATTEN_SPEC_deduced_M \ - , arities \ - , BOOST_PARAMETER_FLATTEN_ARGS(spec) \ - ) - -# define BOOST_PARAMETER_FLATTEN_SPEC(r, arities, spec) \ - BOOST_PP_CAT( \ - BOOST_PARAMETER_FLATTEN_SPEC_, BOOST_PARAMETER_FLATTEN_QUALIFIER(spec) \ - )(r, arities, spec) - -# define BOOST_PARAMETER_FLATTEN(optional_arity, required_arity, wanted_arity, specs) \ - BOOST_PP_SEQ_FOR_EACH( \ - BOOST_PARAMETER_FLATTEN_SPEC \ - , ( \ - optional_arity, required_arity \ - , wanted_arity \ - ) \ - , specs \ - ) - -#endif // BOOST_PARAMETER_FLATTEN_051217_HPP +#endif // include guard diff --git a/include/boost/parameter/aux_/preprocessor/impl/argument_specs.hpp b/include/boost/parameter/aux_/preprocessor/impl/argument_specs.hpp new file mode 100755 index 0000000..1efce38 --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/impl/argument_specs.hpp @@ -0,0 +1,24 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_ARGUMENT_SPECS_HPP +#define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_ARGUMENT_SPECS_HPP + +#include + +// Accessor macros for the argument specs tuple. +#define BOOST_PARAMETER_FN_ARG_QUALIFIER(x) BOOST_PP_TUPLE_ELEM(4, 0, x) +#define BOOST_PARAMETER_FN_ARG_KEYWORD(x) BOOST_PP_TUPLE_ELEM(4, 1, x) +#define BOOST_PARAMETER_FN_ARG_PRED(x) BOOST_PP_TUPLE_ELEM(4, 2, x) +#define BOOST_PARAMETER_FN_ARG_DEFAULT(x) BOOST_PP_TUPLE_ELEM(4, 3, x) + +#include + +#define BOOST_PARAMETER_FN_ARG_NAME(x) \ + BOOST_PARAMETER_UNQUALIFIED(BOOST_PARAMETER_FN_ARG_KEYWORD(x)) +/**/ + +#endif // include guard + diff --git a/include/boost/parameter/aux_/preprocessor/impl/arity_range.hpp b/include/boost/parameter/aux_/preprocessor/impl/arity_range.hpp new file mode 100755 index 0000000..848648e --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/impl/arity_range.hpp @@ -0,0 +1,42 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_ARITY_RANGE_HPP +#define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_ARITY_RANGE_HPP + +// Helper macros for BOOST_PARAMETER_ARITY_RANGE. +#define BOOST_PARAMETER_ARITY_RANGE_M_optional(state) state +#define BOOST_PARAMETER_ARITY_RANGE_M_deduced_optional(state) state + +#include + +#define BOOST_PARAMETER_ARITY_RANGE_M_required(state) BOOST_PP_INC(state) +#define BOOST_PARAMETER_ARITY_RANGE_M_deduced_required(state) \ + BOOST_PP_INC(state) +/**/ + +#include +#include + +#define BOOST_PARAMETER_ARITY_RANGE_M(s, state, x) \ + BOOST_PP_CAT( \ + BOOST_PARAMETER_ARITY_RANGE_M_ \ + , BOOST_PARAMETER_FN_ARG_QUALIFIER(x) \ + )(state) +/**/ + +#include +#include + +// Calculates [begin, end) arity range. +#define BOOST_PARAMETER_ARITY_RANGE(args) \ + ( \ + BOOST_PP_SEQ_FOLD_LEFT(BOOST_PARAMETER_ARITY_RANGE_M, 0, args) \ + , BOOST_PP_INC(BOOST_PP_SEQ_SIZE(args)) \ + ) +/**/ + +#endif // include guard + diff --git a/include/boost/parameter/aux_/preprocessor/impl/flatten.hpp b/include/boost/parameter/aux_/preprocessor/impl/flatten.hpp new file mode 100755 index 0000000..85c8df4 --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/impl/flatten.hpp @@ -0,0 +1,116 @@ +// Copyright Daniel Wallin 2005. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FLATTEN_HPP +#define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FLATTEN_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BOOST_PARAMETER_FLATTEN_SPLIT_required required, +#define BOOST_PARAMETER_FLATTEN_SPLIT_optional optional, +#define BOOST_PARAMETER_FLATTEN_SPLIT_deduced deduced, + +#define BOOST_PARAMETER_FLATTEN_SPLIT(sub) \ + BOOST_PP_CAT(BOOST_PARAMETER_FLATTEN_SPLIT_, sub) + +#define BOOST_PARAMETER_FLATTEN_QUALIFIER(sub) \ + BOOST_PP_SPLIT(0, BOOST_PARAMETER_FLATTEN_SPLIT(sub)) + +#define BOOST_PARAMETER_FLATTEN_ARGS(sub) \ + BOOST_PP_SPLIT(1, BOOST_PARAMETER_FLATTEN_SPLIT(sub)) + +#define BOOST_PARAMETER_FLATTEN_ARITY_optional(arities) \ + BOOST_PP_TUPLE_ELEM(3, 0, arities) + +#define BOOST_PARAMETER_FLATTEN_ARITY_required(arities) \ + BOOST_PP_TUPLE_ELEM(3, 1, arities) + +#define BOOST_PARAMETER_FLATTEN_SPEC0_DUMMY_ELEM(z, n, data) ~ +#define BOOST_PARAMETER_FLATTEN_SPEC0(r, n, elem, data) \ + (( \ + BOOST_PP_TUPLE_ELEM(3, 2, data) \ + , BOOST_PP_TUPLE_REM(BOOST_PP_TUPLE_ELEM(3, 0, data)) elem \ + BOOST_PP_ENUM_TRAILING( \ + BOOST_PP_SUB( \ + BOOST_PP_TUPLE_ELEM(3, 1, data) \ + , BOOST_PP_TUPLE_ELEM(3, 0, data) \ + ) \ + , BOOST_PARAMETER_FLATTEN_SPEC0_DUMMY_ELEM \ + , ~ \ + ) \ + )) + +#define BOOST_PARAMETER_FLATTEN_SPEC_AUX(r, arity, max_arity, spec, xform) \ + BOOST_PARAMETER_FOR_EACH_R( \ + r \ + , arity \ + , BOOST_PARAMETER_FLATTEN_ARGS(spec) \ + , (arity, max_arity, xform(BOOST_PARAMETER_FLATTEN_QUALIFIER(spec))) \ + , BOOST_PARAMETER_FLATTEN_SPEC0 \ + ) + +#define BOOST_PARAMETER_FLATTEN_IDENTITY(x) x + +#define BOOST_PARAMETER_FLATTEN_SPEC_optional(r, arities, spec) \ + BOOST_PARAMETER_FLATTEN_SPEC_AUX( \ + r \ + , BOOST_PP_CAT( \ + BOOST_PARAMETER_FLATTEN_ARITY_ \ + , BOOST_PARAMETER_FLATTEN_QUALIFIER(spec) \ + )(arities) \ + , BOOST_PP_TUPLE_ELEM(3, 2, arities) \ + , spec \ + , BOOST_PARAMETER_FLATTEN_IDENTITY \ + ) + +#define BOOST_PARAMETER_FLATTEN_SPEC_required(r, arities, spec) \ + BOOST_PARAMETER_FLATTEN_SPEC_optional(r, arities, spec) + +#define BOOST_PARAMETER_FLATTEN_SPEC_AS_DEDUCED(x) BOOST_PP_CAT(deduced_, x) + +#define BOOST_PARAMETER_FLATTEN_SPEC_deduced_M(r, arities, n, spec) \ + BOOST_PARAMETER_FLATTEN_SPEC_AUX( \ + r \ + , BOOST_PP_CAT( \ + BOOST_PARAMETER_FLATTEN_ARITY_ \ + , BOOST_PARAMETER_FLATTEN_QUALIFIER(spec) \ + )(arities) \ + , BOOST_PP_TUPLE_ELEM(3, 2, arities) \ + , spec \ + , BOOST_PARAMETER_FLATTEN_SPEC_AS_DEDUCED \ + ) + +#define BOOST_PARAMETER_FLATTEN_SPEC_deduced(r, arities, spec) \ + BOOST_PP_SEQ_FOR_EACH_I_R( \ + r \ + , BOOST_PARAMETER_FLATTEN_SPEC_deduced_M \ + , arities \ + , BOOST_PARAMETER_FLATTEN_ARGS(spec) \ + ) + +#define BOOST_PARAMETER_FLATTEN_SPEC(r, arities, spec) \ + BOOST_PP_CAT( \ + BOOST_PARAMETER_FLATTEN_SPEC_ \ + , BOOST_PARAMETER_FLATTEN_QUALIFIER(spec) \ + )(r, arities, spec) + +#define BOOST_PARAMETER_FLATTEN(opt_arity, req_arity, wanted_arity, specs) \ + BOOST_PP_SEQ_FOR_EACH( \ + BOOST_PARAMETER_FLATTEN_SPEC \ + , (opt_arity, req_arity, wanted_arity) \ + , specs \ + ) + +#endif // include guard + diff --git a/include/boost/parameter/aux_/preprocessor/impl/forwarding_overloads.hpp b/include/boost/parameter/aux_/preprocessor/impl/forwarding_overloads.hpp new file mode 100755 index 0000000..ee66111 --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/impl/forwarding_overloads.hpp @@ -0,0 +1,283 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FORWARDING_OVERLOADS_HPP +#define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FORWARDING_OVERLOADS_HPP + +#define BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_PRODUCT(r, product) \ + (product) +/**/ + +#include + +#define BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_TEMPLATE_HEADER_Z(z, n, p) \ + template +/**/ + +#include +#include + +#define BOOST_PARAMETER_FUNCTION_ARGUMENT(r, _, i, elem) \ + BOOST_PP_COMMA_IF(i) elem& BOOST_PP_CAT(a, i) +/**/ + +#include +#include +#include + +#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) +// No partial ordering. This feature doesn't work. +#define BOOST_PARAMETER_FUNCTION_FORWARD_COMBINATION(r, _, i, elem) \ + (BOOST_PP_IF( \ + BOOST_PARAMETER_IS_QUALIFIER( \ + BOOST_PARAMETER_FN_ARG_KEYWORD(elem) \ + ) \ + , (BOOST_PP_CAT(ParameterArgumentType, i)) \ + , (BOOST_PP_CAT(ParameterArgumentType, i) const) \ + )) +/**/ +#else +#define BOOST_PARAMETER_FUNCTION_FORWARD_COMBINATION(r, _, i, elem) \ + (BOOST_PP_IF( \ + BOOST_PARAMETER_IS_QUALIFIER( \ + BOOST_PARAMETER_FN_ARG_KEYWORD(elem) \ + ) \ + , (BOOST_PP_CAT(ParameterArgumentType, i) const) \ + (BOOST_PP_CAT(ParameterArgumentType, i)) \ + , (BOOST_PP_CAT(ParameterArgumentType, i) const) \ + )) +/**/ +#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING + +#include + +#define BOOST_PARAMETER_FUNCTION_FORWARD_COMBINATIONS(args) \ + BOOST_PP_SEQ_FOR_EACH_I( \ + BOOST_PARAMETER_FUNCTION_FORWARD_COMBINATION, ~, args \ + ) +/**/ + +#include +#include +#include +#include +#include +#include + +#define BOOST_PARAMETER_CONSTRUCTOR_OVERLOAD_IMPL(z, n, r, data, elem) \ + BOOST_PP_IF( \ + n \ + , BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_TEMPLATE_HEADER_Z \ + , BOOST_PP_TUPLE_EAT(3) \ + )(z, n, ParameterArgumentType) \ + BOOST_PP_EXPR_IF(BOOST_PP_EQUAL(n, 1), explicit) \ + BOOST_PP_TUPLE_ELEM(5, 2, data)( \ + BOOST_PP_IF( \ + n, BOOST_PP_SEQ_FOR_EACH_I_R, BOOST_PP_TUPLE_EAT(4) \ + )(r, BOOST_PARAMETER_FUNCTION_ARGUMENT, ~, elem) \ + BOOST_PP_IF( \ + n, BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z, BOOST_PP_TUPLE_EAT(4) \ + )( \ + z \ + , BOOST_PP_CAT(constructor_parameters, __LINE__) \ + , n \ + , ParameterArgumentType \ + ) \ + ) : BOOST_PARAMETER_PARENTHESIZED_TYPE( \ + BOOST_PP_TUPLE_ELEM(5, 3, data) \ + )( \ + BOOST_PP_CAT(constructor_parameters, __LINE__)()( \ + BOOST_PP_ENUM_PARAMS_Z(z, n, a) \ + ) \ + ) \ + { \ + } +/**/ + +#include +#include +#include +#include + +#define BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_IMPL(z, n, r, data, elem) \ + BOOST_PP_IF( \ + n \ + , BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_TEMPLATE_HEADER_Z \ + , BOOST_PP_TUPLE_EAT(3) \ + )(z, n, ParameterArgumentType) \ + BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(BOOST_PP_TUPLE_ELEM(6, 3, data)) \ + inline BOOST_PP_EXPR_IF(n, typename) \ + BOOST_PARAMETER_FUNCTION_RESULT_NAME(BOOST_PP_TUPLE_ELEM(6, 3, data))< \ + BOOST_PP_EXPR_IF(n, typename) \ + ::boost::parameter::aux::argument_pack< \ + BOOST_PARAMETER_FUNCTION_SPECIFICATION_NAME( \ + BOOST_PP_TUPLE_ELEM(6, 3, data) \ + ) \ + BOOST_PP_COMMA_IF(n) \ + BOOST_PP_IF( \ + n, BOOST_PP_SEQ_ENUM, BOOST_PP_TUPLE_EAT(1) \ + )(elem) \ + >::type \ + >::type \ + BOOST_PARAMETER_MEMBER_FUNCTION_NAME(BOOST_PP_TUPLE_ELEM(6, 2, data))( \ + BOOST_PP_IF( \ + n, BOOST_PP_SEQ_FOR_EACH_I_R, BOOST_PP_TUPLE_EAT(4) \ + )(r, BOOST_PARAMETER_FUNCTION_ARGUMENT, ~, elem) \ + BOOST_PP_IF( \ + n, BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z, BOOST_PP_TUPLE_EAT(4) \ + )( \ + z \ + , BOOST_PARAMETER_FUNCTION_SPECIFICATION_NAME( \ + BOOST_PP_TUPLE_ELEM(6, 3, data) \ + ) \ + , n \ + , ParameterArgumentType \ + ) \ + ) BOOST_PP_EXPR_IF(BOOST_PP_TUPLE_ELEM(6, 5, data), const) \ + { \ + return BOOST_PARAMETER_FUNCTION_IMPL_NAME( \ + BOOST_PP_TUPLE_ELEM(6, 3, data) \ + )( \ + BOOST_PARAMETER_FUNCTION_SPECIFICATION_NAME( \ + BOOST_PP_TUPLE_ELEM(6, 3, data) \ + )()(BOOST_PP_ENUM_PARAMS_Z(z, n, a)) \ + ); \ + } +/**/ + +#define BOOST_PARAMETER_CONSTRUCTOR_OVERLOAD_IMPL_R(r, data, elem) \ + BOOST_PARAMETER_CONSTRUCTOR_OVERLOAD_IMPL( \ + BOOST_PP_TUPLE_ELEM(5, 0, data) \ + , BOOST_PP_TUPLE_ELEM(5, 1, data) \ + , r \ + , data \ + , elem \ + ) +/**/ + +#define BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_IMPL_R(r, data, elem) \ + BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_IMPL( \ + BOOST_PP_TUPLE_ELEM(6, 0, data) \ + , BOOST_PP_TUPLE_ELEM(6, 1, data) \ + , r \ + , data \ + , elem \ + ) +/**/ + +#include +#include + +#define BOOST_PARAMETER_CONSTRUCTOR_OVERLOAD_IMPL_ARITY_0(z, n, data) \ + BOOST_PARAMETER_CONSTRUCTOR_OVERLOAD_IMPL( \ + z \ + , n \ + , BOOST_PP_DEDUCE_R() \ + , (z, n, BOOST_PP_TUPLE_REM(3) data) \ + , ~ \ + ) +/**/ + +#define BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_IMPL_ARITY_0(z, n, data) \ + BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_IMPL( \ + z \ + , n \ + , BOOST_PP_DEDUCE_R() \ + , (z, n, BOOST_PP_TUPLE_REM(4) data) \ + , ~ \ + ) +/**/ + +#include +#include +#include + +#define BOOST_PARAMETER_CONSTRUCTOR_OVERLOAD_IMPL_ARITY_N(z, n, data) \ + BOOST_PP_SEQ_FOR_EACH( \ + BOOST_PARAMETER_CONSTRUCTOR_OVERLOAD_IMPL_R \ + , (z, n, BOOST_PP_TUPLE_REM(3) data) \ + , BOOST_PP_SEQ_FOR_EACH_PRODUCT( \ + BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_PRODUCT \ + , BOOST_PP_SEQ_FIRST_N(n, BOOST_PP_TUPLE_ELEM(3, 2, data)) \ + ) \ + ) +/**/ + +#define BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_IMPL_ARITY_N(z, n, data) \ + BOOST_PP_SEQ_FOR_EACH( \ + BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_IMPL_R \ + , (z, n, BOOST_PP_TUPLE_REM(4) data) \ + , BOOST_PP_SEQ_FOR_EACH_PRODUCT( \ + BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_PRODUCT \ + , BOOST_PP_SEQ_FIRST_N(n, BOOST_PP_TUPLE_ELEM(4, 2, data)) \ + ) \ + ) +/**/ + +#define BOOST_PARAMETER_CONSTRUCTOR_OVERLOAD_Z(z, n, data) \ + BOOST_PP_IF( \ + n \ + , BOOST_PARAMETER_CONSTRUCTOR_OVERLOAD_IMPL_ARITY_N \ + , BOOST_PARAMETER_CONSTRUCTOR_OVERLOAD_IMPL_ARITY_0 \ + )(z, n, data) +/**/ + +#define BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_Z(z, n, data) \ + BOOST_PP_IF( \ + n \ + , BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_IMPL_ARITY_N \ + , BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_IMPL_ARITY_0 \ + )(z, n, data) +/**/ + +#include + +// Helper macro for BOOST_PARAMETER_CONSTRUCTOR_OVERLOADS. +#define BOOST_PARAMETER_CONSTRUCTOR_OVERLOADS_AUX(class_, base, r, combo) \ + BOOST_PP_REPEAT_FROM_TO( \ + BOOST_PP_TUPLE_ELEM(2, 0, r) \ + , BOOST_PP_TUPLE_ELEM(2, 1, r) \ + , BOOST_PARAMETER_CONSTRUCTOR_OVERLOAD_Z \ + , (class_, base, combo) \ + ) +/**/ + +// Helper macro for BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOADS. +#define BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOADS_AUX(n, i, r, combo, c) \ + BOOST_PP_REPEAT_FROM_TO( \ + BOOST_PP_TUPLE_ELEM(2, 0, r) \ + , BOOST_PP_TUPLE_ELEM(2, 1, r) \ + , BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOAD_Z \ + , (n, i, combo, c) \ + ) +/**/ + +#include + +// Expands to the layer of forwarding functions for the constructor in the +// specified class, whose arguments determine the range of arities. +#define BOOST_PARAMETER_CONSTRUCTOR_OVERLOADS(class_, base, args) \ + BOOST_PARAMETER_CONSTRUCTOR_OVERLOADS_AUX( \ + class_ \ + , base \ + , BOOST_PARAMETER_ARITY_RANGE(args) \ + , BOOST_PARAMETER_FUNCTION_FORWARD_COMBINATIONS(args) \ + ) +/**/ + +// Expands to the layer of forwarding functions for the function with the +// specified name, whose arguments determine the range of arities. +#define BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOADS(name, impl, args, const_) \ + BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOADS_AUX( \ + name \ + , impl \ + , BOOST_PARAMETER_ARITY_RANGE(args) \ + , BOOST_PARAMETER_FUNCTION_FORWARD_COMBINATIONS(args) \ + , const_ \ + ) +/**/ + +#endif // include guard + diff --git a/include/boost/parameter/aux_/preprocessor/impl/function_cast.hpp b/include/boost/parameter/aux_/preprocessor/impl/function_cast.hpp new file mode 100755 index 0000000..48b0d9a --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/impl/function_cast.hpp @@ -0,0 +1,154 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FUNCTION_CAST_HPP +#define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FUNCTION_CAST_HPP + +#include +#include + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + +#define BOOST_PARAMETER_FUNCTION_CAST(value, predicate) value + +#else // !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + +namespace boost { namespace parameter { namespace aux { + + // Handles possible implicit casts. Used by preprocessor.hpp + // to normalize user input. + // + // cast::execute() is identity + // cast::execute() is identity + // cast::execute() casts to X + // + // preprocessor.hpp uses this like this: + // + // #define X(value, predicate) + // cast::execute(value) + // + // X(something, *) + // X(something, *(predicate)) + // X(something, (int)) + template + struct cast; +}}} // namespace boost::parameter::aux + +#include + +namespace boost { namespace parameter { namespace aux { + + template + struct cast + { + static ::boost::parameter::aux::use_default_tag + execute(::boost::parameter::aux::use_default_tag) + { + return ::boost::parameter::aux::use_default_tag(); + } + + static ::boost::parameter::aux::use_default_tag + remove_const(::boost::parameter::aux::use_default_tag) + { + return ::boost::parameter::aux::use_default_tag(); + } + + template + static U& execute(U& value) + { + return value; + } + + template + static U& remove_const(U& x) + { + return x; + } + }; +}}} // namespace boost::parameter::aux + +#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) +#include +#endif + +namespace boost { namespace parameter { namespace aux { + + template +#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) + struct cast< ::boost::parameter::aux::voidstar(Predicate),Args> +#else + struct cast +#endif + : ::boost::parameter::aux::cast + { + }; +}}} // namespace boost::parameter::aux + +#include + +namespace boost { namespace parameter { namespace aux { + + // This is a hack used in cast<> to turn the user supplied type, + // which may or may not be a placeholder expression, into one, + // so that it will be properly evaluated by mpl::apply. + template + struct as_placeholder_expr + { + typedef T type; + }; +}}} // namespace boost::parameter::aux + +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + template + struct cast + { + typedef typename ::boost::mpl::apply2< + ::boost::parameter::aux::as_placeholder_expr + , Args + , Args + >::type type0; + + typedef typename ::boost::add_lvalue_reference< + typename ::boost::remove_const::type + >::type reference; + + static ::boost::parameter::aux::use_default_tag + execute(::boost::parameter::aux::use_default_tag) + { + return ::boost::parameter::aux::use_default_tag(); + } + + static ::boost::parameter::aux::use_default_tag + remove_const(::boost::parameter::aux::use_default_tag) + { + return ::boost::parameter::aux::use_default_tag(); + } + + static type0 execute(type0 value) + { + return value; + } + + template + static reference remove_const(U const& x) + { + return const_cast(x); + } + }; +}}} // namespace boost::parameter::aux + +#define BOOST_PARAMETER_FUNCTION_CAST(value, predicate, args) \ + ::boost::parameter::aux::cast::remove_const( \ + ::boost::parameter::aux::cast::execute(value) \ + ) + +#endif // Borland workarounds needed. +#endif // include guard + diff --git a/include/boost/parameter/aux_/preprocessor/impl/function_dispatch_layer.hpp b/include/boost/parameter/aux_/preprocessor/impl/function_dispatch_layer.hpp new file mode 100755 index 0000000..a2f3c9d --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/impl/function_dispatch_layer.hpp @@ -0,0 +1,350 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FUNCTION_DISPATCH_LAYER_HPP +#define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FUNCTION_DISPATCH_LAYER_HPP + +#include + +// Expands to keyword_tag_type for some keyword_tag. +#define BOOST_PARAMETER_FUNCTION_DISPATCH_ARG_TYPE(keyword) \ + BOOST_PP_CAT(keyword, _type) +/**/ + +#include + +// Helpers used as parameters to BOOST_PARAMETER_FUNCTION_DISPATCH_ARGUMENTS. +#define BOOST_PARAMETER_FUNCTION_DISPATCH_TEMPLATE_ARG(r, _, arg) \ + , typename BOOST_PARAMETER_FUNCTION_DISPATCH_ARG_TYPE( \ + BOOST_PARAMETER_FN_ARG_NAME(arg) \ + ) +/**/ + +#define BOOST_PARAMETER_FUNCTION_DISPATCH_ARG_DEFN(r, _, arg) \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_ARG_TYPE( \ + BOOST_PARAMETER_FN_ARG_NAME(arg) \ + )& BOOST_PARAMETER_FN_ARG_NAME(arg) +/**/ + +#define BOOST_PARAMETER_FUNCTION_DISPATCH_PARAMETER(r, _, arg) \ + , BOOST_PARAMETER_FN_ARG_NAME(arg) +/**/ + +#include +#include +#include +#include + +// Helper macro used below to produce lists based on the keyword argument +// names. macro is applied to every element. n is the number of +// optional arguments that should be included. +#define BOOST_PARAMETER_FUNCTION_DISPATCH_ARGUMENTS(macro, n, split_args) \ + BOOST_PP_SEQ_FOR_EACH( \ + macro \ + , ~ \ + , BOOST_PARAMETER_SPLIT_ARG_REQ_SEQ(split_args) \ + ) \ + BOOST_PP_SEQ_FOR_EACH( \ + macro \ + , ~ \ + , BOOST_PP_SEQ_FIRST_N( \ + BOOST_PP_SUB( \ + BOOST_PARAMETER_SPLIT_ARG_OPT_COUNT(split_args) \ + , n \ + ) \ + , BOOST_PARAMETER_SPLIT_ARG_OPT_SEQ(split_args) \ + ) \ + ) +/**/ + +namespace boost { namespace parameter { namespace aux { + + template + T& as_lvalue(T& value, long) + { + return value; + } + + template + T const& as_lvalue(T const& value, int) + { + return value; + } +}}} // namespace boost::parameter::aux + +#define BOOST_PARAMETER_FUNCTION_DISPATCH_EVAL_ACTUAL_DEFAULT(arg) \ + BOOST_PARAMETER_FUNCTION_CAST( \ + ::boost::parameter::aux::as_lvalue( \ + BOOST_PARAMETER_FN_ARG_DEFAULT(arg) \ + , 0L \ + ) \ + , BOOST_PARAMETER_FN_ARG_PRED(arg) \ + , Args \ + ) +/**/ + +#include +#include + +// Generates a keyword | default expression. +#define BOOST_PARAMETER_FUNCTION_DISPATCH_KW_OR_DEFAULT(arg, tag_namespace) \ + ::boost::parameter::keyword< \ + tag_namespace::BOOST_PARAMETER_FN_ARG_NAME(arg) \ + >::instance | ::boost::parameter::aux::use_default_tag() +/**/ + +#include + +#define BOOST_PARAMETER_FUNCTION_DISPATCH_ARG_OR_DEFAULT(arg, tag_ns) \ + BOOST_PARAMETER_FUNCTION_CAST( \ + args[BOOST_PARAMETER_FUNCTION_DISPATCH_KW_OR_DEFAULT(arg, tag_ns)] \ + , BOOST_PARAMETER_FN_ARG_PRED(arg) \ + , Args \ + ) +/**/ + +#define BOOST_PARAMETER_FUNCTION_DISPATCH_ARG_CAST_R(r, tag_namespace, arg) \ + , BOOST_PARAMETER_FUNCTION_CAST( \ + args[ \ + ::boost::parameter::keyword< \ + tag_namespace::BOOST_PARAMETER_FN_ARG_NAME(arg) \ + >::instance \ + ] \ + , BOOST_PARAMETER_FN_ARG_PRED(arg) \ + , Args \ + ) +/**/ + +#include +#include +#include + +#define BOOST_PARAMETER_FUNCTION_DISPATCH_OVERLOAD_BODY(x, n) \ + { \ + return BOOST_PARAMETER_FUNCTION_DISPATCH_NAME(x, 0)( \ + static_cast(BOOST_TTI_DETAIL_NULLPTR) \ + , args \ + , 0L \ + BOOST_PARAMETER_FUNCTION_DISPATCH_ARGUMENTS( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_PARAMETER \ + , n \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS(x) \ + ) \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_ARG_OR_DEFAULT( \ + BOOST_PP_SEQ_ELEM( \ + BOOST_PP_SUB( \ + BOOST_PARAMETER_SPLIT_ARG_OPT_COUNT( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS(x) \ + ) \ + , n \ + ) \ + , BOOST_PARAMETER_SPLIT_ARG_OPT_SEQ( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS(x) \ + ) \ + ) \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_TAG_NAMESPACE(x) \ + ) \ + ); \ + } +/**/ + +#include +#include +#include + +#define BOOST_PARAMETER_FUNCTION_DISPATCH_OVERLOAD_DEFAULT_BODY(x, n) \ + template < \ + typename ResultType \ + , typename Args \ + BOOST_PARAMETER_FUNCTION_DISPATCH_ARGUMENTS( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_TEMPLATE_ARG \ + , BOOST_PP_INC(n) \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS(x) \ + ) \ + > \ + BOOST_PARAMETER_MEMBER_FUNCTION_STATIC( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_BASE_NAME(x) \ + ) \ + ResultType BOOST_PARAMETER_FUNCTION_DISPATCH_NAME(x, 0)( \ + ResultType(*)() \ + , Args const& args \ + , long \ + BOOST_PARAMETER_FUNCTION_DISPATCH_ARGUMENTS( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_ARG_DEFN \ + , BOOST_PP_INC(n) \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS(x) \ + ) \ + , ::boost::parameter::aux::use_default_tag \ + ) BOOST_PP_EXPR_IF(BOOST_PARAMETER_FUNCTION_DISPATCH_IS_CONST(x), const) \ + { \ + return BOOST_PARAMETER_FUNCTION_DISPATCH_NAME(x, 0)( \ + static_cast(BOOST_TTI_DETAIL_NULLPTR) \ + , args \ + , 0L \ + BOOST_PARAMETER_FUNCTION_DISPATCH_ARGUMENTS( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_PARAMETER \ + , BOOST_PP_INC(n) \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS(x) \ + ) \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_EVAL_ACTUAL_DEFAULT( \ + BOOST_PP_SEQ_ELEM( \ + BOOST_PP_SUB( \ + BOOST_PARAMETER_SPLIT_ARG_OPT_COUNT( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS(x) \ + ) \ + , BOOST_PP_INC(n) \ + ) \ + , BOOST_PARAMETER_SPLIT_ARG_OPT_SEQ( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS(x) \ + ) \ + ) \ + ) \ + ); \ + } +/**/ + +#include + +// Defines the actual function body for +// BOOST_PARAMETER_FUNCTION_DISPATCH_OVERLOAD_Z. +#define BOOST_PARAMETER_FUNCTION_DISPATCH_OVERLOAD_BODY_Z(z, n, x) \ + template < \ + typename ResultType \ + , typename Args \ + BOOST_PARAMETER_FUNCTION_DISPATCH_ARGUMENTS( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_TEMPLATE_ARG \ + , n \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS(x) \ + ) \ + > \ + BOOST_PARAMETER_MEMBER_FUNCTION_STATIC( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_BASE_NAME(x) \ + ) \ + ResultType BOOST_PARAMETER_FUNCTION_DISPATCH_NAME(x, 0)( \ + ResultType(*)() \ + , Args const& args \ + , int \ + BOOST_PARAMETER_FUNCTION_DISPATCH_ARGUMENTS( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_ARG_DEFN \ + , n \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS(x) \ + ) \ + ) BOOST_PP_EXPR_IF(BOOST_PARAMETER_FUNCTION_DISPATCH_IS_CONST(x), const) \ + BOOST_PP_IF( \ + n \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_OVERLOAD_BODY \ + , ; BOOST_PP_TUPLE_EAT(2) \ + )(x, n) +/**/ + +#include +#include +#include +#include + +#define BOOST_PARAMETER_FUNCTION_DISPATCH_OVERLOAD_Z(z, n, data) \ + BOOST_PP_IF( \ + BOOST_PP_OR(n, BOOST_PP_TUPLE_ELEM(2, 0, data)) \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_OVERLOAD_BODY_Z \ + , BOOST_PP_TUPLE_EAT(3) \ + )(z, n, BOOST_PP_TUPLE_ELEM(2, 1, data)) \ + BOOST_PP_IF( \ + BOOST_PP_EQUAL( \ + n \ + , BOOST_PARAMETER_SPLIT_ARG_OPT_COUNT( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS( \ + BOOST_PP_TUPLE_ELEM(2, 1, data) \ + ) \ + ) \ + ) \ + , BOOST_PP_TUPLE_EAT(2) \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_OVERLOAD_DEFAULT_BODY \ + )(BOOST_PP_TUPLE_ELEM(2, 1, data), n) +/**/ + +// Generates the function template that receives an ArgumentPack, and then +// goes on to call the layers of overloads generated by +// BOOST_PARAMETER_FUNCTION_DISPATCH_LAYER. +#define BOOST_PARAMETER_FUNCTION_INITIAL_DISPATCH_FUNCTION(x) \ + template \ + typename BOOST_PARAMETER_FUNCTION_RESULT_NAME( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_BASE_NAME(x) \ + )::type BOOST_PARAMETER_MEMBER_FUNCTION_STATIC( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_BASE_NAME(x) \ + ) BOOST_PARAMETER_FUNCTION_IMPL_NAME( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_BASE_NAME(x) \ + )(Args const& args) \ + BOOST_PP_EXPR_IF(BOOST_PARAMETER_FUNCTION_DISPATCH_IS_CONST(x), const) \ + { \ + return BOOST_PARAMETER_FUNCTION_DISPATCH_NAME(x, 0)( \ + static_cast< \ + typename BOOST_PARAMETER_FUNCTION_RESULT_NAME( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_BASE_NAME(x) \ + )::type(*)() \ + >(BOOST_TTI_DETAIL_NULLPTR) \ + , args \ + , 0L \ + BOOST_PP_SEQ_FOR_EACH( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_ARG_CAST_R \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_TAG_NAMESPACE(x) \ + , BOOST_PARAMETER_SPLIT_ARG_REQ_SEQ( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS(x) \ + ) \ + ) \ + ); \ + } +/**/ + +// x is a tuple: +// +// (base_name, split_args, is_const, tag_namespace) +// +// Generates all dispatch functions for the function named base_name. Each +// dispatch function that takes in n optional parameters passes the default +// value of the (n + 1)th optional parameter to the next dispatch function. +// The last dispatch function is the back-end implementation, so only the +// header is generated: the user is expected to supply the body. +// +// Also generates the front-end implementation function, which uses +// BOOST_PARAMETER_FUNCTION_CAST to extract each argument from the argument +// pack. +#define BOOST_PARAMETER_FUNCTION_DISPATCH_LAYER(fwd_decl, x) \ + BOOST_PP_REPEAT_FROM_TO( \ + 0 \ + , BOOST_PP_INC( \ + BOOST_PARAMETER_SPLIT_ARG_OPT_COUNT( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS(x) \ + ) \ + ) \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_OVERLOAD_Z \ + , (fwd_decl, x) \ + ) \ + BOOST_PARAMETER_FUNCTION_INITIAL_DISPATCH_FUNCTION(x) \ + template < \ + typename ResultType \ + , typename Args \ + BOOST_PARAMETER_FUNCTION_DISPATCH_ARGUMENTS( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_TEMPLATE_ARG \ + , 0 \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS(x) \ + ) \ + > \ + BOOST_PARAMETER_MEMBER_FUNCTION_STATIC( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_BASE_NAME(x) \ + ) \ + ResultType BOOST_PARAMETER_FUNCTION_DISPATCH_NAME(x, 0)( \ + ResultType(*)() \ + , Args const& \ + , int \ + BOOST_PARAMETER_FUNCTION_DISPATCH_ARGUMENTS( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_ARG_DEFN \ + , 0 \ + , BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS(x) \ + ) \ + ) BOOST_PP_EXPR_IF(BOOST_PARAMETER_FUNCTION_DISPATCH_IS_CONST(x), const) +/**/ + +#endif // include guard + diff --git a/include/boost/parameter/aux_/preprocessor/impl/function_dispatch_tuple.hpp b/include/boost/parameter/aux_/preprocessor/impl/function_dispatch_tuple.hpp new file mode 100755 index 0000000..63e6acd --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/impl/function_dispatch_tuple.hpp @@ -0,0 +1,29 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FUNCTION_DISPATCH_TUPLE_HPP +#define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FUNCTION_DISPATCH_TUPLE_HPP + +#include + +// Accessor macros for the input tuple to the dispatch macros. +#define BOOST_PARAMETER_FUNCTION_DISPATCH_BASE_NAME(x) \ + BOOST_PP_TUPLE_ELEM(4, 0, x) +/**/ + +#define BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS(x) \ + BOOST_PP_TUPLE_ELEM(4, 1, x) +/**/ + +#define BOOST_PARAMETER_FUNCTION_DISPATCH_IS_CONST(x) \ + BOOST_PP_TUPLE_ELEM(4, 2, x) +/**/ + +#define BOOST_PARAMETER_FUNCTION_DISPATCH_TAG_NAMESPACE(x) \ + BOOST_PP_TUPLE_ELEM(4, 3, x) +/**/ + +#endif // include guard + diff --git a/include/boost/parameter/aux_/preprocessor/impl/function_forward_match.hpp b/include/boost/parameter/aux_/preprocessor/impl/function_forward_match.hpp new file mode 100755 index 0000000..c902d82 --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/impl/function_forward_match.hpp @@ -0,0 +1,33 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FUNCTION_FORWARD_MATCH_HPP +#define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FUNCTION_FORWARD_MATCH_HPP + +#include +#include + +#if !defined(BOOST_NO_SFINAE) && \ + !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) + +#include +#include + +// Expands to an extra argument that is well-formed +// iff all Args... satisfy the requirements set by params. +#define BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z(z, parameters, n, prefix) \ + , typename ::boost::parameter::aux::match< \ + parameters, BOOST_PP_ENUM_PARAMS(n, prefix) \ + >::type = parameters() +/**/ + +#else + +#define BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z(z, parameters, n, prefix) +/**/ + +#endif +#endif // include guard + diff --git a/include/boost/parameter/aux_/preprocessor/impl/function_name.hpp b/include/boost/parameter/aux_/preprocessor/impl/function_name.hpp new file mode 100755 index 0000000..aed9f15 --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/impl/function_name.hpp @@ -0,0 +1,115 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FUNCTION_NAME_HPP +#define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FUNCTION_NAME_HPP + +#define BOOST_PARAMETER_MEMBER_FUNCTION_CHECK_STATIC_static () +/**/ + +#include +#include + +#define BOOST_PARAMETER_MEMBER_FUNCTION_IS_STATIC(name) \ + BOOST_PARAMETER_IS_NULLARY( \ + BOOST_PP_CAT(BOOST_PARAMETER_MEMBER_FUNCTION_CHECK_STATIC_, name) \ + ) +/**/ + +#include +#include + +#if defined(BOOST_MSVC) + +// Workaround for MSVC preprocessor. +// +// When stripping static from "static f", msvc will produce " f". The leading +// whitespace doesn't go away when pasting the token with something else, so +// this thing is a hack to strip the whitespace. +#define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_static ( +/**/ + +#define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_AUX(name) \ + BOOST_PP_CAT(BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_, name)) +/**/ + +#define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC(name) \ + BOOST_PP_SEQ_HEAD( \ + BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_AUX(name) \ + ) +/**/ + +#else + +#define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_static +/**/ + +#define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC(name) \ + BOOST_PP_CAT(BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_, name) +/**/ + +#endif // MSVC workarounds needed + +#include + +#define BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(name) \ + BOOST_PP_EXPR_IF( \ + BOOST_PARAMETER_MEMBER_FUNCTION_IS_STATIC(name), static \ + ) +/**/ + +#include +#include + +#define BOOST_PARAMETER_MEMBER_FUNCTION_NAME(name) \ + BOOST_PP_IF( \ + BOOST_PARAMETER_MEMBER_FUNCTION_IS_STATIC(name) \ + , BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC \ + , name BOOST_PP_TUPLE_EAT(1) \ + )(name) +/**/ + +// Produces a name for a parameter specification for the function named base. +#define BOOST_PARAMETER_FUNCTION_SPECIFICATION_NAME(base) \ + BOOST_PP_CAT( \ + BOOST_PP_CAT(boost_param_parameters_, __LINE__) \ + , BOOST_PARAMETER_MEMBER_FUNCTION_NAME(name) \ + ) +/**/ + +// Produces a name for a result type metafunction for the function named base. +#define BOOST_PARAMETER_FUNCTION_RESULT_NAME(base) \ + BOOST_PP_CAT( \ + BOOST_PP_CAT(boost_param_result_, __LINE__) \ + , BOOST_PARAMETER_MEMBER_FUNCTION_NAME(name) \ + ) +/**/ + +// Can't do boost_param_impl_ ## basee +// because base might start with an underscore. +// daniel: what? how is that relevant? the reason for using CAT() +// is to make sure base is expanded. i'm not sure we need to here, +// but it's more stable to do it. +#define BOOST_PARAMETER_FUNCTION_IMPL_NAME(base) \ + BOOST_PP_CAT(boost_param_impl, BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base)) +/**/ + +#include + +// Produces a name for the dispatch functions. +#define BOOST_PARAMETER_FUNCTION_DISPATCH_NAME(x, n) \ + BOOST_PP_CAT( \ + BOOST_PP_CAT( \ + BOOST_PP_CAT(boost_param_dispatch_, n) \ + , BOOST_PP_CAT(boost_, __LINE__) \ + ) \ + , BOOST_PARAMETER_MEMBER_FUNCTION_NAME( \ + BOOST_PARAMETER_FUNCTION_DISPATCH_BASE_NAME(x) \ + ) \ + ) +/**/ + +#endif // include guard + diff --git a/include/boost/parameter/aux_/preprocessor/impl/parenthesized_type.hpp b/include/boost/parameter/aux_/preprocessor/impl/parenthesized_type.hpp new file mode 100755 index 0000000..5eb1718 --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/impl/parenthesized_type.hpp @@ -0,0 +1,34 @@ +// Copyright David Abrahams 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_PARENTHESIZED_TYPE_HPP +#define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_PARENTHESIZED_TYPE_HPP + +namespace boost { namespace parameter { namespace aux { + + // A metafunction that transforms void(*)(T) -> T + template + struct unaryfunptr_arg_type; + + template + struct unaryfunptr_arg_type + { + typedef Arg type; + }; + + template <> + struct unaryfunptr_arg_type + { + typedef void type; + }; +}}} // namespace boost::parameter::aux + +// A macro that takes a parenthesized C++ type name (T) and transforms it +// into an un-parenthesized type expression equivalent to T. +#define BOOST_PARAMETER_PARENTHESIZED_TYPE(x) \ + ::boost::parameter::aux::unaryfunptr_arg_type< void(*)x >::type + +#endif // include guard + diff --git a/include/boost/parameter/aux_/preprocessor/impl/specification.hpp b/include/boost/parameter/aux_/preprocessor/impl/specification.hpp new file mode 100755 index 0000000..a9eb415 --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/impl/specification.hpp @@ -0,0 +1,95 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_SPECIFICATION_HPP +#define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_SPECIFICATION_HPP + +#include + +// Helper macros for BOOST_PARAMETER_SPECIFICATION_ELEM_R. +#define BOOST_PARAMETER_QUALIFIED_TAG_optional(tag) \ + optional + +#define BOOST_PARAMETER_QUALIFIED_TAG_required(tag) \ + required + +#define BOOST_PARAMETER_QUALIFIED_TAG_deduced_optional(tag) \ + optional< ::boost::parameter::deduced +/**/ + +#define BOOST_PARAMETER_QUALIFIED_TAG_deduced_required(tag) \ + required< ::boost::parameter::deduced +/**/ + +#include +#include +#include +#include +#include + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + +#include + +#define BOOST_PARAMETER_SPECIFICATION_ELEM_R(r, tag_namespace, i, elem) \ + BOOST_PP_COMMA_IF(i) ::boost::parameter::BOOST_PP_CAT( \ + BOOST_PARAMETER_QUALIFIED_TAG_ \ + , BOOST_PARAMETER_FN_ARG_QUALIFIER(elem) \ + )(tag_namespace::BOOST_PARAMETER_FN_ARG_NAME(elem)) \ + , ::boost::parameter::aux::use_default \ + > +/**/ + +#else // !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + +#include + +// Expands to each boost::parameter::parameters<> element type. +#define BOOST_PARAMETER_SPECIFICATION_ELEM_R(r, tag_namespace, i, elem) \ + BOOST_PP_COMMA_IF(i) ::boost::parameter::BOOST_PP_CAT( \ + BOOST_PARAMETER_QUALIFIED_TAG_ \ + , BOOST_PARAMETER_FN_ARG_QUALIFIER(elem) \ + )(tag_namespace::BOOST_PARAMETER_FN_ARG_NAME(elem)) \ + , typename ::boost::parameter::aux::unwrap_predicate< \ + void BOOST_PARAMETER_FN_ARG_PRED(elem) \ + >::type \ + > +/**/ + +#endif // Borland workarounds needed. + +#include +#include +#include + +// Expands to a boost::parameter::parameters<> specialization for the +// function named base. Used by BOOST_PARAMETER_CONSTRUCTOR_AUX and +// BOOST_PARAMETER_FUNCTION_HEAD for their respective ParameterSpec models. +#define BOOST_PARAMETER_SPECIFICATION(tag_ns, base, split_args) \ + template \ + struct BOOST_PP_CAT( \ + BOOST_PP_CAT(boost_param_params_, __LINE__) \ + , BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base) \ + ) : ::boost::parameter::parameters< \ + BOOST_PP_SEQ_FOR_EACH_I( \ + BOOST_PARAMETER_SPECIFICATION_ELEM_R, tag_ns, split_args \ + ) \ + > \ + { \ + }; \ + typedef BOOST_PP_CAT( \ + BOOST_PP_CAT(boost_param_params_, __LINE__) \ + , BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base) \ + ) +/**/ + +#endif // include guard + diff --git a/include/boost/parameter/aux_/preprocessor/impl/split_args.hpp b/include/boost/parameter/aux_/preprocessor/impl/split_args.hpp new file mode 100755 index 0000000..bfda33b --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/impl/split_args.hpp @@ -0,0 +1,71 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_SPLIT_ARGS_HPP +#define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_SPLIT_ARGS_HPP + +#include + +// Accessor macros for the split_args tuple. +#define BOOST_PARAMETER_SPLIT_ARG_REQ_COUNT(x) BOOST_PP_TUPLE_ELEM(4, 0, x) +#define BOOST_PARAMETER_SPLIT_ARG_REQ_SEQ(x) BOOST_PP_TUPLE_ELEM(4, 1, x) +#define BOOST_PARAMETER_SPLIT_ARG_OPT_COUNT(x) BOOST_PP_TUPLE_ELEM(4, 2, x) +#define BOOST_PARAMETER_SPLIT_ARG_OPT_SEQ(x) BOOST_PP_TUPLE_ELEM(4, 3, x) + +#include +#include + +// Helper macros for BOOST_PARAMETER_FUNCTION_SPLIT_ARGS. +#define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_required(s_a, arg) \ + ( \ + BOOST_PP_INC(BOOST_PARAMETER_SPLIT_ARG_REQ_COUNT(s_a)) \ + , BOOST_PP_SEQ_PUSH_BACK(BOOST_PARAMETER_SPLIT_ARG_REQ_SEQ(s_a), arg) \ + , BOOST_PARAMETER_SPLIT_ARG_OPT_COUNT(s_a) \ + , BOOST_PARAMETER_SPLIT_ARG_OPT_SEQ(s_a) \ + ) +/**/ + +#define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_deduced_required(split_args, arg) \ + BOOST_PARAMETER_FUNCTION_SPLIT_ARG_required(split_args, arg) +/**/ + +#define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_optional(s_a, arg) \ + ( \ + BOOST_PARAMETER_SPLIT_ARG_REQ_COUNT(s_a) \ + , BOOST_PARAMETER_SPLIT_ARG_REQ_SEQ(s_a) \ + , BOOST_PP_INC(BOOST_PARAMETER_SPLIT_ARG_OPT_COUNT(s_a)) \ + , BOOST_PP_SEQ_PUSH_BACK(BOOST_PARAMETER_SPLIT_ARG_OPT_SEQ(s_a), arg) \ + ) +/**/ + +#define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_deduced_optional(split_args, arg) \ + BOOST_PARAMETER_FUNCTION_SPLIT_ARG_optional(split_args, arg) +/**/ + +#include +#include + +#define BOOST_PARAMETER_FUNCTION_SPLIT_ARG(s, split_args, arg) \ + BOOST_PP_CAT( \ + BOOST_PARAMETER_FUNCTION_SPLIT_ARG_ \ + , BOOST_PARAMETER_FN_ARG_QUALIFIER(arg) \ + )(split_args, arg) +/**/ + +#include +#include + +// Expands from the flattened BOOST_PARAMETER_FUNCTION et. al. arg sequence to +// the tuple (required_count, required_args, optional_count, optional_args). +#define BOOST_PARAMETER_FUNCTION_SPLIT_ARGS(args) \ + BOOST_PP_SEQ_FOLD_LEFT( \ + BOOST_PARAMETER_FUNCTION_SPLIT_ARG \ + , (0, BOOST_PP_SEQ_NIL, 0, BOOST_PP_SEQ_NIL) \ + , args \ + ) +/**/ + +#endif // include guard + diff --git a/include/boost/parameter/aux_/preprocessor/is_binary.hpp b/include/boost/parameter/aux_/preprocessor/is_binary.hpp new file mode 100755 index 0000000..343b362 --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/is_binary.hpp @@ -0,0 +1,30 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IS_BINARY_HPP +#define BOOST_PARAMETER_AUX_PREPROCESSOR_IS_BINARY_HPP + +#include + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +// From Paul Mensonides +#include +#include +#define BOOST_PARAMETER_IS_BINARY(x) \ + BOOST_PP_SPLIT(1, BOOST_PARAMETER_IS_BINARY_C x BOOST_PP_COMMA() 0) +/**/ +#include +#include +#define BOOST_PARAMETER_IS_BINARY_C(x,y) \ + ~, 1 BOOST_PP_RPAREN() \ + BOOST_PP_TUPLE_EAT(2) BOOST_PP_LPAREN() ~ +/**/ +#else +#include +#define BOOST_PARAMETER_IS_BINARY(x) BOOST_PP_IS_BINARY(x) +#endif + +#endif // include guard + diff --git a/include/boost/parameter/aux_/preprocessor/is_nullary.hpp b/include/boost/parameter/aux_/preprocessor/is_nullary.hpp new file mode 100755 index 0000000..4ff3cb9 --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/is_nullary.hpp @@ -0,0 +1,31 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IS_NULLARY_HPP +#define BOOST_PARAMETER_AUX_PREPROCESSOR_IS_NULLARY_HPP + +#include + +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +// From Paul Mensonides +#include +#include +#define BOOST_PARAMETER_IS_NULLARY(x) \ + BOOST_PP_SPLIT(1, BOOST_PARAMETER_IS_NULLARY_C x BOOST_PP_COMMA() 0) +/**/ +#include +#include +#define BOOST_PARAMETER_IS_NULLARY_C() \ + ~, 1 BOOST_PP_RPAREN() \ + BOOST_PP_TUPLE_EAT(2) BOOST_PP_LPAREN() ~ +/**/ +#else +#include +#define BOOST_PARAMETER_IS_NULLARY(x) BOOST_PP_IS_NULLARY(x) +/**/ +#endif + +#endif // include guard + diff --git a/include/boost/parameter/aux_/preprocessor/no_perfect_forwarding_begin.hpp b/include/boost/parameter/aux_/preprocessor/no_perfect_forwarding_begin.hpp new file mode 100755 index 0000000..4dbf0a8 --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/no_perfect_forwarding_begin.hpp @@ -0,0 +1,80 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// No include guard. This file is intended for multiple inclusion. + +#define BOOST_PARAMETER_right_angle(z, n, _) > +/**/ + +#define BOOST_PARAMETER_satisfies_end(z, n, false_t) ,false_t> +/**/ + +#include +#include + +// Generates: +// +// make< +// parameter_spec##0, argument_type##0 +// , make< +// parameter_spec##1, argument_type##1 +// , ... boost::mpl::identity +// ...> +// > +#define BOOST_PARAMETER_make_arg_list(z, n, names) \ + BOOST_PP_SEQ_ELEM(0, names)< \ + BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(1, names), n), \ + BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(2, names), n), +/**/ + +#include +#include +#include + +#define BOOST_PARAMETER_build_arg_list(n, make, param_spec, arg_type) \ + BOOST_PP_REPEAT( \ + n, BOOST_PARAMETER_make_arg_list, (make)(param_spec)(arg_type) \ + ) \ + ::boost::mpl::identity< ::boost::parameter::void_> \ + BOOST_PP_REPEAT(n, BOOST_PARAMETER_right_angle, _) +/**/ + +#define BOOST_PARAMETER_make_deduced_list(z, n, names) \ + BOOST_PP_SEQ_ELEM(0, names) \ + BOOST_PP_REPEAT(n, BOOST_PARAMETER_right_angle, _) +/**/ + +#define BOOST_PARAMETER_forward_typedef(z, n, names) \ + typedef BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(0, names), n) \ + BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(1, names), n); +/**/ + +#define BOOST_PARAMETER_forward_typedefs(n, src, dest) \ + BOOST_PP_REPEAT(n, BOOST_PARAMETER_forward_typedef, (src)(dest)) +/**/ + +#define BOOST_PARAMETER_template_args(z, n, prefix) \ + typename BOOST_PP_CAT(prefix, n) = ::boost::parameter::void_ +/**/ + +#include +#include +#include + +#define BOOST_PARAMETER_satisfies_begin(z, n, prefix) \ + ::boost::mpl::eval_if< \ + ::boost::parameter::aux::satisfies_requirements_of< \ + typename ::boost::mpl::first::type \ + , BOOST_PP_CAT(prefix, n) \ + >, +/**/ + diff --git a/include/boost/parameter/aux_/preprocessor/no_perfect_forwarding_end.hpp b/include/boost/parameter/aux_/preprocessor/no_perfect_forwarding_end.hpp new file mode 100755 index 0000000..be486ff --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/no_perfect_forwarding_end.hpp @@ -0,0 +1,18 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// No include guard. This file is intended for multiple inclusion. + +#undef BOOST_PARAMETER_satisfies_begin +#undef BOOST_PARAMETER_template_args +#undef BOOST_PARAMETER_forward_typedefs +#undef BOOST_PARAMETER_forward_typedef +#undef BOOST_PARAMETER_build_deduced_list +#undef BOOST_PARAMETER_make_deduced_list +#undef BOOST_PARAMETER_build_arg_list +#undef BOOST_PARAMETER_make_arg_list +#undef BOOST_PARAMETER_satisfies_end +#undef BOOST_PARAMETER_right_angle + diff --git a/include/boost/parameter/aux_/overloads.hpp b/include/boost/parameter/aux_/preprocessor/overloads.hpp old mode 100644 new mode 100755 similarity index 53% rename from include/boost/parameter/aux_/overloads.hpp rename to include/boost/parameter/aux_/preprocessor/overloads.hpp index dcc92d4..c4b29d4 --- a/include/boost/parameter/aux_/overloads.hpp +++ b/include/boost/parameter/aux_/preprocessor/overloads.hpp @@ -1,29 +1,33 @@ -// Copyright David Abrahams, Daniel Wallin 2003. Use, modification and -// distribution is subject to the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // This file generates overloads in this format: // -// template -// typename mpl::apply_wrap1< -// aux::make_arg_list< +// template +// typename boost::mpl::apply_wrap1< +// boost::parameter::aux::make_arg_list< // PS0,A0 -// , aux::make_arg_list< +// , boost::parameter::aux::make_arg_list< // PS1,A1 -// , mpl::identity +// , boost::mpl::identity< +// boost::parameter::aux::empty_arg_list +// > // > // > // , unnamed_list // >::type // operator()(A0 const& a0, A1 const& a1) const // { -// typedef typename mpl::apply_wrap1< -// aux::make_arg_list< +// typedef typename boost::mpl::apply_wrap1< +// boost::parameter::aux::make_arg_list< // PS0,A0 -// , aux::make_arg_list< +// , boost::parameter::aux::make_arg_list< // PS1,A1 -// , mpl::identity +// , boost::mpl::identity< +// boost::parameter::aux::empty_arg_list +// > // > // > // >::type arg_tuple; @@ -31,7 +35,7 @@ // return arg_tuple( // a0 // , a1 -// , aux::void_() +// , boost::parameter::aux::void_() // ... // ); // } @@ -44,45 +48,45 @@ #define N BOOST_PP_ITERATION() #define BOOST_PARAMETER_open_list(z, n, text) \ - aux::item< \ + ::boost::parameter::aux::item< \ BOOST_PP_CAT(PS, n), BOOST_PP_CAT(A, n) #define BOOST_PARAMETER_close_list(z, n, text) > #define BOOST_PARAMETER_arg_list(n) \ - aux::make_arg_list< \ + ::boost::parameter::aux::make_arg_list< \ BOOST_PP_ENUM(N, BOOST_PARAMETER_open_list, _) \ - , void_ \ + , ::boost::parameter::void_ \ BOOST_PP_REPEAT(N, BOOST_PARAMETER_close_list, _) \ , deduced_list \ - , aux::tag_keyword_arg \ + , ::boost::parameter::aux::tag_keyword_arg \ > #define BOOST_PARAMETER_arg_pack_init(z, n, limit) \ - BOOST_PP_CAT(a, BOOST_PP_SUB(limit,n)) + BOOST_PP_CAT(a, BOOST_PP_SUB(limit, n)) -template -typename mpl::first< +template +typename ::boost::mpl::first< typename BOOST_PARAMETER_arg_list(N)::type >::type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, & a)) const { typedef typename BOOST_PARAMETER_arg_list(N)::type result; - - typedef typename mpl::first::type result_type; - typedef typename mpl::second::type error; + typedef typename ::boost::mpl::first::type result_type; + typedef typename ::boost::mpl::second::type error; error(); return result_type( BOOST_PP_ENUM(N, BOOST_PARAMETER_arg_pack_init, BOOST_PP_DEC(N)) BOOST_PP_ENUM_TRAILING_PARAMS( BOOST_PP_SUB(BOOST_PARAMETER_MAX_ARITY, N) - , aux::void_reference() BOOST_PP_INTERCEPT - )); + , ::boost::parameter::aux::void_reference() BOOST_PP_INTERCEPT + ) + ); } #undef BOOST_PARAMETER_arg_list -#undef BOOST_PARAMETER_open_list #undef BOOST_PARAMETER_close_list +#undef BOOST_PARAMETER_open_list #undef N diff --git a/include/boost/parameter/aux_/preprocessor/qualifier.hpp b/include/boost/parameter/aux_/preprocessor/qualifier.hpp new file mode 100755 index 0000000..914ac3b --- /dev/null +++ b/include/boost/parameter/aux_/preprocessor/qualifier.hpp @@ -0,0 +1,46 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_QUALIFIER_HPP +#define BOOST_PARAMETER_AUX_PREPROCESSOR_QUALIFIER_HPP + +#define BOOST_PARAMETER_QUALIFIER_EAT_out(x) +#define BOOST_PARAMETER_QUALIFIER_EAT_in_out(x) + +#define BOOST_PARAMETER_STRIP_QUALIFIER_out(x) x +#define BOOST_PARAMETER_STRIP_QUALIFIER_in_out(x) x + +#include + +#define BOOST_PARAMETER_GET_UNQUALIFIED(x) \ + BOOST_PP_CAT(BOOST_PARAMETER_STRIP_QUALIFIER_, x) +/**/ + +#include + +// Expands to 1 if x is either "out(k)" or "in_out(k)"; +// expands to 0 otherwise. +#define BOOST_PARAMETER_IS_QUALIFIER(x) \ + BOOST_PP_IS_EMPTY(BOOST_PP_CAT(BOOST_PARAMETER_QUALIFIER_EAT_, x)) +/**/ + +#include + +// Expands to the unqualified version of x, +// where x is either a keyword qualifier or a keyword. +// +// k => k +// out(k) => k +// in_out(k) => k +#define BOOST_PARAMETER_UNQUALIFIED(x) \ + BOOST_PP_IIF( \ + BOOST_PARAMETER_IS_QUALIFIER(x) \ + , BOOST_PARAMETER_GET_UNQUALIFIED(x) \ + , x \ + ) +/**/ + +#endif // include guard + diff --git a/include/boost/parameter/aux_/tagged_argument.hpp b/include/boost/parameter/aux_/tagged_argument.hpp index 251523c..8d46a2e 100644 --- a/include/boost/parameter/aux_/tagged_argument.hpp +++ b/include/boost/parameter/aux_/tagged_argument.hpp @@ -6,16 +6,17 @@ #ifndef BOOST_PARAMETER_TAGGED_ARGUMENT_050328_HPP # define BOOST_PARAMETER_TAGGED_ARGUMENT_050328_HPP +# include +# include +# include # include # include # include # include +# include +# include # include -# include -# include # include -# include -# include # include # include # include @@ -28,11 +29,6 @@ namespace boost { namespace parameter { namespace aux { -struct empty_arg_list; -struct arg_list_tag; - -struct tagged_argument_base {}; - // Holds a reference to an argument of type Arg associated with // keyword Keyword @@ -206,21 +202,6 @@ public: typedef arg_list_tag tag; // For dispatching to sequence intrinsics }; -// Defines a metafunction, is_tagged_argument, that identifies -// tagged_argument specializations and their derived classes. -template -struct is_tagged_argument_aux - : is_convertible -{}; - -template -struct is_tagged_argument - : mpl::and_< - mpl::not_ > - , is_tagged_argument_aux - > -{}; - }}} // namespace boost::parameter::aux #endif // BOOST_PARAMETER_TAGGED_ARGUMENT_050328_HPP diff --git a/include/boost/parameter/aux_/tagged_argument_fwd.hpp b/include/boost/parameter/aux_/tagged_argument_fwd.hpp new file mode 100755 index 0000000..16f66ff --- /dev/null +++ b/include/boost/parameter/aux_/tagged_argument_fwd.hpp @@ -0,0 +1,16 @@ +// Copyright Daniel Wallin, David Abrahams 2005. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_TAGGED_ARGUMENT_FWD_HPP +#define BOOST_PARAMETER_TAGGED_ARGUMENT_FWD_HPP + +namespace boost { namespace parameter { namespace aux { + + template + class tagged_argument; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/use_default.hpp b/include/boost/parameter/aux_/use_default.hpp new file mode 100755 index 0000000..ba25a3f --- /dev/null +++ b/include/boost/parameter/aux_/use_default.hpp @@ -0,0 +1,17 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_USE_DEFAULT_HPP +#define BOOST_PARAMETER_AUX_USE_DEFAULT_HPP + +namespace boost { namespace parameter { namespace aux { + + struct use_default + { + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/use_default_tag.hpp b/include/boost/parameter/aux_/use_default_tag.hpp new file mode 100755 index 0000000..9688448 --- /dev/null +++ b/include/boost/parameter/aux_/use_default_tag.hpp @@ -0,0 +1,21 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_USE_DEFAULT_TAG_HPP +#define BOOST_PARAMETER_USE_DEFAULT_TAG_HPP + +namespace boost { namespace parameter { namespace aux { + + struct use_default_tag + { + inline use_default_tag operator()() const + { + return *this; + } + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/aux_/void.hpp b/include/boost/parameter/aux_/void.hpp index 7061a7d..2c7103b 100644 --- a/include/boost/parameter/aux_/void.hpp +++ b/include/boost/parameter/aux_/void.hpp @@ -1,6 +1,6 @@ -// Copyright Daniel Wallin, David Abrahams 2005. Use, modification and -// distribution is subject to the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at +// Copyright Daniel Wallin, David Abrahams 2005. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_PARAMETER_VOID_050329_HPP @@ -8,22 +8,31 @@ namespace boost { namespace parameter { -// A placemarker for "no argument passed." -// MAINTAINER NOTE: Do not make this into a metafunction -struct void_ {}; - -namespace aux -{ - - inline void_& void_reference() - { - static void_ instance; - return instance; - } - -} // namespace aux - + // A placemarker for "no argument passed." + // MAINTAINER NOTE: Do not make this into a metafunction + struct void_ + { + }; }} // namespace boost::parameter -#endif // BOOST_PARAMETER_VOID_050329_HPP +namespace boost { namespace parameter { namespace aux { + + inline ::boost::parameter::void_& void_reference() + { + static ::boost::parameter::void_ instance; + return instance; + } +}}} // namespace boost::parameter::aux + +#include + +#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) + +namespace boost { namespace parameter { namespace aux { + + typedef void* voidstar; +}}} // namespace boost::parameter::aux + +#endif +#endif // include guard diff --git a/include/boost/parameter/deduced.hpp b/include/boost/parameter/deduced.hpp new file mode 100755 index 0000000..8110668 --- /dev/null +++ b/include/boost/parameter/deduced.hpp @@ -0,0 +1,92 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_DEDUCED_HPP +#define BOOST_PARAMETER_DEDUCED_HPP + +#include + +namespace boost { namespace parameter { + + // This metafunction can be used to describe the treatment of particular + // named parameters for the purposes of overload elimination with SFINAE, + // by placing specializations in the parameters<...> list. + // + // If a keyword k is specified with deduced<...>, that keyword + // will be automatically deduced from the argument list. + template + struct deduced + { + typedef Tag key_type; + }; +}} + +#include + +namespace boost { namespace parameter { namespace aux { + + template + struct is_deduced_aux : ::boost::mpl::false_ + { + }; + + template + struct is_deduced_aux< ::boost::parameter::deduced > + : ::boost::mpl::true_ + { + }; + + template + struct is_deduced0 + : ::boost::parameter::aux::is_deduced_aux::type + { + }; +}}} // namespace boost::parameter::aux + +#include +#include +#include + +namespace boost { namespace parameter { namespace aux { + + // + // tag_type, has_default, and predicate -- + // + // These metafunctions accept a ParameterSpec and extract the + // keyword tag, whether or not a default is supplied for the + // parameter, and the predicate that the corresponding actual + // argument type is required match. + // + // a ParameterSpec is a specialization of either keyword<...>, + // required<...>, optional<...> + // + + template + struct has_default + : ::boost::mpl::if_< + ::boost::parameter::aux::is_required + , ::boost::mpl::false_ + , ::boost::mpl::true_ + >::type + { + }; + + template + struct is_deduced + : ::boost::mpl::if_< + typename ::boost::mpl::if_< + ::boost::parameter::aux::is_optional + , ::boost::mpl::true_ + , ::boost::parameter::aux::is_required + >::type + , ::boost::parameter::aux::is_deduced0 + , ::boost::mpl::false_ + >::type + { + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/keyword_fwd.hpp b/include/boost/parameter/keyword_fwd.hpp new file mode 100755 index 0000000..2ad1cf6 --- /dev/null +++ b/include/boost/parameter/keyword_fwd.hpp @@ -0,0 +1,16 @@ +// Copyright Cromwell D. Enage 2017. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_KEYWORD_FWD_HPP +#define BOOST_PARAMETER_KEYWORD_FWD_HPP + +namespace boost { namespace parameter { + + template + struct keyword; +}} // namespace boost::parameter + +#endif // include guard + diff --git a/include/boost/parameter/optional.hpp b/include/boost/parameter/optional.hpp new file mode 100755 index 0000000..cb47e2d --- /dev/null +++ b/include/boost/parameter/optional.hpp @@ -0,0 +1,52 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_OPTIONAL_HPP +#define BOOST_PARAMETER_OPTIONAL_HPP + +#include + +namespace boost { namespace parameter { + + // This metafunction can be used to describe the treatment of particular + // named parameters for the purposes of overload elimination with SFINAE, + // by placing specializations in the parameters<...> list. In order for + // a treated function to participate in overload resolution: + // + // - The actual argument type matched by every keyword tag + // associated with a predicate must satisfy that predicate + // + // - If a keyword k is specified without an optional<...> or + // required<...> wrapper, it is treated as though + // optional were specified. + template < + typename Tag + , typename Predicate = ::boost::parameter::aux::use_default + > + struct optional + { + typedef Tag key_type; + typedef Predicate predicate; + }; +}} + +#include + +namespace boost { namespace parameter { namespace aux { + + template + struct is_optional : ::boost::mpl::false_ + { + }; + + template + struct is_optional< ::boost::parameter::optional > + : ::boost::mpl::true_ + { + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/include/boost/parameter/parameters.hpp b/include/boost/parameter/parameters.hpp index 97e1024..7d857e6 100644 --- a/include/boost/parameter/parameters.hpp +++ b/include/boost/parameter/parameters.hpp @@ -1,931 +1,290 @@ -// Copyright David Abrahams, Daniel Wallin 2003. Use, modification and -// distribution is subject to the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_PARAMETERS_031014_HPP #define BOOST_PARAMETERS_031014_HPP -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include - -#include -#include -#include -#include -#include +#if !defined(BOOST_NO_SFINAE) && \ + !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) +#include +#include #include #include -#include -#include -#include - #include -#include +#endif -#include +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) #include -#include -#include -#include -#include +#else #include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace parameter_ -{ - template - struct unmatched_argument - { - BOOST_MPL_ASSERT((boost::is_same)); - typedef int type; - }; -} // namespace parameter_ - -namespace boost { - -template class reference_wrapper; - -namespace parameter { - -namespace aux { struct use_default {}; } - -// These templates can be used to describe the treatment of particular -// named parameters for the purposes of overload elimination with -// SFINAE, by placing specializations in the parameters<...> list. In -// order for a treated function to participate in overload resolution: -// -// - all keyword tags wrapped in required<...> must have a matching -// actual argument -// -// - The actual argument type matched by every keyword tag -// associated with a predicate must satisfy that predicate -// -// If a keyword k is specified without an optional<...> or -// required<...>, wrapper, it is treated as though optional were -// specified. -// -// If a keyword k is specified with deduced<...>, that keyword -// will be automatically deduced from the argument list. -// -template -struct required -{ - typedef Tag key_type; - typedef Predicate predicate; -}; - -template -struct optional -{ - typedef Tag key_type; - typedef Predicate predicate; -}; - -template -struct deduced -{ - typedef Tag key_type; -}; - -namespace aux -{ - // Defines metafunctions, is_required and is_optional, that - // identify required<...>, optional<...> and deduced<...> specializations. - BOOST_DETAIL_IS_XXX_DEF(required, required, 2) - BOOST_DETAIL_IS_XXX_DEF(optional, optional, 2) - BOOST_DETAIL_IS_XXX_DEF(deduced_aux, deduced, 1) - - template - struct is_deduced0 - : is_deduced_aux< - typename S::key_type - >::type - {}; - - template - struct is_deduced - : mpl::eval_if< - mpl::or_< - is_optional, is_required - > - , is_deduced0 - , mpl::false_ - >::type - {}; - - // - // key_type, has_default, and predicate -- - // - // These metafunctions accept a ParameterSpec and extract the - // keyword tag, whether or not a default is supplied for the - // parameter, and the predicate that the corresponding actual - // argument type is required match. - // - // a ParameterSpec is a specialization of either keyword<...>, - // required<...>, optional<...> - // - - // helper for key_type<...>, below. - template - struct get_tag_type0 - { - typedef typename T::key_type type; - }; - - template - struct get_tag_type - : mpl::eval_if< - is_deduced_aux - , get_tag_type0 - , mpl::identity - > - {}; - - template - struct tag_type - : mpl::eval_if< - mpl::or_< - is_optional - , is_required - > - , get_tag_type - , mpl::identity - > - {}; - - template - struct has_default - : mpl::not_ > - {}; - - // helper for get_predicate<...>, below - template - struct get_predicate_or_default - { - typedef T type; - }; - - template <> - struct get_predicate_or_default - { - typedef mpl::always type; - }; - - // helper for predicate<...>, below - template - struct get_predicate - { - typedef typename - get_predicate_or_default::type - type; - }; - - template - struct predicate - : mpl::eval_if< - mpl::or_< - is_optional - , is_required - > - , get_predicate - , mpl::identity > - > - { - }; - - - // Converts a ParameterSpec into a specialization of - // parameter_requirements. We need to do this in order to get the - // tag_type into the type in a way that can be conveniently matched - // by a satisfies(...) member function in arg_list. - template - struct as_parameter_requirements - { - typedef parameter_requirements< - typename tag_type::type - , typename predicate::type - , typename has_default::type - > type; - }; - - template - struct is_named_argument - : mpl::or_< - is_template_keyword - , is_tagged_argument - > - {}; - - // Returns mpl::true_ iff the given ParameterRequirements are - // satisfied by ArgList. - template - struct satisfies - { -#if BOOST_WORKAROUND(BOOST_MSVC, == 1310) - // VC7.1 can't handle the sizeof() implementation below, - // so we use this instead. - typedef typename mpl::apply_wrap3< - typename ArgList::binding - , typename ParameterRequirements::keyword - , void_ - , mpl::false_ - >::type bound; - - typedef typename mpl::eval_if< - is_same - , typename ParameterRequirements::has_default - , mpl::apply_wrap2< - typename mpl::lambda< - typename ParameterRequirements::predicate, lambda_tag - >::type - , bound - , ArgList - > - >::type type; -#else - BOOST_STATIC_CONSTANT( - bool, value = ( - sizeof( - aux::to_yesno( - ArgList::satisfies((ParameterRequirements*)0, (ArgList*)0) - ) - ) == sizeof(yes_tag) - ) - ); - - typedef mpl::bool_ type; -#endif - }; - - // Returns mpl::true_ if the requirements of the given ParameterSpec - // are satisfied by ArgList. - template - struct satisfies_requirements_of - : satisfies< - ArgList - , typename as_parameter_requirements::type - > - {}; - - // Tags a deduced argument Arg with the keyword tag of Spec using TagFn. - // Returns the tagged argument and the mpl::set<> UsedArgs with the - // tag of Spec inserted. - template - struct tag_deduced - { - typedef mpl::pair< - typename mpl::apply_wrap2::type, Arg>::type - , typename aux::insert_::type>::type - > type; - }; - - template < - class Argument - , class ArgumentPack - , class DeducedArgs - , class UsedArgs - , class TagFn - > - struct deduce_tag; - - // Tag type passed to MPL lambda. - struct lambda_tag; - - // Helper for deduce_tag<> below. - template < - class Argument - , class ArgumentPack - , class DeducedArgs - , class UsedArgs - , class TagFn - > - struct deduce_tag0 - { - typedef typename DeducedArgs::spec spec; - - typedef typename mpl::apply_wrap2< - typename mpl::lambda< - typename spec::predicate, lambda_tag - >::type - , Argument - , ArgumentPack - >::type condition; - - // Deduced parameter matches several arguments. - - BOOST_MPL_ASSERT(( - mpl::not_::type> - > > - )); - - typedef typename mpl::eval_if< - condition - , tag_deduced - , deduce_tag - >::type type; - }; - - // Tries to deduced a keyword tag for a given Argument. - // Returns an mpl::pair<> consisting of the tagged_argument<>, - // and an mpl::set<> where the new tag has been inserted. - // - // Argument: The argument type to be tagged. - // - // ArgumentPack: The ArgumentPack built so far. - // - // DeducedArgs: A specialization of deduced_item<> (see below). - // A list containing only the deduced ParameterSpecs. - // - // UsedArgs: An mpl::set<> containing the keyword tags used so far. - // - // TagFn: A metafunction class used to tag positional or deduced - // arguments with a keyword tag. - - template < - class Argument - , class ArgumentPack - , class DeducedArgs - , class UsedArgs - , class TagFn - > - struct deduce_tag - { - typedef typename mpl::eval_if< - is_same - , mpl::pair - , deduce_tag0 - >::type type; - }; - - template < - class List - , class DeducedArgs - , class TagFn - , class Positional - , class UsedArgs - , class ArgumentPack - , class Error - > - struct make_arg_list_aux; - - // Inserts Tagged::key_type into the UserArgs set. - // Extra indirection to lazily evaluate Tagged::key_type. - template - struct insert_tagged - { - typedef typename aux::insert_< - UsedArgs, typename Tagged::key_type - >::type type; - }; - - // Borland needs the insane extra-indirection workaround below - // so that it doesn't magically drop the const qualifier from - // the argument type. - - template < - class List - , class DeducedArgs - , class TagFn - , class Positional - , class UsedArgs - , class ArgumentPack -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - , class argument -#endif - , class Error - > -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - struct make_arg_list00 -#else - struct make_arg_list0 -#endif - { -#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - typedef typename List::arg argument; -#endif - typedef typename List::spec parameter_spec; - typedef typename tag_type::type tag_; - - typedef is_named_argument is_tagged; - - // If this argument is either explicitly tagged or a deduced - // parameter, we turn off positional matching. - typedef mpl::and_< - mpl::not_< - mpl::or_, is_tagged> - > - , Positional - > positional; - - // If this parameter is explicitly tagged we add it to the - // used-parmeters set. We only really need to add parameters - // that are deduced, but we would need a way to check if - // a given tag corresponds to a deduced parameter spec. - typedef typename mpl::eval_if< - is_tagged - , insert_tagged - , mpl::identity - >::type used_args; - - // If this parameter is neither explicitly tagged, nor - // positionally matched; deduce the tag from the deduced - // parameter specs. - typedef typename mpl::eval_if< - mpl::or_ - , mpl::pair - , deduce_tag - >::type deduced_data; - - // If this parameter is explicitly tagged.. - typedef typename mpl::eval_if< - is_tagged - , mpl::identity // .. just use it - , mpl::eval_if< // .. else, if positional matching is turned on.. - positional - , mpl::apply_wrap2 // .. tag it positionally - , mpl::first // .. else, use the deduced tag - > - >::type tagged; - - // We build the arg_list incrementally as we go, prepending new - // nodes. - - typedef typename mpl::if_< - mpl::and_< - is_same - , is_same - > - , parameter_::unmatched_argument - , void_ - >::type error; - - typedef typename mpl::if_< - is_same - , ArgumentPack - , arg_list - >::type argument_pack; - - typedef typename make_arg_list_aux< - typename List::tail - , DeducedArgs - , TagFn - , positional - , typename deduced_data::second - , argument_pack - , error - >::type type; - }; - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - template < - class List - , class DeducedArgs - , class TagFn - , class Positional - , class UsedArgs - , class ArgumentPack - , class Error - > - struct make_arg_list0 - { - typedef typename mpl::eval_if< - typename List::is_arg_const - , make_arg_list00< - List - , DeducedArgs - , TagFn - , Positional - , UsedArgs - , ArgumentPack - , typename List::arg const - , Error - > - , make_arg_list00< - List - , DeducedArgs - , TagFn - , Positional - , UsedArgs - , ArgumentPack - , typename List::arg - , Error - > - >::type type; - }; #endif - // Returns an ArgumentPack where the list of arguments has - // been tagged with keyword tags. - // - // List: A specialization of item<> (see below). Contains - // both the ordered ParameterSpecs, and the given arguments. - // - // DeducedArgs: A specialization of deduced_item<> (see below). - // A list containing only the deduced ParameterSpecs. - // - // TagFn: A metafunction class used to tag positional or deduced - // arguments with a keyword tag. - // - // Position: An mpl::bool_<> specialization indicating if positional - // matching is to be performed. - // - // DeducedSet: An mpl::set<> containing the keyword tags used so far. - // - // ArgumentPack: The ArgumentPack built so far. This is initially an - // empty_arg_list and is built incrementally. - // +#include - template < - class List - , class DeducedArgs - , class TagFn - , class Positional - , class DeducedSet - , class ArgumentPack - , class Error - > - struct make_arg_list_aux - { - typedef typename mpl::eval_if< - is_same - , mpl::identity > - , make_arg_list0 - >::type type; - }; - - // VC6.5 was choking on the default parameters for make_arg_list_aux, so - // this just forwards to that adding in the defaults. - template < - class List - , class DeducedArgs - , class TagFn - , class EmitErrors = mpl::true_ - > - struct make_arg_list - { - typedef typename make_arg_list_aux< - List, DeducedArgs, TagFn, mpl::true_, aux::set0, empty_arg_list, void_ - >::type type; - }; - - // A parameter spec item typelist. - template - struct item - { - typedef Spec spec; - -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - typedef is_const is_arg_const; -#endif - - typedef Arg arg; - typedef Tail tail; - }; - - template - struct make_item - { - typedef item type; - }; - - // Creates a item typelist. - template - struct make_items - { - typedef typename mpl::eval_if< - is_same - , mpl::identity - , make_item - >::type type; - }; - - // A typelist that stored deduced parameter specs. - template - struct deduced_item - { - typedef ParameterSpec spec; - typedef Tail tail; - }; - - // Evaluate Tail and construct deduced_item list. - template - struct make_deduced_item - { - typedef deduced_item type; - }; - - template - struct make_deduced_items - { - typedef typename mpl::eval_if< - is_same - , mpl::identity - , mpl::eval_if< - is_deduced - , make_deduced_item - , Tail - > - >::type type; - }; - - // Generates: - // - // make< - // parameter_spec#0, argument_type#0 - // , make< - // parameter_spec#1, argument_type#1 - // , ... mpl::identity - // ...> - // > -#define BOOST_PARAMETER_make_arg_list(z, n, names) \ - BOOST_PP_SEQ_ELEM(0,names)< \ - BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(1,names), n), \ - BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(2,names), n), - -#define BOOST_PARAMETER_right_angle(z, n, text) > - -#define BOOST_PARAMETER_build_arg_list(n, make, parameter_spec, argument_type) \ - BOOST_PP_REPEAT( \ - n, BOOST_PARAMETER_make_arg_list, (make)(parameter_spec)(argument_type)) \ - mpl::identity \ - BOOST_PP_REPEAT(n, BOOST_PARAMETER_right_angle, _) - -#define BOOST_PARAMETER_make_deduced_list(z, n, names) \ - BOOST_PP_SEQ_ELEM(0,names)< \ - BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(1,names), n), - -#define BOOST_PARAMETER_build_deduced_list(n, make, parameter_spec) \ - BOOST_PP_REPEAT( \ - n, BOOST_PARAMETER_make_deduced_list, (make)(parameter_spec)) \ - mpl::identity \ - BOOST_PP_REPEAT(n, BOOST_PARAMETER_right_angle, _) - - struct tag_keyword_arg - { - template - struct apply - : tag - {}; - }; - - struct tag_template_keyword_arg - { - template - struct apply - { - typedef template_keyword type; - }; - }; - -} // namespace aux - -#define BOOST_PARAMETER_FORWARD_TYPEDEF(z, i, names) \ - typedef BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(0,names),i) BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(1,names),i); - -#define BOOST_PARAMETER_FORWARD_TYPEDEFS(n, src, dest) \ - BOOST_PP_REPEAT(n, BOOST_PARAMETER_FORWARD_TYPEDEF, (src)(dest)) - - -#define BOOST_PARAMETER_TEMPLATE_ARGS(z, n, text) class BOOST_PP_CAT(PS, n) = void_ - -template< - class PS0 - , BOOST_PP_ENUM_SHIFTED(BOOST_PARAMETER_MAX_ARITY, BOOST_PARAMETER_TEMPLATE_ARGS, _) -> -struct parameters -{ -#undef BOOST_PARAMETER_TEMPLATE_ARGS - - typedef typename BOOST_PARAMETER_build_deduced_list( - BOOST_PARAMETER_MAX_ARITY, aux::make_deduced_items, PS - )::type deduced_list; - - // if the elements of NamedList match the criteria of overload - // resolution, returns a type which can be constructed from - // parameters. Otherwise, this is not a valid metafunction (no nested - // ::type). - - -#if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) - // If NamedList satisfies the PS0, PS1, ..., this is a - // metafunction returning parameters. Otherwise it - // has no nested ::type. - template - struct match_base - : mpl::if_< - // mpl::and_< - // aux::satisfies_requirements_of - // , mpl::and_< - // aux::satisfies_requirements_of... - // ..., mpl::true_ - // ...> > - -# define BOOST_PARAMETER_satisfies(z, n, text) \ - mpl::and_< \ - aux::satisfies_requirements_of< \ - typename mpl::first::type \ - , BOOST_PP_CAT(PS, n)> \ - , - mpl::and_< - is_same::type, void_> - , BOOST_PP_REPEAT(BOOST_PARAMETER_MAX_ARITY, BOOST_PARAMETER_satisfies, _) - mpl::true_ - BOOST_PP_REPEAT(BOOST_PARAMETER_MAX_ARITY, BOOST_PARAMETER_right_angle, _) - > - -# undef BOOST_PARAMETER_satisfies - - , mpl::identity - , void_ - > - {}; -#endif - - // Specializations are to be used as an optional argument to - // eliminate overloads via SFINAE - template< -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - // Borland simply can't handle default arguments in member - // class templates. People wishing to write portable code can - // explicitly specify BOOST_PARAMETER_MAX_ARITY arguments - BOOST_PP_ENUM_PARAMS(BOOST_PARAMETER_MAX_ARITY, class A) -#else - BOOST_PP_ENUM_BINARY_PARAMS( - BOOST_PARAMETER_MAX_ARITY, class A, = void_ BOOST_PP_INTERCEPT - ) -#endif - > - struct match -# if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) - : match_base< - typename aux::make_arg_list< - typename BOOST_PARAMETER_build_arg_list( - BOOST_PARAMETER_MAX_ARITY, aux::make_items, PS, A - )::type - , deduced_list - , aux::tag_keyword_arg - , mpl::false_ // Don't emit errors when doing SFINAE - >::type - >::type - {}; -# else - { - typedef parameters< - BOOST_PP_ENUM_PARAMS(BOOST_PARAMETER_MAX_ARITY, PS) - > type; - }; -# endif - - // Metafunction that returns an ArgumentPack. - - // TODO, bind has to instantiate the error type in the result - // of make_arg_list. +namespace boost { namespace parameter { template < -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - // Borland simply can't handle default arguments in member - // class templates. People wishing to write portable code can - // explicitly specify BOOST_PARAMETER_MAX_ARITY arguments - BOOST_PP_ENUM_PARAMS(BOOST_PARAMETER_MAX_ARITY, class A) -#else - BOOST_PP_ENUM_BINARY_PARAMS( - BOOST_PARAMETER_MAX_ARITY, class A, = void_ BOOST_PP_INTERCEPT + typename PS0 + , BOOST_PP_ENUM_SHIFTED( + BOOST_PARAMETER_MAX_ARITY, BOOST_PARAMETER_template_args, PS ) -#endif > - struct bind + struct parameters { - typedef typename aux::make_arg_list< - typename BOOST_PARAMETER_build_arg_list( - BOOST_PARAMETER_MAX_ARITY, aux::make_items, PS, A - )::type - , deduced_list - , aux::tag_template_keyword_arg - >::type result; + typedef typename BOOST_PARAMETER_build_deduced_list( + BOOST_PARAMETER_MAX_ARITY + , ::boost::parameter::aux::make_deduced_items + , PS + )::type deduced_list; - typedef typename mpl::first::type type; - }; - - BOOST_PARAMETER_FORWARD_TYPEDEFS(BOOST_PARAMETER_MAX_ARITY, PS, parameter_spec) - - // - // The function call operator is used to build an arg_list that - // labels the positional parameters and maintains whatever other - // tags may have been specified by the caller. - // - // !!!NOTE!!! - // - // The make_arg_list<> produces a reversed arg_list, so - // we need to pass the arguments to its constructor - // reversed. - // - aux::empty_arg_list operator()() const - { - return aux::empty_arg_list(); - } - - template - typename mpl::first< - typename aux::make_arg_list< - aux::item< - PS0,A0 - > - , deduced_list - , aux::tag_keyword_arg - >::type - >::type - operator()(A0& a0) const - { - typedef typename aux::make_arg_list< - aux::item< - PS0,A0 - > - , deduced_list - , aux::tag_keyword_arg - >::type result; - - typedef typename mpl::first::type result_type; - typedef typename mpl::second::type error; - error(); - - return result_type( - a0 - // , void_(), void_(), void_() ... - BOOST_PP_ENUM_TRAILING_PARAMS( - BOOST_PP_SUB(BOOST_PARAMETER_MAX_ARITY, 1) - , aux::void_reference() BOOST_PP_INTERCEPT) - ); - } - - template - typename mpl::first< - typename aux::make_arg_list< - aux::item< - PS0,A0 - , aux::item< - PS1,A1 + // If the elements of NamedList match the criteria of overload + // resolution, returns a type which can be constructed from + // parameters. Otherwise, this is not a valid metafunction + // (no nested ::type). +#if !defined(BOOST_NO_SFINAE) && \ + !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) + // If NamedList satisfies the PS0, PS1, ..., this is a metafunction + // returning parameters. Otherwise it has no nested ::type. + template + struct match_base + : ::boost::mpl::if_< + // ::boost::mpl::and_< + // aux::satisfies_requirements_of + // , ::boost::mpl::and_< + // aux::satisfies_requirements_of... + // ..., ::boost::mpl::true_ + // ...> > + typename BOOST_PP_REPEAT( + BOOST_PARAMETER_MAX_ARITY + , BOOST_PARAMETER_satisfies_begin + , PS + ) + ::boost::is_same< + typename ::boost::mpl + ::second::type + , ::boost::parameter::void_ > - > - , deduced_list - , aux::tag_keyword_arg - >::type - >::type - operator()(A0& a0, A1& a1) const - { - typedef typename aux::make_arg_list< - aux::item< - PS0,A0 - , aux::item< - PS1,A1 + BOOST_PP_REPEAT( + BOOST_PARAMETER_MAX_ARITY + , BOOST_PARAMETER_satisfies_end + , ::boost::mpl::false_ + )::type + , ::boost::mpl::identity< + ::boost::parameter::parameters< + BOOST_PP_ENUM_PARAMS(BOOST_PARAMETER_MAX_ARITY, PS) + > > + , ::boost::parameter::void_ > - , deduced_list - , aux::tag_keyword_arg - >::type result; + { + }; +#endif // SFINAE enabled, not Borland. - typedef typename mpl::first::type result_type; - typedef typename mpl::second::type error; - error(); + // Specializations are to be used as an optional argument + // to eliminate overloads via SFINAE. + template < +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + // Borland simply can't handle default arguments in member + // class templates. People wishing to write portable code can + // explicitly specify BOOST_PARAMETER_MAX_ARITY arguments. + BOOST_PP_ENUM_PARAMS(BOOST_PARAMETER_MAX_ARITY, typename A) +#else + BOOST_PP_ENUM_BINARY_PARAMS( + BOOST_PARAMETER_MAX_ARITY + , typename A + , = ::boost::parameter::void_ BOOST_PP_INTERCEPT + ) +#endif + > + struct match +#if !defined(BOOST_NO_SFINAE) && \ + !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) + : ::boost::parameter::parameters< + BOOST_PP_ENUM_PARAMS(BOOST_PARAMETER_MAX_ARITY, PS) + >::BOOST_NESTED_TEMPLATE match_base< + typename ::boost::parameter::aux::make_arg_list< + typename BOOST_PARAMETER_build_arg_list( + BOOST_PARAMETER_MAX_ARITY + , ::boost::parameter::aux::make_items + , PS + , A + )::type + , deduced_list + , ::boost::parameter::aux::tag_keyword_arg + // Don't emit errors when doing SFINAE. + , ::boost::mpl::false_ + >::type + >::type + { + }; +#else + { + typedef ::boost::parameter::parameters< + BOOST_PP_ENUM_PARAMS(BOOST_PARAMETER_MAX_ARITY, PS) + > type; + }; +#endif // SFINAE enabled, not Borland. - return result_type( - a1,a0 - // , void_(), void_() ... - BOOST_PP_ENUM_TRAILING_PARAMS( - BOOST_PP_SUB(BOOST_PARAMETER_MAX_ARITY, 2) - , aux::void_reference() BOOST_PP_INTERCEPT) - ); - } + // Metafunction that returns an ArgumentPack. - // Higher arities are handled by the preprocessor -#define BOOST_PP_ITERATION_PARAMS_1 (3,( \ - 3,BOOST_PARAMETER_MAX_ARITY, \ + // TODO, bind has to instantiate the error type in the result + // of make_arg_list. + + template < +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) + // Borland simply can't handle default arguments in member + // class templates. People wishing to write portable code can + // explicitly specify BOOST_PARAMETER_MAX_ARITY arguments + BOOST_PP_ENUM_PARAMS(BOOST_PARAMETER_MAX_ARITY, typename A) +#else + BOOST_PP_ENUM_BINARY_PARAMS( + BOOST_PARAMETER_MAX_ARITY + , typename A + , = ::boost::parameter::void_ BOOST_PP_INTERCEPT + ) +#endif + > + struct bind + { + typedef typename ::boost::parameter::aux::make_arg_list< + typename BOOST_PARAMETER_build_arg_list( + BOOST_PARAMETER_MAX_ARITY + , ::boost::parameter::aux::make_items + , PS + , A + )::type + , deduced_list + , ::boost::parameter::aux::tag_template_keyword_arg + >::type result; + + typedef typename ::boost::mpl::first::type type; + }; + + BOOST_PARAMETER_forward_typedefs( + BOOST_PARAMETER_MAX_ARITY, PS, parameter_spec + ) + + // The function call operator is used to build an arg_list that + // labels the positional parameters and maintains whatever other + // tags may have been specified by the caller. + // + // !!!NOTE!!! + // + // The make_arg_list<> metafunction produces a reversed arg_list, + // so pass the arguments to the arg_list constructor reversed in turn. + inline ::boost::parameter::aux::empty_arg_list operator()() const + { + return ::boost::parameter::aux::empty_arg_list(); + } + + template + typename ::boost::mpl::first< + typename ::boost::parameter::aux::make_arg_list< + ::boost::parameter::aux::item< + PS0,A0 + > + , deduced_list + , ::boost::parameter::aux::tag_keyword_arg + >::type + >::type + operator()(A0& a0) const + { + typedef typename ::boost::parameter::aux::make_arg_list< + ::boost::parameter::aux::item< + PS0,A0 + > + , deduced_list + , ::boost::parameter::aux::tag_keyword_arg + >::type result; + + typedef typename ::boost::mpl::first::type result_type; + typedef typename ::boost::mpl::second::type error; + error(); + + return result_type( + a0 + // , void_(), void_(), void_() ... + BOOST_PP_ENUM_TRAILING_PARAMS( + BOOST_PP_SUB(BOOST_PARAMETER_MAX_ARITY, 1) + , ::boost::parameter::aux::void_reference() BOOST_PP_INTERCEPT + ) + ); + } + + template + typename ::boost::mpl::first< + typename ::boost::parameter::aux::make_arg_list< + ::boost::parameter::aux::item< + PS0,A0 + , ::boost::parameter::aux::item< + PS1,A1 + > + > + , deduced_list + , ::boost::parameter::aux::tag_keyword_arg + >::type + >::type + operator()(A0& a0, A1& a1) const + { + typedef typename ::boost::parameter::aux::make_arg_list< + ::boost::parameter::aux::item< + PS0,A0 + , ::boost::parameter::aux::item< + PS1,A1 + > + > + , deduced_list + , ::boost::parameter::aux::tag_keyword_arg + >::type result; + + typedef typename ::boost::mpl::first::type result_type; + typedef typename ::boost::mpl::second::type error; + error(); + + return result_type( + a1,a0 + // , void_(), void_() ... + BOOST_PP_ENUM_TRAILING_PARAMS( + BOOST_PP_SUB(BOOST_PARAMETER_MAX_ARITY, 2) + , ::boost::parameter::aux::void_reference() BOOST_PP_INTERCEPT + ) + ); + } + + // Higher arities are handled by the preprocessor +#define BOOST_PP_ITERATION_PARAMS_1 \ + (3,( \ + 3 \ + , BOOST_PARAMETER_MAX_ARITY \ + , \ )) #include BOOST_PP_ITERATE() + }; +}} // namespace boost::parameter -}; +#include -} // namespace parameter - -} // namespace boost - -#endif // BOOST_PARAMETERS_031014_HPP +#endif // include guard diff --git a/include/boost/parameter/preprocessor.hpp b/include/boost/parameter/preprocessor.hpp index 8ea370c..1250f01 100644 --- a/include/boost/parameter/preprocessor.hpp +++ b/include/boost/parameter/preprocessor.hpp @@ -1,1077 +1,145 @@ -// Copyright Daniel Wallin 2006. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_PARAMETER_PREPROCESSOR_060206_HPP -# define BOOST_PARAMETER_PREPROCESSOR_060206_HPP +#define BOOST_PARAMETER_PREPROCESSOR_060206_HPP -# include -# include -# include +#include +#include +#include -# include -# include -# include - -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include - -# include - -# include -# include - -namespace boost { namespace parameter { namespace aux { - -# if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) - -// Given Match, which is "void x" where x is an argument matching -// criterion, extract a corresponding MPL predicate. -template -struct unwrap_predicate; - -// Match anything -template <> -struct unwrap_predicate -{ - typedef mpl::always type; -}; - -#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) - -typedef void* voidstar; - -// A matching predicate is explicitly specified -template -struct unwrap_predicate -{ - typedef Predicate type; -}; - -#else - -// A matching predicate is explicitly specified -template -struct unwrap_predicate -{ - typedef Predicate type; -}; - -#endif - - -// A type to which the argument is supposed to be convertible is -// specified -template -struct unwrap_predicate -{ - typedef is_convertible type; -}; - -// Recast the ParameterSpec's nested match metafunction as a free metafunction -template < - class Parameters - , BOOST_PP_ENUM_BINARY_PARAMS( - BOOST_PARAMETER_MAX_ARITY, class A, = boost::parameter::void_ BOOST_PP_INTERCEPT - ) -> -struct match - : Parameters::template match< - BOOST_PP_ENUM_PARAMS(BOOST_PARAMETER_MAX_ARITY, A) - > -{}; -# endif - -# undef false_ - -template < - class Parameters - , BOOST_PP_ENUM_BINARY_PARAMS( - BOOST_PARAMETER_MAX_ARITY, class A, = boost::parameter::void_ BOOST_PP_INTERCEPT - ) -> -struct argument_pack -{ - typedef typename make_arg_list< - typename BOOST_PARAMETER_build_arg_list( - BOOST_PARAMETER_MAX_ARITY, make_items, typename Parameters::parameter_spec, A - )::type - , typename Parameters::deduced_list - , tag_keyword_arg - , mpl::false_ - >::type result; - typedef typename mpl::first::type type; -}; - -// Works around VC6 problem where it won't accept rvalues. -template -T& as_lvalue(T& value, long) -{ - return value; -} - -template -T const& as_lvalue(T const& value, int) -{ - return value; -} - - -# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - -template -struct apply_predicate -{ - BOOST_MPL_ASSERT(( - mpl::and_ - )); - - typedef typename mpl::if_< - typename mpl::apply2::type - , char - , int - >::type type; -}; - -template -struct funptr_predicate -{ - static P p; - - template - static typename apply_predicate::type - check_predicate(type, Args*, void**(*)(P0)); - - template - static typename mpl::if_< - is_convertible - , char - , int - >::type check_predicate(type, Args*, void*(*)(P0)); - - template - struct apply - { - BOOST_STATIC_CONSTANT(bool, result = - sizeof(check_predicate(boost::type(), (Args*)0, &p)) == 1 - ); - - typedef mpl::bool_::result> type; - }; -}; - -template <> -struct funptr_predicate - : mpl::always -{}; - -# endif - -}}} // namespace boost::parameter::aux - -# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -// From Paul Mensonides -# define BOOST_PARAMETER_IS_NULLARY(x) \ - BOOST_PP_SPLIT(1, BOOST_PARAMETER_IS_NULLARY_C x BOOST_PP_COMMA() 0) \ - /**/ -# define BOOST_PARAMETER_IS_NULLARY_C() \ - ~, 1 BOOST_PP_RPAREN() \ - BOOST_PP_TUPLE_EAT(2) BOOST_PP_LPAREN() ~ \ - /**/ -# else -# define BOOST_PARAMETER_IS_NULLARY(x) BOOST_PP_IS_NULLARY(x) -# endif - -# define BOOST_PARAMETER_MEMBER_FUNCTION_CHECK_STATIC_static () -# define BOOST_PARAMETER_MEMBER_FUNCTION_IS_STATIC(name) \ - BOOST_PARAMETER_IS_NULLARY( \ - BOOST_PP_CAT(BOOST_PARAMETER_MEMBER_FUNCTION_CHECK_STATIC_,name) \ - ) - -# if !defined(BOOST_MSVC) -# define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_static -# define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC(name) \ - BOOST_PP_CAT(BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_, name) -# else -// Workaround for MSVC preprocessor. -// -// When stripping static from "static f", msvc will produce -// " f". The leading whitespace doesn't go away when pasting -// the token with something else, so this thing is a hack to -// strip the whitespace. -# define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_static ( -# define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_AUX(name) \ - BOOST_PP_CAT(BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_, name)) -# define BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC(name) \ - BOOST_PP_SEQ_HEAD( \ - BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC_AUX(name) \ - ) -# endif - -# define BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(name) \ - BOOST_PP_EXPR_IF( \ - BOOST_PARAMETER_MEMBER_FUNCTION_IS_STATIC(name) \ - , static \ - ) - -# define BOOST_PARAMETER_MEMBER_FUNCTION_NAME(name) \ - BOOST_PP_IF( \ - BOOST_PARAMETER_MEMBER_FUNCTION_IS_STATIC(name) \ - , BOOST_PARAMETER_MEMBER_FUNCTION_STRIP_STATIC \ - , name BOOST_PP_TUPLE_EAT(1) \ - )(name) - -// Calculates [begin, end) arity range. - -# define BOOST_PARAMETER_ARITY_RANGE_M_optional(state) state -# define BOOST_PARAMETER_ARITY_RANGE_M_deduced_optional(state) state -# define BOOST_PARAMETER_ARITY_RANGE_M_required(state) BOOST_PP_INC(state) -# define BOOST_PARAMETER_ARITY_RANGE_M_deduced_required(state) BOOST_PP_INC(state) - -# define BOOST_PARAMETER_ARITY_RANGE_M(s, state, x) \ - BOOST_PP_CAT( \ - BOOST_PARAMETER_ARITY_RANGE_M_ \ - , BOOST_PARAMETER_FN_ARG_QUALIFIER(x) \ - )(state) +// Helper macro for BOOST_PARAMETER_CONSTRUCTOR. +#define BOOST_PARAMETER_CONSTRUCTOR_AUX(class_, base, tag_namespace, args) \ + BOOST_PARAMETER_SPECIFICATION(tag_namespace, ctor, args) \ + BOOST_PP_CAT(constructor_parameters, __LINE__); \ + BOOST_PARAMETER_CONSTRUCTOR_OVERLOADS(class_, base, args) /**/ -# define BOOST_PARAMETER_ARITY_RANGE(args) \ - ( \ - BOOST_PP_SEQ_FOLD_LEFT(BOOST_PARAMETER_ARITY_RANGE_M, 0, args) \ - , BOOST_PP_INC(BOOST_PP_SEQ_SIZE(args)) \ - ) +#include + +// Defines the implementation function header. +#define BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name) \ + template \ + typename BOOST_PARAMETER_FUNCTION_RESULT_NAME(name)< \ + Args \ + >::type BOOST_PARAMETER_FUNCTION_IMPL_NAME(name)(Args const& args) /**/ -// Accessor macros for the argument specs tuple. -# define BOOST_PARAMETER_FN_ARG_QUALIFIER(x) \ - BOOST_PP_TUPLE_ELEM(4,0,x) +#include + +// Expands to the result metafunction and the parameters specialization. +#define BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \ + template \ + struct BOOST_PARAMETER_FUNCTION_RESULT_NAME(name) \ + { \ + typedef typename BOOST_PARAMETER_PARENTHESIZED_TYPE(result) type; \ + }; \ + BOOST_PARAMETER_SPECIFICATION(tag_namespace, name, args) \ + BOOST_PARAMETER_FUNCTION_SPECIFICATION_NAME(name); /**/ -# define BOOST_PARAMETER_FN_ARG_NAME(x) \ - BOOST_PP_TUPLE_ELEM(4,1,x) -/**/ - -# define BOOST_PARAMETER_FN_ARG_PRED(x) \ - BOOST_PP_TUPLE_ELEM(4,2,x) -/**/ - -# define BOOST_PARAMETER_FN_ARG_DEFAULT(x) \ - BOOST_PP_TUPLE_ELEM(4,3,x) -/**/ - -# define BOOST_PARAMETETER_FUNCTION_EAT_KEYWORD_QUALIFIER_out(x) -# define BOOST_PARAMETETER_FUNCTION_EAT_KEYWORD_QUALIFIER_in_out(x) - -// Returns 1 if x is either "out(k)" or "in_out(k)". -# define BOOST_PARAMETER_FUNCTION_IS_KEYWORD_QUALIFIER(x) \ - BOOST_PP_IS_EMPTY( \ - BOOST_PP_CAT(BOOST_PARAMETETER_FUNCTION_EAT_KEYWORD_QUALIFIER_, x) \ - ) \ -/**/ - -# define BOOST_PARAMETETER_FUNCTION_GET_KEYWORD_QUALIFIER_out(x) x -# define BOOST_PARAMETETER_FUNCTION_GET_KEYWORD_QUALIFIER_in_out(x) x -# define BOOST_PARAMETER_FUNCTION_KEYWORD_GET(x) \ - BOOST_PP_CAT(BOOST_PARAMETETER_FUNCTION_GET_KEYWORD_QUALIFIER_, x) -/**/ - -// Returns the keyword of x, where x is either a keyword qualifier -// or a keyword. -// -// k => k -// out(k) => k -// in_out(k) => k -// -# define BOOST_PARAMETER_FUNCTION_KEYWORD(x) \ - BOOST_PP_IF( \ - BOOST_PARAMETER_FUNCTION_IS_KEYWORD_QUALIFIER(x) \ - , BOOST_PARAMETER_FUNCTION_KEYWORD_GET \ - , x BOOST_PP_TUPLE_EAT(1) \ - )(x) -/**/ - -# define BOOST_PARAMETER_FN_ARG_KEYWORD(x) \ - BOOST_PARAMETER_FUNCTION_KEYWORD( \ - BOOST_PARAMETER_FN_ARG_NAME(x) \ - ) - -// Builds forwarding functions. - -# define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_TEMPLATE_Z(z, n) \ - template -/**/ - -# if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) -# define BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z(z, name, parameters, n) \ - , typename boost::parameter::aux::match< \ - parameters, BOOST_PP_ENUM_PARAMS(n, ParameterArgumentType) \ - >::type = parameters() -# else -# define BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z(z, name, parameters, n) -# endif -/**/ - -# define BOOST_PARAMETER_FUNCTION_PARAMETERS_NAME(base) \ - BOOST_PP_CAT( \ - boost_param_parameters_ \ - , BOOST_PP_CAT(__LINE__, BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base)) \ - ) - -// Produce a name for a result type metafunction for the function -// named base -# define BOOST_PARAMETER_FUNCTION_RESULT_NAME(base) \ - BOOST_PP_CAT( \ - boost_param_result_ \ - , BOOST_PP_CAT(__LINE__,BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base)) \ - ) - -// Can't do boost_param_impl_ ## basee because base might start with an underscore -// daniel: what? how is that relevant? the reason for using CAT() is to make sure -// base is expanded. i'm not sure we need to here, but it's more stable to do it. -# define BOOST_PARAMETER_IMPL(base) \ - BOOST_PP_CAT(boost_param_impl,BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base)) - -# define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION00(z, n, r, data, elem) \ - BOOST_PP_IF( \ - n \ - , BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_TEMPLATE_Z, BOOST_PP_TUPLE_EAT(2) \ - )(z,n) \ - BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(BOOST_PP_TUPLE_ELEM(7,3,data)) \ - inline \ - BOOST_PP_EXPR_IF(n, typename) \ - BOOST_PARAMETER_FUNCTION_RESULT_NAME(BOOST_PP_TUPLE_ELEM(7,3,data))< \ - BOOST_PP_EXPR_IF(n, typename) \ - boost::parameter::aux::argument_pack< \ - BOOST_PARAMETER_FUNCTION_PARAMETERS_NAME(BOOST_PP_TUPLE_ELEM(7,3,data)) \ - BOOST_PP_COMMA_IF(n) \ - BOOST_PP_IF( \ - n, BOOST_PP_SEQ_ENUM, BOOST_PP_TUPLE_EAT(1) \ - )(elem) \ - >::type \ - >::type \ - BOOST_PARAMETER_MEMBER_FUNCTION_NAME(BOOST_PP_TUPLE_ELEM(7,3,data))( \ - BOOST_PP_IF( \ - n \ - , BOOST_PP_SEQ_FOR_EACH_I_R \ - , BOOST_PP_TUPLE_EAT(4) \ - )( \ - r \ - , BOOST_PARAMETER_FUNCTION_ARGUMENT \ - , ~ \ - , elem \ - ) \ - BOOST_PP_IF(n, BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z, BOOST_PP_TUPLE_EAT(4))( \ - z \ - , BOOST_PP_TUPLE_ELEM(7,3,data) \ - , BOOST_PARAMETER_FUNCTION_PARAMETERS_NAME(BOOST_PP_TUPLE_ELEM(7,3,data)) \ - , n \ - ) \ - ) BOOST_PP_EXPR_IF(BOOST_PP_TUPLE_ELEM(7,4,data), const) \ - { \ - return BOOST_PARAMETER_IMPL(BOOST_PP_TUPLE_ELEM(7,3,data))( \ - BOOST_PARAMETER_FUNCTION_PARAMETERS_NAME(BOOST_PP_TUPLE_ELEM(7,3,data))()( \ - BOOST_PP_ENUM_PARAMS_Z(z, n, a) \ - ) \ - ); \ - } -/**/ - -# define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION0(r, data, elem) \ - BOOST_PARAMETER_FUNCTION_FWD_FUNCTION00( \ - BOOST_PP_TUPLE_ELEM(7,0,data) \ - , BOOST_PP_TUPLE_ELEM(7,1,data) \ - , r \ - , data \ - , elem \ - ) -/**/ - -# define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_ARITY_0(z, n, data) \ - BOOST_PARAMETER_FUNCTION_FWD_FUNCTION00( \ - z, n, BOOST_PP_DEDUCE_R() \ - , (z, n, BOOST_PP_TUPLE_REM(5) data) \ - , ~ \ - ) -/**/ - -# define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_ARITY_N(z, n, data) \ - BOOST_PP_SEQ_FOR_EACH( \ - BOOST_PARAMETER_FUNCTION_FWD_FUNCTION0 \ - , (z, n, BOOST_PP_TUPLE_REM(5) data) \ - , BOOST_PP_SEQ_FOR_EACH_PRODUCT( \ - BOOST_PARAMETER_FUNCTION_FWD_PRODUCT \ - , BOOST_PP_SEQ_FIRST_N( \ - n, BOOST_PP_TUPLE_ELEM(5,3,data) \ - ) \ - ) \ - ) -/**/ - -# define BOOST_PARAMETER_FUNCTION_FWD_FUNCTION(z, n, data) \ - BOOST_PP_IF( \ - n \ - , BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_ARITY_N \ - , BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_ARITY_0 \ - )(z,n,data) \ -/**/ - -# define BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS0( \ - result,name,args,const_,combinations,range \ -) \ - BOOST_PP_REPEAT_FROM_TO( \ - BOOST_PP_TUPLE_ELEM(2,0,range), BOOST_PP_TUPLE_ELEM(2,1,range) \ - , BOOST_PARAMETER_FUNCTION_FWD_FUNCTION \ - , (result,name,const_,combinations,BOOST_PP_TUPLE_ELEM(2,1,range)) \ - ) -/**/ - -# define BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS(result,name,args, const_, combinations) \ - BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS0( \ - result, name, args, const_, combinations, BOOST_PARAMETER_ARITY_RANGE(args) \ - ) -/**/ - -// Builds boost::parameter::parameters<> specialization -# define BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_optional(tag) \ - optional - -# define BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_deduced_required(tag) \ - required - -# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) - -# define BOOST_PARAMETER_FUNCTION_PARAMETERS_M(r,tag_namespace,i,elem) \ - BOOST_PP_COMMA_IF(i) \ - boost::parameter::BOOST_PP_CAT( \ - BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_ \ - , BOOST_PARAMETER_FN_ARG_QUALIFIER(elem) \ - )( \ - tag_namespace::BOOST_PARAMETER_FUNCTION_KEYWORD( \ - BOOST_PARAMETER_FN_ARG_KEYWORD(elem) \ - ) \ - ) \ - , typename boost::parameter::aux::unwrap_predicate< \ - void BOOST_PARAMETER_FN_ARG_PRED(elem) \ - >::type \ - > -# elif BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -# define BOOST_PARAMETER_FUNCTION_PARAMETERS_M(r,tag_namespace,i,elem) \ - BOOST_PP_COMMA_IF(i) \ - boost::parameter::BOOST_PP_CAT( \ - BOOST_PARAMETER_FUNCTION_PARAMETERS_QUALIFIER_ \ - , BOOST_PARAMETER_FN_ARG_QUALIFIER(elem) \ - )( \ - tag_namespace::BOOST_PARAMETER_FUNCTION_KEYWORD( \ - BOOST_PARAMETER_FN_ARG_KEYWORD(elem) \ - ) \ - ) \ - , boost::mpl::always \ - > -# endif - -# define BOOST_PARAMETER_FUNCTION_PARAMETERS(tag_namespace, base, args) \ - template \ - struct BOOST_PP_CAT( \ - BOOST_PP_CAT(boost_param_params_, __LINE__) \ - , BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base) \ - ) : boost::parameter::parameters< \ - BOOST_PP_SEQ_FOR_EACH_I( \ - BOOST_PARAMETER_FUNCTION_PARAMETERS_M, tag_namespace, args \ - ) \ - > \ - {}; \ - \ - typedef BOOST_PP_CAT( \ - BOOST_PP_CAT(boost_param_params_, __LINE__) \ - , BOOST_PARAMETER_MEMBER_FUNCTION_NAME(base) \ - ) - -// Defines result type metafunction -# define BOOST_PARAMETER_FUNCTION_RESULT_ARG(z, _, i, x) \ - BOOST_PP_COMMA_IF(i) class BOOST_PP_TUPLE_ELEM(3,1,x) -/**/ - -# define BOOST_PARAMETER_FUNCTION_RESULT_(result, name, args) \ - template \ - struct BOOST_PARAMETER_FUNCTION_RESULT_NAME(name) \ - { \ - typedef typename BOOST_PARAMETER_PARENTHESIZED_TYPE(result) type; \ - }; - -// Defines implementation function -# define BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name) \ - template \ - typename BOOST_PARAMETER_FUNCTION_RESULT_NAME(name)< \ - Args \ - >::type BOOST_PARAMETER_IMPL(name)(Args const& args) - -# define BOOST_PARAMETER_FUNCTION_IMPL_FWD(name) \ - BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name); -/**/ - -# define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_required(state, arg) \ - ( \ - BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(4, 0, state)) \ - , BOOST_PP_SEQ_PUSH_BACK(BOOST_PP_TUPLE_ELEM(4, 1, state), arg) \ - , BOOST_PP_TUPLE_ELEM(4, 2, state) \ - , BOOST_PP_TUPLE_ELEM(4, 3, state) \ - ) - -# define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_deduced_required(state, arg) \ - BOOST_PARAMETER_FUNCTION_SPLIT_ARG_required(state, arg) - -# define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_optional(state, arg) \ - ( \ - BOOST_PP_TUPLE_ELEM(4, 0, state) \ - , BOOST_PP_TUPLE_ELEM(4, 1, state) \ - , BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(4, 2, state)) \ - , BOOST_PP_SEQ_PUSH_BACK(BOOST_PP_TUPLE_ELEM(4, 3, state), arg) \ - ) - -# define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_deduced_optional(state, arg) \ - BOOST_PARAMETER_FUNCTION_SPLIT_ARG_optional(state, arg) - -# define BOOST_PARAMETER_FUNCTION_SPLIT_ARG(s, state, arg) \ - BOOST_PP_CAT( \ - BOOST_PARAMETER_FUNCTION_SPLIT_ARG_ \ - , BOOST_PARAMETER_FN_ARG_QUALIFIER(arg) \ - )(state, arg) - -// Returns (required_count, required, optional_count, optionals) tuple -# define BOOST_PARAMETER_FUNCTION_SPLIT_ARGS(args) \ - BOOST_PP_SEQ_FOLD_LEFT( \ - BOOST_PARAMETER_FUNCTION_SPLIT_ARG \ - , (0,BOOST_PP_SEQ_NIL, 0,BOOST_PP_SEQ_NIL) \ - , args \ - ) - -# define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG_NAME(keyword) \ - BOOST_PP_CAT(BOOST_PP_CAT(keyword,_),type) - -// Helpers used as parameters to BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS. -# define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_TEMPLATE_ARG(r, _, arg) \ - , class BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG_NAME( \ - BOOST_PARAMETER_FN_ARG_KEYWORD(arg) \ - ) - -# define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG(r, _, arg) \ - , BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG_NAME( \ - BOOST_PARAMETER_FN_ARG_KEYWORD(arg) \ - )& BOOST_PARAMETER_FN_ARG_KEYWORD(arg) - -# define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_PARAMETER(r, _, arg) \ - , BOOST_PARAMETER_FN_ARG_KEYWORD(arg) - -// Produces a name for the dispatch functions. -# define BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name) \ - BOOST_PP_CAT( \ - boost_param_default_ \ - , BOOST_PP_CAT(__LINE__, BOOST_PARAMETER_MEMBER_FUNCTION_NAME(name)) \ - ) - -// Helper macro used below to produce lists based on the keyword argument -// names. macro is applied to every element. n is the number of -// optional arguments that should be included. -# define BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS(macro, n, split_args) \ - BOOST_PP_SEQ_FOR_EACH( \ - macro \ - , ~ \ - , BOOST_PP_TUPLE_ELEM(4,1,split_args) \ - ) \ - BOOST_PP_SEQ_FOR_EACH( \ - macro \ - , ~ \ - , BOOST_PP_SEQ_FIRST_N( \ - BOOST_PP_SUB(BOOST_PP_TUPLE_ELEM(4,2,split_args), n) \ - , BOOST_PP_TUPLE_ELEM(4,3,split_args) \ - ) \ - ) - -// Generates a keyword | default expression. -# define BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_DEFAULT(arg, tag_namespace) \ - boost::parameter::keyword< \ - tag_namespace::BOOST_PARAMETER_FN_ARG_KEYWORD(arg) \ - >::instance | boost::parameter::aux::use_default_tag() - -# define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_GET_ARG(arg, tag_ns) \ - BOOST_PARAMETER_FUNCTION_CAST( \ - args[ \ - BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_DEFAULT( \ - arg, tag_ns \ - ) \ - ] \ - , BOOST_PARAMETER_FN_ARG_PRED(arg) \ - , Args \ - ) - -# define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_BODY(name, n, split_args, tag_namespace) \ - { \ - return BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name)( \ - (ResultType(*)())0 \ - , args \ - , 0L \ - BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ - BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_PARAMETER \ - , n \ - , split_args \ - ) \ - , BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_GET_ARG( \ - BOOST_PP_SEQ_ELEM( \ - BOOST_PP_SUB(BOOST_PP_TUPLE_ELEM(4,2,split_args), n) \ - , BOOST_PP_TUPLE_ELEM(4,3,split_args) \ - ) \ - , tag_namespace \ - ) \ - ); \ - } - -# define BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_ACTUAL_DEFAULT(arg) \ - BOOST_PARAMETER_FUNCTION_CAST( \ - boost::parameter::aux::as_lvalue(BOOST_PARAMETER_FN_ARG_DEFAULT(arg), 0L) \ - , BOOST_PARAMETER_FN_ARG_PRED(arg) \ - , Args \ - ) - -# define BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_DEFAULT_BODY(name, n, split_args, tag_ns, const_) \ - template < \ - class ResultType \ - , class Args \ - BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ - BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_TEMPLATE_ARG \ - , BOOST_PP_INC(n) \ - , split_args \ - ) \ - > \ - BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(name) \ - ResultType BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name)( \ - ResultType(*)() \ - , Args const& args \ - , long \ - BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ - BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG \ - , BOOST_PP_INC(n) \ - , split_args \ - ) \ - , boost::parameter::aux::use_default_tag \ - ) BOOST_PP_EXPR_IF(const_, const) \ - { \ - return BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name)( \ - (ResultType(*)())0 \ - , args \ - , 0L \ - BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ - BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_PARAMETER \ - , BOOST_PP_INC(n) \ - , split_args \ - ) \ - , BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_ACTUAL_DEFAULT( \ - BOOST_PP_SEQ_ELEM( \ - BOOST_PP_SUB(BOOST_PP_TUPLE_ELEM(4,2,split_args), BOOST_PP_INC(n)) \ - , BOOST_PP_TUPLE_ELEM(4,3,split_args) \ - ) \ - ) \ - ); \ - } - -// Produces a forwarding layer in the default evaluation machine. -// -// data is a tuple: -// -// (name, split_args) -// -// Where name is the base name of the function, and split_args is a tuple: -// -// (required_count, required_args, optional_count, required_args) -// - - -// defines the actual function body for BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION below. -# define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION0(z, n, data) \ - template < \ - class ResultType \ - , class Args \ - BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ - BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_TEMPLATE_ARG \ - , n \ - , BOOST_PP_TUPLE_ELEM(5,1,data) \ - ) \ - > \ - BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(BOOST_PP_TUPLE_ELEM(5,0,data)) \ - ResultType BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(BOOST_PP_TUPLE_ELEM(5,0,data))( \ - ResultType(*)() \ - , Args const& args \ - , int \ - BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ - BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG \ - , n \ - , BOOST_PP_TUPLE_ELEM(5,1,data) \ - ) \ - ) BOOST_PP_EXPR_IF(BOOST_PP_TUPLE_ELEM(5,2,data), const) \ - BOOST_PP_IF( \ - n \ - , BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_BODY \ - , ; BOOST_PP_TUPLE_EAT(4) \ - )( \ - BOOST_PP_TUPLE_ELEM(5,0,data) \ - , n \ - , BOOST_PP_TUPLE_ELEM(5,1,data) \ - , BOOST_PP_TUPLE_ELEM(5,3,data) \ - ) - -# define BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION(z, n, data) \ - BOOST_PP_IF( \ - BOOST_PP_AND( \ - BOOST_PP_NOT(n) \ - , BOOST_PP_TUPLE_ELEM(5,4,data) \ - ) \ - , BOOST_PP_TUPLE_EAT(3) \ - , BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION0 \ - )(z, n, data) \ - BOOST_PP_IF( \ - BOOST_PP_EQUAL(n, BOOST_PP_TUPLE_ELEM(4,2,BOOST_PP_TUPLE_ELEM(5,1,data))) \ - , BOOST_PP_TUPLE_EAT(5) \ - , BOOST_PARAMETER_FUNCTION_DEFAULT_EVAL_DEFAULT_BODY \ - )( \ - BOOST_PP_TUPLE_ELEM(5,0,data) \ - , n \ - , BOOST_PP_TUPLE_ELEM(5,1,data) \ - , BOOST_PP_TUPLE_ELEM(5,3,data) \ - , BOOST_PP_TUPLE_ELEM(5,2,data) \ - ) - -# define BOOST_PARAMETER_FUNCTION_DEFAULT_GET_ARG(r, tag_ns, arg) \ - , BOOST_PARAMETER_FUNCTION_CAST( \ - args[ \ - boost::parameter::keyword::instance \ - ] \ - , BOOST_PARAMETER_FN_ARG_PRED(arg) \ - , Args \ - ) - -// Generates the function template that recives a ArgumentPack, and then -// goes on to call the layers of overloads generated by -// BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER. -# define BOOST_PARAMETER_FUNCTION_INITIAL_DISPATCH_FUNCTION(name, split_args, const_, tag_ns) \ - template \ - typename BOOST_PARAMETER_FUNCTION_RESULT_NAME(name)::type \ - BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(name) \ - BOOST_PARAMETER_IMPL(name)(Args const& args) BOOST_PP_EXPR_IF(const_, const) \ - { \ - return BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name)( \ - (typename BOOST_PARAMETER_FUNCTION_RESULT_NAME(name)::type(*)())0 \ - , args \ - , 0L \ - \ - BOOST_PP_SEQ_FOR_EACH( \ - BOOST_PARAMETER_FUNCTION_DEFAULT_GET_ARG \ - , tag_ns \ - , BOOST_PP_TUPLE_ELEM(4,1,split_args) \ - ) \ - \ - ); \ - } - -// Helper for BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER below. -# define BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER_AUX( \ - name, split_args, skip_fwd_decl, const_, tag_namespace \ - ) \ - BOOST_PP_REPEAT_FROM_TO( \ - 0 \ - , BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(4, 2, split_args)) \ - , BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION \ - , (name, split_args, const_, tag_namespace, skip_fwd_decl) \ - ) \ - \ - BOOST_PARAMETER_FUNCTION_INITIAL_DISPATCH_FUNCTION(name, split_args, const_, tag_namespace) \ -\ - template < \ - class ResultType \ - , class Args \ - BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ - BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_TEMPLATE_ARG \ - , 0 \ - , split_args \ - ) \ - > \ - BOOST_PARAMETER_MEMBER_FUNCTION_STATIC(name) \ - ResultType BOOST_PARAMETER_FUNCTION_DEFAULT_NAME(name)( \ - ResultType(*)() \ - , Args const& \ - , int \ - BOOST_PARAMETER_FUNCTION_DEFAULT_ARGUMENTS( \ - BOOST_PARAMETER_FUNCTION_DEFAULT_FUNCTION_ARG \ - , 0 \ - , split_args \ - ) \ - ) BOOST_PP_EXPR_IF(const_, const) - -// Generates a bunch of forwarding functions that each extract -// one more argument. -# define BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER(name, args, skip_fwd_decl, const_, tag_ns) \ - BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER_AUX( \ - name, BOOST_PARAMETER_FUNCTION_SPLIT_ARGS(args), skip_fwd_decl, const_, tag_ns \ - ) -/**/ - -// Defines the result metafunction and the parameters specialization. -# define BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \ - BOOST_PARAMETER_FUNCTION_RESULT_(result, name, args) \ - \ - BOOST_PARAMETER_FUNCTION_PARAMETERS(tag_namespace, name, args) \ - BOOST_PARAMETER_FUNCTION_PARAMETERS_NAME(name); \ - -// Helper for BOOST_PARAMETER_FUNCTION below. -# define BOOST_PARAMETER_FUNCTION_AUX(result, name, tag_namespace, args) \ - BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \ - BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name); \ -\ - BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS( \ - result, name, args, 0 \ - , BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ - ) \ - \ - BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER(name, args, 0, 0, tag_namespace) - -// Defines a Boost.Parameter enabled function with the new syntax. -# define BOOST_PARAMETER_FUNCTION(result, name, tag_namespace, args) \ - BOOST_PARAMETER_FUNCTION_AUX( \ - result, name, tag_namespace \ - , BOOST_PARAMETER_FLATTEN(3, 2, 3, args) \ - ) \ -/**/ - -// Defines a Boost.Parameter enabled function. -# define BOOST_PARAMETER_BASIC_FUNCTION_AUX(result, name, tag_namespace, args) \ - BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \ - \ - BOOST_PARAMETER_FUNCTION_IMPL_FWD(name) \ - \ - BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS( \ - result, name, args, 0 \ - , BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ - ) \ - \ +// Helper macro for BOOST_PARAMETER_BASIC_FUNCTION. +#define BOOST_PARAMETER_BASIC_FUNCTION_AUX(result, name, tag_ns, args) \ + BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_ns, args) \ + BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name); \ + BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOADS(name, name, args, 0) \ BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name) - -# define BOOST_PARAMETER_BASIC_FUNCTION(result, name, tag_namespace, args) \ - BOOST_PARAMETER_BASIC_FUNCTION_AUX( \ - result, name, tag_namespace \ - , BOOST_PARAMETER_FLATTEN(2, 2, 3, args) \ - ) \ /**/ -// Defines a Boost.Parameter enabled member function. -# define BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX(result, name, tag_namespace, args, const_) \ - BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \ - \ - BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS( \ - result, name, args, const_ \ - , BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ - ) \ - \ - BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name) BOOST_PP_EXPR_IF(const_, const) \ +#include + +// Helper macro for BOOST_PARAMETER_BASIC_MEMBER_FUNCTION +// and BOOST_PARAMETER_BASIC_CONST_MEMBER_FUNCTION. +#define BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX(r, name, tag_ns, args, c) \ + BOOST_PARAMETER_FUNCTION_HEAD(r, name, tag_ns, args) \ + BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOADS(name, name, args, c) \ + BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name) BOOST_PP_EXPR_IF(c, const) /**/ -# define BOOST_PARAMETER_BASIC_MEMBER_FUNCTION(result, name, tag_namespace, args) \ - BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX( \ - result, name, tag_namespace \ - , BOOST_PARAMETER_FLATTEN(2, 2, 3, args) \ - , 0 \ +#include + +// Expands to a Boost.Parameter-enabled constructor header. All arguments are +// accessible via args and keywords only. +#define BOOST_PARAMETER_CONSTRUCTOR(class_, base, tag_namespace, args) \ + BOOST_PARAMETER_CONSTRUCTOR_AUX( \ + class_, base, tag_namespace, BOOST_PARAMETER_FLATTEN(2, 2, 3, args) \ ) /**/ -# define BOOST_PARAMETER_BASIC_CONST_MEMBER_FUNCTION(result, name, tag_namespace, args) \ - BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX( \ - result, name, tag_namespace \ - , BOOST_PARAMETER_FLATTEN(2, 2, 3, args) \ - , 1 \ +// Expands to a Boost.Parameter-enabled function header. All arguments are +// accessible via args and keywords only. +#define BOOST_PARAMETER_BASIC_FUNCTION(result, name, tag_namespace, args) \ + BOOST_PARAMETER_BASIC_FUNCTION_AUX( \ + result, name, tag_namespace, BOOST_PARAMETER_FLATTEN(2, 2, 3, args) \ ) /**/ - - -# define BOOST_PARAMETER_MEMBER_FUNCTION_AUX(result, name, tag_namespace, const_, args) \ - BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_namespace, args) \ -\ - BOOST_PARAMETER_FUNCTION_FWD_FUNCTIONS( \ - result, name, args, const_ \ - , BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ - ) \ - \ - BOOST_PARAMETER_FUNCTION_DEFAULT_LAYER(name, args, 1, const_, tag_namespace) - -// Defines a Boost.Parameter enabled function with the new syntax. -# define BOOST_PARAMETER_MEMBER_FUNCTION(result, name, tag_namespace, args) \ - BOOST_PARAMETER_MEMBER_FUNCTION_AUX( \ - result, name, tag_namespace, 0 \ - , BOOST_PARAMETER_FLATTEN(3, 2, 3, args) \ - ) \ -/**/ - -# define BOOST_PARAMETER_CONST_MEMBER_FUNCTION(result, name, tag_namespace, args) \ - BOOST_PARAMETER_MEMBER_FUNCTION_AUX( \ - result, name, tag_namespace, 1 \ - , BOOST_PARAMETER_FLATTEN(3, 2, 3, args) \ - ) \ -/**/ - -// Defines a Boost.Parameter enabled constructor. - -# define BOOST_PARAMETER_FUNCTION_ARGUMENT(r, _, i, elem) \ - BOOST_PP_COMMA_IF(i) elem& BOOST_PP_CAT(a, i) -/**/ - -# define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR00(z, n, r, data, elem) \ - BOOST_PP_IF( \ - n \ - , BOOST_PARAMETER_FUNCTION_FWD_FUNCTION_TEMPLATE_Z, BOOST_PP_TUPLE_EAT(2) \ - )(z, n) \ - BOOST_PP_EXPR_IF(BOOST_PP_EQUAL(n,1), explicit) \ - BOOST_PP_TUPLE_ELEM(6,2,data)( \ - BOOST_PP_IF( \ - n \ - , BOOST_PP_SEQ_FOR_EACH_I_R \ - , BOOST_PP_TUPLE_EAT(4) \ - )( \ - r \ - , BOOST_PARAMETER_FUNCTION_ARGUMENT \ - , ~ \ - , elem \ - ) \ - BOOST_PP_IF(n, BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z, BOOST_PP_TUPLE_EAT(4))( \ - z \ - , BOOST_PP_TUPLE_ELEM(6,3,data) \ - , BOOST_PP_CAT(constructor_parameters, __LINE__) \ - , n \ - ) \ - ) \ - : BOOST_PARAMETER_PARENTHESIZED_TYPE(BOOST_PP_TUPLE_ELEM(6,3,data)) ( \ - BOOST_PP_CAT(constructor_parameters, __LINE__)()( \ - BOOST_PP_ENUM_PARAMS_Z(z, n, a) \ - ) \ - ) \ - {} -/**/ - -# define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR0(r, data, elem) \ - BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR00( \ - BOOST_PP_TUPLE_ELEM(6,0,data) \ - , BOOST_PP_TUPLE_ELEM(6,1,data) \ - , r \ - , data \ - , elem \ +// Expands to a Boost.Parameter-enabled member function header. All arguments +// are accessible via args and keywords only. +#define BOOST_PARAMETER_BASIC_MEMBER_FUNCTION(result, name, tag_ns, args) \ + BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX( \ + result, name, tag_ns, BOOST_PARAMETER_FLATTEN(2, 2, 3, args), 0 \ ) /**/ -# define BOOST_PARAMETER_FUNCTION_FWD_PRODUCT(r, product) \ - (product) -/**/ - -# define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR_ARITY_0(z, n, data) \ - BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR00( \ - z, n, BOOST_PP_DEDUCE_R() \ - , (z, n, BOOST_PP_TUPLE_REM(4) data) \ - , ~ \ +// Expands to a Boost.Parameter-enabled const-qualified member function +// header. All arguments are accessible via args and keywords only. +#define BOOST_PARAMETER_BASIC_CONST_MEMBER_FUNCTION(r, name, tag_ns, args) \ + BOOST_PARAMETER_BASIC_MEMBER_FUNCTION_AUX( \ + r, name, tag_ns, BOOST_PARAMETER_FLATTEN(2, 2, 3, args), 1 \ ) /**/ -# define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR_ARITY_N(z, n, data) \ - BOOST_PP_SEQ_FOR_EACH( \ - BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR0 \ - , (z, n, BOOST_PP_TUPLE_REM(4) data) \ - , BOOST_PP_SEQ_FOR_EACH_PRODUCT( \ - BOOST_PARAMETER_FUNCTION_FWD_PRODUCT \ - , BOOST_PP_SEQ_FIRST_N( \ - n, BOOST_PP_TUPLE_ELEM(4,2,data) \ - ) \ - ) \ +#include + +// Helper macro for BOOST_PARAMETER_FUNCTION. +#define BOOST_PARAMETER_FUNCTION_AUX(result, name, tag_ns, args) \ + BOOST_PARAMETER_FUNCTION_HEAD(result, name, tag_ns, args) \ + BOOST_PARAMETER_FUNCTION_IMPL_HEAD(name); \ + BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOADS(name, name, args, 0) \ + BOOST_PARAMETER_FUNCTION_DISPATCH_LAYER( \ + 1, (name, BOOST_PARAMETER_FUNCTION_SPLIT_ARGS(args), 0, tag_ns) \ ) /**/ -# define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR(z, n, data) \ - BOOST_PP_IF( \ - n \ - , BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR_ARITY_N \ - , BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR_ARITY_0 \ - )(z,n,data) \ -/**/ - -# define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTORS0(class_,base,args,combinations,range) \ - BOOST_PP_REPEAT_FROM_TO( \ - BOOST_PP_TUPLE_ELEM(2,0,range), BOOST_PP_TUPLE_ELEM(2,1,range) \ - , BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTOR \ - , (class_,base,combinations,BOOST_PP_TUPLE_ELEM(2,1,range)) \ +// Expands to a Boost.Parameter-enabled function header. All arguments are +// accessible via args and keywords, as well as by name. +#define BOOST_PARAMETER_FUNCTION(result, name, tag_namespace, args) \ + BOOST_PARAMETER_FUNCTION_AUX( \ + result, name, tag_namespace, BOOST_PARAMETER_FLATTEN(3, 2, 3, args) \ ) /**/ -# define BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTORS(class_,base,args,combinations) \ - BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTORS0( \ - class_, base, args, combinations, BOOST_PARAMETER_ARITY_RANGE(args) \ +// Helper macro for BOOST_PARAMETER_MEMBER_FUNCTION and +// BOOST_PARAMETER_CONST_MEMBER_FUNCTION. +#define BOOST_PARAMETER_MEMBER_FUNCTION_AUX(r, name, impl, tag_ns, c, args) \ + BOOST_PARAMETER_FUNCTION_HEAD(r, impl, tag_ns, args) \ + BOOST_PARAMETER_FUNCTION_FORWARD_OVERLOADS(name, impl, args, c) \ + BOOST_PARAMETER_FUNCTION_DISPATCH_LAYER( \ + 0, (impl, BOOST_PARAMETER_FUNCTION_SPLIT_ARGS(args), c, tag_ns) \ ) /**/ -# define BOOST_PARAMETER_CONSTRUCTOR_AUX(class_, base, tag_namespace, args) \ - BOOST_PARAMETER_FUNCTION_PARAMETERS(tag_namespace, ctor, args) \ - BOOST_PP_CAT(constructor_parameters, __LINE__); \ -\ - BOOST_PARAMETER_FUNCTION_FWD_CONSTRUCTORS( \ - class_, base, args \ - , BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ - ) \ -/**/ - -# define BOOST_PARAMETER_CONSTRUCTOR(class_, base, tag_namespace, args) \ - BOOST_PARAMETER_CONSTRUCTOR_AUX( \ - class_, base, tag_namespace \ - , BOOST_PARAMETER_FLATTEN(2, 2, 3, args) \ +// Expands to a Boost.Parameter-enabled member function header. All +// arguments are accessible via args and keywords, as well as by name. +#define BOOST_PARAMETER_MEMBER_FUNCTION(result, name, tag_ns, args) \ + BOOST_PARAMETER_MEMBER_FUNCTION_AUX( \ + result, name, name, tag_ns, 0 \ + , BOOST_PARAMETER_FLATTEN(3, 2, 3, args) \ ) /**/ -# ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING -# define BOOST_PARAMETER_FUNCTION_FWD_COMBINATION(r, _, i, elem) \ - (BOOST_PP_IF( \ - BOOST_PARAMETER_FUNCTION_IS_KEYWORD_QUALIFIER( \ - BOOST_PARAMETER_FN_ARG_NAME(elem) \ - ) \ - , (const ParameterArgumentType ## i)(ParameterArgumentType ## i) \ - , (const ParameterArgumentType ## i) \ - )) -// No partial ordering. This feature doesn't work. -# else -# define BOOST_PARAMETER_FUNCTION_FWD_COMBINATION(r, _, i, elem) \ - (BOOST_PP_IF( \ - BOOST_PARAMETER_FUNCTION_IS_KEYWORD_QUALIFIER( \ - BOOST_PARAMETER_FN_ARG_NAME(elem) \ - ) \ - , (ParameterArgumentType ## i) \ - , (const ParameterArgumentType ## i) \ - )) -# endif +// Expands to a Boost.Parameter-enabled const-qualified member function +// header. All arguments are accessible via args and keywords, as well as +// by name. +#define BOOST_PARAMETER_CONST_MEMBER_FUNCTION(result, name, tag_ns, args) \ + BOOST_PARAMETER_MEMBER_FUNCTION_AUX( \ + result, name, name, tag_ns, 1 \ + , BOOST_PARAMETER_FLATTEN(3, 2, 3, args) \ + ) +/**/ -# define BOOST_PARAMETER_FUNCTION_FWD_COMBINATIONS(args) \ - BOOST_PP_SEQ_FOR_EACH_I(BOOST_PARAMETER_FUNCTION_FWD_COMBINATION, ~, args) - -#endif // BOOST_PARAMETER_PREPROCESSOR_060206_HPP +#endif // include guard diff --git a/include/boost/parameter/required.hpp b/include/boost/parameter/required.hpp new file mode 100755 index 0000000..001bded --- /dev/null +++ b/include/boost/parameter/required.hpp @@ -0,0 +1,51 @@ +// Copyright David Abrahams, Daniel Wallin 2003. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_REQUIRED_HPP +#define BOOST_PARAMETER_REQUIRED_HPP + +#include + +namespace boost { namespace parameter { + + // This metafunction can be used to describe the treatment of particular + // named parameters for the purposes of overload elimination with SFINAE, + // by placing specializations in the parameters<...> list. In order for + // a treated function to participate in overload resolution: + // + // - all keyword tags wrapped in required<...> must have a matching + // actual argument + // + // - The actual argument type matched by every keyword tag + // associated with a predicate must satisfy that predicate + template < + typename Tag + , typename Predicate = ::boost::parameter::aux::use_default + > + struct required + { + typedef Tag key_type; + typedef Predicate predicate; + }; +}} + +#include + +namespace boost { namespace parameter { namespace aux { + + template + struct is_required : ::boost::mpl::false_ + { + }; + + template + struct is_required< ::boost::parameter::required > + : ::boost::mpl::true_ + { + }; +}}} // namespace boost::parameter::aux + +#endif // include guard + diff --git a/test/preprocessor.cpp b/test/preprocessor.cpp index 14c3b5f..49d6e72 100644 --- a/test/preprocessor.cpp +++ b/test/preprocessor.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include "basics.hpp" From 5f5d777691a9c18f1c93fde14a0d0c6ff14b647e Mon Sep 17 00:00:00 2001 From: CromwellEnage <32967088+CromwellEnage@users.noreply.github.com> Date: Wed, 24 Oct 2018 12:32:27 -0400 Subject: [PATCH 2/4] Restructure code : * Move support metafunction definitions and BOOST_PARAMETER_TAG_PLACEHOLDER_TYPE macro definition to . * Move BOOST_PARAMETER_IS_BINARY macro definition to . * Use BOOST_PARAMETER_TAG_PLACEHOLDER_TYPE macro. --- include/boost/parameter/aux_/name.hpp | 78 +++++++++++++++++++++ include/boost/parameter/name.hpp | 99 ++++++--------------------- 2 files changed, 99 insertions(+), 78 deletions(-) create mode 100755 include/boost/parameter/aux_/name.hpp diff --git a/include/boost/parameter/aux_/name.hpp b/include/boost/parameter/aux_/name.hpp new file mode 100755 index 0000000..45f2049 --- /dev/null +++ b/include/boost/parameter/aux_/name.hpp @@ -0,0 +1,78 @@ +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_PARAMETER_AUX_NAME_HPP +#define BOOST_PARAMETER_AUX_NAME_HPP + +namespace boost { namespace parameter { namespace aux { + + struct name_tag_base + { + }; + + template + struct name_tag + { + }; +}}} // namespace boost::parameter::aux + +#include + +namespace boost { namespace parameter { namespace aux { + + template + struct is_name_tag : ::boost::mpl::false_ + { + }; +}}} // namespace boost::parameter::aux + +#include +#include +#include +#include + +#if !defined(BOOST_NO_SFINAE) && \ + !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) + +#include +#include +#include +#include +#include + +namespace boost { namespace mpl { + + template + struct lambda< + T + , typename ::boost::enable_if< + ::boost::parameter::aux::is_name_tag + , ::boost::parameter::aux::lambda_tag + >::type + > + { + typedef ::boost::mpl::true_ is_le; + typedef ::boost::mpl::bind3< + ::boost::mpl::quote3< ::boost::parameter::value_type> + , ::boost::mpl::arg<2> + , T + , void + > result_; + typedef result_ type; + }; +}} // namespace boost::mpl + +#endif // SFINAE enabled, not Borland. + +#include + +#define BOOST_PARAMETER_TAG_PLACEHOLDER_TYPE(tag) \ + ::boost::parameter::value_type< \ + ::boost::mpl::_2,tag,::boost::parameter::void_ \ + > +/**/ + +#endif // include guard + diff --git a/include/boost/parameter/name.hpp b/include/boost/parameter/name.hpp index f439df4..d958d3d 100644 --- a/include/boost/parameter/name.hpp +++ b/include/boost/parameter/name.hpp @@ -1,78 +1,15 @@ -// Copyright Daniel Wallin 2006. Use, modification and distribution is -// subject to the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// Copyright Daniel Wallin 2006. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_PARAMETER_NAME_060806_HPP -# define BOOST_PARAMETER_NAME_060806_HPP +#define BOOST_PARAMETER_NAME_060806_HPP -# include -# include -# include -# include -# include -# include -# include -# include -# include - -# if !defined(BOOST_NO_SFINAE) \ - && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592)) - -# include -# include - -namespace boost { namespace parameter { namespace aux { - -// Tag type passed to MPL lambda. -struct lambda_tag; - -struct name_tag_base -{}; - -template -struct name_tag -{}; - -template -struct is_name_tag - : mpl::false_ -{}; - -}}} // namespace boost::parameter::aux - -namespace boost { namespace mpl { - -template -struct lambda< - T - , typename boost::enable_if< - parameter::aux::is_name_tag, parameter::aux::lambda_tag - >::type -> -{ - typedef true_ is_le; - typedef bind3< quote3, arg<2>, T, void> result_; - typedef result_ type; -}; - -}} // namespace boost::mpl - -# endif - -# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) -# include -// From Paul Mensonides -# define BOOST_PARAMETER_IS_BINARY(x) \ - BOOST_PP_SPLIT(1, BOOST_PARAMETER_IS_BINARY_C x BOOST_PP_COMMA() 0) \ - /**/ -# define BOOST_PARAMETER_IS_BINARY_C(x,y) \ - ~, 1 BOOST_PP_RPAREN() \ - BOOST_PP_TUPLE_EAT(2) BOOST_PP_LPAREN() ~ \ - /**/ -# else -# include -# define BOOST_PARAMETER_IS_BINARY(x) BOOST_PP_IS_BINARY(x) -# endif +#include +#include +#include +#include # define BOOST_PARAMETER_BASIC_NAME(tag_namespace, tag, name) \ namespace tag_namespace \ @@ -84,13 +21,9 @@ struct lambda< return BOOST_PP_STRINGIZE(tag); \ } \ \ - typedef boost::parameter::value_type< \ - boost::mpl::_2, tag, boost::parameter::void_ \ - > _; \ + typedef BOOST_PARAMETER_TAG_PLACEHOLDER_TYPE(tag) _; \ \ - typedef boost::parameter::value_type< \ - boost::mpl::_2, tag, boost::parameter::void_ \ - > _1; \ + typedef BOOST_PARAMETER_TAG_PLACEHOLDER_TYPE(tag) _1; \ }; \ } \ namespace \ @@ -102,6 +35,8 @@ struct lambda< # define BOOST_PARAMETER_COMPLEX_NAME_TUPLE1(tag,namespace) \ (tag, namespace), ~ +#include + # define BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name) \ BOOST_PP_TUPLE_ELEM(2, 0, (BOOST_PARAMETER_COMPLEX_NAME_TUPLE1 name)) @@ -111,6 +46,8 @@ struct lambda< # define BOOST_PARAMETER_COMPLEX_NAME_NAMESPACE(name) \ BOOST_PP_TUPLE_ELEM(2, 1, BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name)) +#include + # define BOOST_PARAMETER_COMPLEX_NAME(name) \ BOOST_PARAMETER_BASIC_NAME( \ BOOST_PARAMETER_COMPLEX_NAME_NAMESPACE(name) \ @@ -119,9 +56,14 @@ struct lambda< ) \ /**/ +#include + # define BOOST_PARAMETER_SIMPLE_NAME(name) \ BOOST_PARAMETER_BASIC_NAME(tag, name, BOOST_PP_CAT(_, name)) +#include +#include + # define BOOST_PARAMETER_NAME(name) \ BOOST_PP_IIF( \ BOOST_PARAMETER_IS_BINARY(name) \ @@ -130,6 +72,7 @@ struct lambda< )(name) \ /**/ +#include # define BOOST_PARAMETER_TEMPLATE_KEYWORD(name) \ namespace tag \ From 0fdf92a4e3d84400faf63cc65733c41d9c55eb50 Mon Sep 17 00:00:00 2001 From: CromwellEnage <32967088+CromwellEnage@users.noreply.github.com> Date: Wed, 24 Oct 2018 12:42:14 -0400 Subject: [PATCH 3/4] Update keyword.hpp Add #include statement for forward declaration. --- include/boost/parameter/keyword.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/parameter/keyword.hpp b/include/boost/parameter/keyword.hpp index 925c772..339dde6 100644 --- a/include/boost/parameter/keyword.hpp +++ b/include/boost/parameter/keyword.hpp @@ -6,6 +6,7 @@ #ifndef KEYWORD_050328_HPP #define KEYWORD_050328_HPP +#include #include #include #include From b0785c293129a40a5397235977a2e7ac9e6500e3 Mon Sep 17 00:00:00 2001 From: CromwellEnage <32967088+CromwellEnage@users.noreply.github.com> Date: Wed, 24 Oct 2018 16:54:44 -0400 Subject: [PATCH 4/4] Update documentation Document that boost::parameter::required, boost::parameter::optional, and boost::parameter::deduced are defined in their own header files, which are in turn #included by . --- doc/html/reference.html | 33 ++++++++++++++++++++++----------- doc/reference.rst | 19 +++++++++++++++---- 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/doc/html/reference.html b/doc/html/reference.html index f76c28a..5d66bf2 100644 --- a/doc/html/reference.html +++ b/doc/html/reference.html @@ -533,14 +533,15 @@ template <class A0, …class Aβ>

4.3   optional, required

These templates describe the requirements on a function parameter.

- --- - - - -
Defined in:boost/parameter/parameters.hpp
+

optional is defined in: boost/parameter/optional.hpp.

+

required is defined in: boost/parameter/required.hpp.

+

Both headers are included by: boost/parameter/parameters.hpp

@@ -551,10 +552,10 @@ template <class A0, …class Aβ> -template <class Tag, class Predicate = unspecified> +template <typename Tag, typename Predicate = unspecified> struct optional; -template <class Tag, class Predicate = unspecified> +template <typename Tag, typename Predicate = unspecified> struct required;

The default value of Predicate is an unspecified Metafunction that returns @@ -568,7 +569,17 @@ struct required;

- + + + + + + +
Defined in:boost/parameter/parameters.hpp
Defined in:boost/parameter/deduced.hpp
Included by:boost/parameter/parameters.hpp
diff --git a/doc/reference.rst b/doc/reference.rst index 552a181..80f0328 100644 --- a/doc/reference.rst +++ b/doc/reference.rst @@ -475,9 +475,16 @@ __ ../../../../boost/parameter/parameters.hpp These templates describe the requirements on a function parameter. -:Defined in: `boost/parameter/parameters.hpp`__ +``optional`` is defined in: |optional_header|_ +``required`` is defined in: |required_header|_ +Both headers are included by: |preprocessor_header|_ -__ ../../../../boost/parameter/parameters.hpp +.. |optional_header| replace:: boost/parameter/optional.hpp +.. _optional_header: ../../../../boost/parameter/optional.hpp +.. |required_header| replace:: boost/parameter/required.hpp +.. _required_header: ../../../../boost/parameter/required.hpp +.. |preprocessor_header| replace:: boost/parameter/preprocessor.hpp +.. _preprocessor_header: ../../../../boost/parameter/preprocessor.hpp :Specializations model: |ParameterSpec|_ @@ -502,9 +509,13 @@ The default value of ``Predicate`` is an unspecified |Metafunction|_ that return This template is used to wrap the *keyword tag* argument to ``optional`` or ``required``. -:Defined in: `boost/parameter/parameters.hpp`__ +:Defined in: |deduced_header|_ +:Included by: |preprocessor_header|_ -__ ../../../../boost/parameter/parameters.hpp +.. |deduced_header| replace:: boost/parameter/deduced.hpp +.. _deduced_header: ../../../../boost/parameter/deduced.hpp +.. |preprocessor_header| replace:: boost/parameter/preprocessor.hpp +.. _preprocessor_header: ../../../../boost/parameter/preprocessor.hpp .. parsed-literal::