+| |
+
+ The return type of each of the following function templates falls under a
+different value category.
+
+template <std::size_t N>
+std::bitset<N + 1> rvalue_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const rvalue_const_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1>& lvalue_bitset()
+{
+ static std::bitset<N + 1> lset = std::bitset<N + 1>();
+ return lset;
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const& lvalue_const_bitset()
+{
+ static std::bitset<N + 1> const clset = std::bitset<N + 1>();
+ return clset;
+}
+
+The U::evaluate_category static member
+function template has a simple job: to return the correct value category when
+passed in an object returned by one of the functions defined above. Assume
+that BOOST_PARAMETER_HAS_PERFECT_FORWARDING is defined.
+
+enum invoked
+{
+ passed_by_lvalue_reference_to_const
+ , passed_by_lvalue_reference
+ , passed_by_rvalue_reference_to_const
+ , passed_by_rvalue_reference
+};
+
+struct U
+{
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&)
+ {
+ return passed_by_lvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&)
+ {
+ return passed_by_lvalue_reference;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&&)
+ {
+ return passed_by_rvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&&)
+ {
+ return passed_by_rvalue_reference;
+ }
+};
+
+Define the named parameters that will comprise the argument specification
+that this macro will use. Ensure that all their tag types are in the same
+namespace, which is kw in this case. The
+identifiers with leading underscores can be passed to the bracket operator of
+args to extract the same argument to which
+the corresponding named parameter (without underscores) is bound, as will be
+shown later.
+
+BOOST_PARAMETER_NAME((_lrc, kw) in(lrc))
+BOOST_PARAMETER_NAME((_lr, kw) in_out(lr))
+BOOST_PARAMETER_NAME((_rrc, kw) in(rrc))
+BOOST_PARAMETER_NAME((_rr, kw) consume(rr))
+
+Use the macro as a substitute for a normal static member function header. Enclose the return type bool in parentheses. For each parameter, also
+enclose the expected value type in parentheses. Since the value types are
+mutually exclusive, you can wrap the parameters in a (deduced …) clause. Otherwise, just as with a
+normal function, the order in which you specify the parameters determines
+their position. Also, just as with a normal function, optional parameters
+have default values, whereas required parameters do not. Within the function
+body, either simply use the parameter name or pass the matching identifier
+with the leading underscore to the bracket operator of args to extract the corresponding
+argument. Note that the second method doesn't require std::forward to preserve value categories.
+
+struct B
+{
+ BOOST_PARAMETER_MEMBER_FUNCTION((bool), static evaluate, kw,
+ (deduced
+ (required
+ (lrc, (std::bitset<1>))
+ (lr, (std::bitset<2>))
+ )
+ (optional
+ (rrc, (std::bitset<3>), rvalue_const_bitset<2>())
+ (rr, (std::bitset<4>), rvalue_bitset<3>())
+ )
+ )
+ )
+ {
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference_to_const
+ , U::evaluate_category<0>(lrc)
+ );
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference
+ , U::evaluate_category<1>(lr)
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference_to_const
+ , U::evaluate_category<2>(std::forward<rrc0_type>(rrc0))
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference
+ , U::evaluate_category<3>(args[_rr0])
+ );
+
+ return true;
+ }
+};
+
+The following function calls are legal.
+
+B::evaluate( // positional arguments
+ lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+ , rvalue_const_bitset<2>()
+ , rvalue_bitset<3>()
+);
+B::evaluate( // positional arguments
+ lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+);
+B::evaluate(( // composed arguments
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+));
+B::evaluate( // named arguments
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+);
+B::evaluate( // named arguments
+ _lr0 = lvalue_bitset<1>()
+ , _lrc0 = lvalue_const_bitset<0>()
+);
+
+Because the parameters were wrapped in a (deduced …) clause, the following function calls are also legal.
+
+B::evaluate( // deduced arguments
+ rvalue_bitset<3>()
+ , lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+ , rvalue_const_bitset<2>()
+);
+B::evaluate( // deduced arguments
+ lvalue_bitset<1>()
+ , lvalue_const_bitset<0>()
+);
+
The test/preprocessor.cpp and test/preprocessor_eval_category.cpp test programs demonstrate proper
usage of this macro.
-
-
-
-
-
- Same as BOOST_PARAMETER_MEMBER_FUNCTION,
-except that the name of the forwarding member function overloads is
-operator().
-
-
-
-
-
-| Generated names in enclosing scope: |
+Macro parameters: |
| |
-
-- boost_param_result_ ## __LINE__ ##
-operator
-- boost_param_params_ ## __LINE__ ##
-operator
-- boost_param_parameters_ ## __LINE__ ##
-operator
-- boost_param_impl ## operator
-- boost_param_dispatch_0boost_ ## __LINE__ ##
-operator
-- boost_param_dispatch_1boost_ ## __LINE__ ##
-operator
+
+- result is the parenthesized return type
+of the function.
+- name is the base name of the function;
+it determines the name of the generated forwarding functions. name may be qualified by the static keyword to declare the member function
+and its helpers as not associated with any object of the enclosing type.
+- tag_namespace is the namespace in which
+the keywords used by the function resides.
+- arguments is a list of argument
+specifiers, as defined below.
|
-
-
- The test/preprocessor.cpp test program demonstrates proper usage of this
-macro.
-
-
-
-
-
-
-
-
-
-
-| Requires: |
+Argument specifiers syntax: |
| |
- cls is the name of this
-class. impl is the parenthesized
-implementation base class for cls. tag_namespace is the namespace
-in which the keywords used by the function resides. arguments is a list of
-argument-specifiers, as defined in BOOST_PARAMETER_FUNCTION except that
-optional-specifier no longer includes default-value. It is
-up to the delegate constructor in impl to
-determine the default value of all optional arguments.
- |
-
-
-| Generated names in enclosing scope: |
-
-
-| |
-
-
-- boost_param_params_ ## __LINE__ ##
-ctor
-- constructor_parameters ## __LINE__
+
+argument-specifiers ::= specifier-group0 {specifier-group0}
+
+specifier-group0 ::= specifier-group1 |
+ (
+ '(' 'deduced'
+ specifier-group1 {specifier-group1}
+ ')'
+ )
+
+specifier-group1 ::=
+ (
+ '(' 'optional'
+ optional-specifier {optional-specifier}
+ ')'
+ ) | (
+ '(' 'required'
+ required-specifier {required-specifier}
+ ')'
+ )
+
+optional-specifier ::=
+ '('
+ argument-name ',' restriction ',' default-value
+ ')'
+
+required-specifier ::=
+ '(' argument-name ',' restriction ')'
+
+restriction ::=
+ ( '*' '(' mfc ')' ) |
+ ( '(' typename ')' ) |
+ '*'
+
+
+- argument-name is any valid C++
+identifier.
+- default-value is any valid C++
+expression; if necessary, user code can compute it in terms of
+previous-name ## _type, where
+previous-name is the
+argument-name in a previous
+specifier-group0 or
+specifier-group1. This expression will
+be invoked exactly once.
+- mfc is an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is a
+Boolean Integral
+Concept; however, user code cannot compute
+mfc in terms of
+previous-name ## _type.
+- type-name is either the name of a
+target type or an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is the
+target type. If restriction uses this form, then the type of the generated name argument-name ## _type will be computed in terms
+of the target type, and the generated reference
+argument-name (but not its corresponding
+entry in args) will be cast to that
+type.
|
@@ -2938,125 +2910,1998 @@ determined from arguments.
m denotes the maximum arity, as
determined from arguments.
-If BOOST_PARAMETER_HAS_PERFECT_FORWARDING is
-#defined, then:
-struct boost_param_params_ ## __LINE__ ## ctor
- : boost::parameter::parameters<
+template <typename T>
+struct boost_param_result_ ## __LINE__ ## name
+{
+ typedef result type;
+};
+
+struct boost_param_params_ ## __LINE__ ## name
+ : parameters<
list of parameter specifications, based on arguments
>
{
};
typedef boost_param_params_ ## __LINE__ ## name
- constructor_parameters ## __LINE__;
+ boost_param_parameters_ ## __LINE__ ## name;
template <typename A0, …, typename A ## n>
-cls(A0&& a0, …, A ## n && a ## n)
- : impl(
- constructor_parameters ## __LINE__(
- std::forward<A0>(a0)
- , …
- , std::forward<A ## n>(a ## n)
- )
+result type
+ name(
+ A0&& a0, …, A ## n && a ## n
+ , typename boost_param_parameters_ ## __LINE__ ## name
+ ::match<A0, …, A ## n>::type
+ = boost_param_parameters_ ## __LINE__ ## name()
)
{
-}
-
-⋮
-
-template <typename A0, …, typename A ## m>
-cls(A0&& a0, …, A ## m&& a ## m)
- : impl(
- constructor_parameters ## __LINE__(
+ return this->boost_param_impl ## __LINE__ ## name(
+ boost_param_parameters_ ## __LINE__ ## name()(
std::forward<A0>(a0)
+href="http://en.cppreference.com/w/cpp/utility/forward"
+>forward<A0>(a0)
, …
, std::forward<A ## m>(a ## m)
+href="http://en.cppreference.com/w/cpp/utility/forward"
+>forward<A ## n>(a ## n)
)
+ );
+}
+
+⋮
+
+template <typename A0, …, typename A ## m>
+result type
+ name(
+ A0&& a0, …, A ## m && a ## m
+ , typename boost_param_parameters_ ## __LINE__ ## name
+ ::match<A0, …, A ## m>::type
+ = boost_param_parameters_ ## __LINE__ ## name()
)
{
-}
-
-If BOOST_PARAMETER_HAS_PERFECT_FORWARDING is not
-#defined, then:
-
-struct boost_param_params_ ## __LINE__ ## ctor
- : boost::parameter::parameters<
- list of parameter specifications, based on arguments
- >
-{
-};
-
-typedef boost_param_params_ ## __LINE__ ## name
- constructor_parameters ## __LINE__;
-
-template <typename A0, …, typename A ## n>
-cls(A0 const& a0, …, A ## n const& a ## n)
- : impl(constructor_parameters ## __LINE__(a0, …, a ## n))
-{
+ return this->boost_param_impl ## __LINE__ ## name(
+ boost_param_parameters_ ## __LINE__ ## name()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## m>(a ## m)
+ )
+ );
}
-… exponential number of overloads …
-⋮
-
-template <typename A0, …, typename A ## n>
-cls(A0& a0, …, A ## n & a ## n)
- : impl(constructor_parameters ## __LINE__(a0, …, a ## n))
+template <typename Args>
+typename boost_param_result_ ## __LINE__ ## name<Args>::type
+ boost_param_impl ## __LINE__ ## name(Args const& args)
{
+ return this->boost_param_dispatch_0boost_ ## __LINE__ ## name(
+ static_cast<
+ typename boost_param_result_ ## __LINE__ ## name<
+ Args
+ >::type(*)()
+ >(std::nullptr)
+ , args
+ , std::forward<
+ typename value_type<
+ Args
+ , keyword tag type of required parameter ## 0
+ >::type
+ >(args[ keyword object of required parameter ## 0])
+ , …
+ , std::forward<
+ typename value_type<
+ Args
+ , keyword tag type of required parameter ## n
+ >::type
+ >(args[ keyword object of required parameter ## n])
+ );
+}
+
+template <
+ typename ResultType
+ , typename Args
+ , typename argument name ## 0 ## _type
+ , …
+ , typename argument name ## n ## _type
+>
+ResultType
+ boost_param_dispatch_0boost_ ## __LINE__ ## name(
+ (ResultType(*)())
+ , Args const& args
+ , argument name ## 0 ## _type&& argument name ## 0
+ , …
+ , argument name ## n ## _type&& argument name ## n
+ )
+{
+ return this->boost_param_dispatch_0boost_ ## __LINE__ ## name(
+ static_cast<ResultType(*)()>(std::nullptr)
+ , (args, keyword object of optional parameter ## n + 1 =
+ default value of optional parameter ## n + 1
+ )
+ , std::forward< argument name ## 0 ## _type>(
+ argument name ## 0
+ )
+ , …
+ , std::forward< argument name ## n ## _type>(
+ argument name ## n
+ )
+ , std::forward<
+ typename value_type<
+ Args
+ , keyword tag type of optional parameter ## n + 1
+ >::type
+ >(default value of optional parameter ## n + 1)
+ );
}
⋮
-template <typename A0, …, typename A ## m>
-cls(A0 const& a0, …, A ## m const& a ## m)
- : impl(constructor_parameters ## __LINE__(a0, …, a ## m))
-{
-}
-
-… exponential number of overloads …
-⋮
-
-template <typename A0, …, typename A ## m>
-cls(A0& a0, …, A ## m & a ## m)
- : impl(constructor_parameters ## __LINE__(a0, …, a ## m))
-{
-}
+template <
+ typename ResultType
+ , typename Args
+ , typename argument name ## 0 ## _type
+ , …
+ , typename argument name ## m ## _type
+>
+ResultType
+ boost_param_dispatch_0boost_ ## __LINE__ ## name(
+ (ResultType(*)())
+ , Args const& args
+ , argument name ## 0 ## _type&& argument name ## 0
+ , …
+ , argument name ## m ## _type&& argument name ## m
+ )
+
+
+
+
+ Generates a member function that can take in positional arguments, composed
+arguments, named arguments, and deduced arguments.
+
+
+
+
+
+| Example usage: |
+
+
+| |
+
+ The return type of each of the following function templates falls under a
+different value category.
+
+template <std::size_t N>
+std::bitset<N + 1> rvalue_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const rvalue_const_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1>& lvalue_bitset()
+{
+ static std::bitset<N + 1> lset = std::bitset<N + 1>();
+ return lset;
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const& lvalue_const_bitset()
+{
+ static std::bitset<N + 1> const clset = std::bitset<N + 1>();
+ return clset;
+}
+
+The U::evaluate_category static member
+function template has a simple job: to return the correct value category when
+passed in an object returned by one of the functions defined above. Assume
+that BOOST_PARAMETER_HAS_PERFECT_FORWARDING is defined.
+
+enum invoked
+{
+ passed_by_lvalue_reference_to_const
+ , passed_by_lvalue_reference
+ , passed_by_rvalue_reference_to_const
+ , passed_by_rvalue_reference
+};
+
+struct U
+{
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&)
+ {
+ return passed_by_lvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&)
+ {
+ return passed_by_lvalue_reference;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&&)
+ {
+ return passed_by_rvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&&)
+ {
+ return passed_by_rvalue_reference;
+ }
+};
+
+Define the named parameters that will comprise the argument specification
+that this macro will use. Ensure that all their tag types are in the same
+namespace, which is kw in this case. The
+identifiers with leading underscores can be passed to the bracket operator of
+args to extract the same argument to which
+the corresponding named parameter (without underscores) is bound, as will be
+shown later.
+
+BOOST_PARAMETER_NAME((_lrc, kw) in(lrc))
+BOOST_PARAMETER_NAME((_lr, kw) in_out(lr))
+BOOST_PARAMETER_NAME((_rrc, kw) in(rrc))
+BOOST_PARAMETER_NAME((_rr, kw) consume(rr))
+
+Use the macro as a substitute for a normal const member function header. Enclose the return type bool in parentheses. For each parameter, also
+enclose the expected value type in parentheses. Since the value types are
+mutually exclusive, you can wrap the parameters in a (deduced …) clause. Otherwise, just as with a
+normal function, the order in which you specify the parameters determines
+their position. Also, just as with a normal function, optional parameters
+have default values, whereas required parameters do not. Within the function
+body, either simply use the parameter name or pass the matching identifier
+with the leading underscore to the bracket operator of args to extract the corresponding
+argument. Note that the second method doesn't require std::forward to preserve value categories.
+
+struct B
+{
+ B()
+ {
+ }
+
+ BOOST_PARAMETER_CONST_MEMBER_FUNCTION((bool), evaluate, kw,
+ (deduced
+ (required
+ (lrc, (std::bitset<1>))
+ (lr, (std::bitset<2>))
+ )
+ (optional
+ (rrc, (std::bitset<3>), rvalue_const_bitset<2>())
+ (rr, (std::bitset<4>), rvalue_bitset<3>())
+ )
+ )
+ )
+ {
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference_to_const
+ , U::evaluate_category<0>(lrc)
+ );
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference
+ , U::evaluate_category<1>(lr)
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference_to_const
+ , U::evaluate_category<2>(std::forward<rrc0_type>(rrc0))
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference
+ , U::evaluate_category<3>(args[_rr0])
+ );
+
+ return true;
+ }
+};
+
+The following function calls are legal.
+
+B const b = B();
+b.evaluate( // positional arguments
+ lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+ , rvalue_const_bitset<2>()
+ , rvalue_bitset<3>()
+);
+b.evaluate( // positional arguments
+ lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+);
+b.evaluate(( // composed arguments
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+));
+b.evaluate( // named arguments
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+);
+b.evaluate( // named arguments
+ _lr0 = lvalue_bitset<1>()
+ , _lrc0 = lvalue_const_bitset<0>()
+);
+
+Because the parameters were wrapped in a (deduced …) clause, the following function calls are also legal.
+
+b.evaluate( // deduced arguments
+ rvalue_bitset<3>()
+ , lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+ , rvalue_const_bitset<2>()
+);
+b.evaluate( // deduced arguments
+ lvalue_bitset<1>()
+ , lvalue_const_bitset<0>()
+);
+
+The test/preprocessor.cpp test program demonstrates proper usage of this
+macro.
+ |
+
+
+| Macro parameters: |
+
+
+| |
+
+
+- result is the parenthesized return type
+of the function.
+- name is the base name of the function;
+it determines the name of the generated forwarding functions.
+- tag_namespace is the namespace in which
+the keywords used by the function resides.
+- arguments is a list of argument
+specifiers, as defined below.
+
+ |
+
+
+| Argument specifiers syntax: |
+
+
+| |
+
+
+argument-specifiers ::= specifier-group0 {specifier-group0}
+
+specifier-group0 ::= specifier-group1 |
+ (
+ '(' 'deduced'
+ specifier-group1 {specifier-group1}
+ ')'
+ )
+
+specifier-group1 ::=
+ (
+ '(' 'optional'
+ optional-specifier {optional-specifier}
+ ')'
+ ) | (
+ '(' 'required'
+ required-specifier {required-specifier}
+ ')'
+ )
+
+optional-specifier ::=
+ '('
+ argument-name ',' restriction ',' default-value
+ ')'
+
+required-specifier ::=
+ '(' argument-name ',' restriction ')'
+
+restriction ::=
+ ( '*' '(' mfc ')' ) |
+ ( '(' typename ')' ) |
+ '*'
+
+
+- argument-name is any valid C++
+identifier.
+- default-value is any valid C++
+expression; if necessary, user code can compute it in terms of
+previous-name ## _type, where
+previous-name is the
+argument-name in a previous
+specifier-group0 or
+specifier-group1. This expression will
+be invoked exactly once.
+- mfc is an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is a
+Boolean Integral
+Concept; however, user code cannot compute
+mfc in terms of
+previous-name ## _type.
+- type-name is either the name of a
+target type or an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is the
+target type. If restriction uses this form, then the type of the generated name argument-name ## _type will be computed in terms
+of the target type, and the generated reference
+argument-name (but not its corresponding
+entry in args) will be cast to that
+type.
+
+ |
+
+
+
+
+- Approximate expansion:
+-
+
Where:
+
+- n denotes the minimum arity, as
+determined from arguments.
+- m denotes the maximum arity, as
+determined from arguments.
+
+
+template <typename T>
+struct boost_param_result_const_ ## __LINE__ ## name
+{
+ typedef result type;
+};
+
+struct boost_param_params_const_ ## __LINE__ ## name
+ : parameters<
+ list of parameter specifications, based on arguments
+ >
+{
+};
+
+typedef boost_param_params_const_ ## __LINE__ ## name
+ boost_param_parameters_const_ ## __LINE__ ## name;
+
+template <typename A0, …, typename A ## n>
+result type
+ name(
+ A0&& a0, …, A ## n && a ## n
+ , typename boost_param_parameters_const_ ## __LINE__ ## name
+ ::match<A0, …, A ## n>::type
+ = boost_param_parameters_const_ ## __LINE__ ## name()
+ ) const
+{
+ return this->boost_param_impl_const ## __LINE__ ## name(
+ boost_param_parameters_const_ ## __LINE__ ## name()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## n>(a ## n)
+ )
+ );
+}
+
+⋮
+
+template <typename A0, …, typename A ## m>
+result type
+ name(
+ A0&& a0, …, A ## m && a ## m
+ , typename boost_param_parameters_const_ ## __LINE__ ## name
+ ::match<A0, …, A ## m>::type
+ = boost_param_parameters_const_ ## __LINE__ ## name()
+ ) const
+{
+ return this->boost_param_impl_const ## __LINE__ ## name(
+ boost_param_parameters_const_ ## __LINE__ ## name()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## m>(a ## m)
+ )
+ );
+}
+
+template <typename Args>
+typename boost_param_result_const_ ## __LINE__ ## name<Args>::type
+ boost_param_impl_const ## __LINE__ ## name(Args const& args) const
+{
+ return this->
+ boost_param_dispatch_const_0boost_ ## __LINE__ ## name(
+ static_cast<
+ typename boost_param_result_const_ ## __LINE__ ## name<
+ Args
+ >::type(*)()
+ >(std::nullptr)
+ , args
+ , std::forward<
+ typename value_type<
+ Args
+ , keyword tag type of required parameter ## 0
+ >::type
+ >(args[ keyword object of required parameter ## 0])
+ , …
+ , std::forward<
+ typename value_type<
+ Args
+ , keyword tag type of required parameter ## n
+ >::type
+ >(args[ keyword object of required parameter ## n])
+ );
+}
+
+template <
+ typename ResultType
+ , typename Args
+ , typename argument name ## 0 ## _type
+ , …
+ , typename argument name ## n ## _type
+>
+ResultType
+ boost_param_dispatch_const_0boost_ ## __LINE__ ## name(
+ (ResultType(*)())
+ , Args const& args
+ , argument name ## 0 ## _type&& argument name ## 0
+ , …
+ , argument name ## n ## _type&& argument name ## n
+ ) const
+{
+ return this->
+ boost_param_dispatch_const_0boost_ ## __LINE__ ## name(
+ static_cast<ResultType(*)()>(std::nullptr)
+ , (args, keyword object of optional parameter ## n + 1 =
+ default value of optional parameter ## n + 1
+ )
+ , std::forward< argument name ## 0 ## _type>(
+ argument name ## 0
+ )
+ , …
+ , std::forward< argument name ## n ## _type>(
+ argument name ## n
+ )
+ , std::forward<
+ typename value_type<
+ Args
+ , keyword tag type of optional parameter ## n + 1
+ >::type
+ >(default value of optional parameter ## n + 1)
+ );
+}
+
+⋮
+
+template <
+ typename ResultType
+ , typename Args
+ , typename argument name ## 0 ## _type
+ , …
+ , typename argument name ## m ## _type
+>
+ResultType
+ boost_param_dispatch_const_0boost_ ## __LINE__ ## name(
+ (ResultType(*)())
+ , Args const& args
+ , argument name ## 0 ## _type&& argument name ## 0
+ , …
+ , argument name ## m ## _type&& argument name ## m
+ ) const
+
+
+
+
+
+
+
+ Generates a function call operator that can take in positional arguments,
+composed arguments, named arguments, and deduced arguments.
+
+
+
+
+
+| Example usage: |
+
+
+| |
+
+ Define the named parameters that will comprise the argument specification
+that this macro will use. Ensure that all their tag types are in the same
+namespace, which is tag by default.
+
+BOOST_PARAMETER_NAME(y)
+BOOST_PARAMETER_NAME(z)
+
+Use the macro as a substitute for a normal function call operator
+header. Enclose the return type in parentheses. For each parameter, also
+enclose the expected value type in parentheses. Since the value types are
+mutually exclusive, you can wrap the parameters in a (deduced …) clause. This is especially useful
+when implementing multiple Boost.Parameter-enabled function call operator
+overloads.
+
+class char_reader
+{
+ int index;
+ char const* key;
+
+ public:
+ explicit char_reader(char const* k) : index(0), key(k)
+ {
+ }
+
+ BOOST_PARAMETER_FUNCTION_CALL_OPERATOR((void), tag,
+ (deduced
+ (required
+ (y, (int))
+ (z, (char const*))
+ )
+ )
+ )
+ {
+ this->index = y;
+ this->key = z;
+ }
+
+ BOOST_PARAMETER_CONST_FUNCTION_CALL_OPERATOR((char), tag,
+ (deduced
+ (required
+ (y, (bool))
+ (z, (std::map<char const*,std::string>))
+ )
+ )
+ )
+ {
+ return y ? (
+ (z.find(this->key)->second)[this->index]
+ ) : this->key[this->index];
+ }
+};
+
+As with regular argument-dependent lookup, the value types of the arguments
+passed in determine which function call operator overload gets invoked.
+
+char const* keys[] = {"foo", "bar", "baz"};
+std::map<char const*,std::string> k2s;
+k2s[keys[0]] = std::string>("qux");
+k2s[keys[1]] = std::string>("wmb");
+k2s[keys[2]] = std::string>("zxc");
+char_reader r(keys[0]);
+
+// positional arguments
+BOOST_TEST_EQ('q', (r(true, k2s)));
+BOOST_TEST_EQ('f', (r(false, k2s)));
+
+// named arguments
+r(_z = keys[1], _y = 1);
+BOOST_TEST_EQ('m', (r(_z = k2s, _y = true)));
+BOOST_TEST_EQ('a', (r(_z = k2s, _y = false)));
+
+// deduced arguments
+r(keys[2], 2);
+BOOST_TEST_EQ('c', (r(k2s, true)));
+BOOST_TEST_EQ('z', (r(k2s, false)));
+
+The test/preprocessor.cpp and test/preprocessor_deduced.cpp
+test programs demonstrate proper usage of this macro.
+ |
+
+
+| Macro parameters: |
+
+
+| |
+
+
+- result is the parenthesized return type
+of the function call operator.
+- tag_namespace is the namespace in which
+the keywords used by the function call operator resides.
+- arguments is a list of argument
+specifiers, as defined below.
+
+ |
+
+
+| Argument specifiers syntax: |
+
+
+| |
+
+
+argument-specifiers ::= specifier-group0 {specifier-group0}
+
+specifier-group0 ::= specifier-group1 |
+ (
+ '(' 'deduced'
+ specifier-group1 {specifier-group1}
+ ')'
+ )
+
+specifier-group1 ::=
+ (
+ '(' 'optional'
+ optional-specifier {optional-specifier}
+ ')'
+ ) | (
+ '(' 'required'
+ required-specifier {required-specifier}
+ ')'
+ )
+
+optional-specifier ::=
+ '('
+ argument-name ',' restriction ',' default-value
+ ')'
+
+required-specifier ::=
+ '(' argument-name ',' restriction ')'
+
+restriction ::=
+ ( '*' '(' mfc ')' ) |
+ ( '(' typename ')' ) |
+ '*'
+
+
+- argument-name is any valid C++
+identifier.
+- default-value is any valid C++
+expression; if necessary, user code can compute it in terms of
+previous-name ## _type, where
+previous-name is the
+argument-name in a previous
+specifier-group0 or
+specifier-group1. This expression will
+be invoked exactly once.
+- mfc is an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is a
+Boolean Integral
+Concept; however, user code cannot compute
+mfc in terms of
+previous-name ## _type.
+- type-name is either the name of a
+target type or an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is the
+target type. If restriction uses this form, then the type of the generated name argument-name ## _type will be computed in terms
+of the target type, and the generated reference
+argument-name (but not its corresponding
+entry in args) will be cast to that
+type.
+
+ |
+
+
+
+
+- Approximate expansion:
+-
+
Where:
+
+- n denotes the minimum arity, as
+determined from arguments.
+- m denotes the maximum arity, as
+determined from arguments.
+
+
+template <typename T>
+struct boost_param_result_ ## __LINE__ ## operator
+{
+ typedef result type;
+};
+
+struct boost_param_params_ ## __LINE__ ## operator
+ : parameters<
+ list of parameter specifications, based on arguments
+ >
+{
+};
+
+typedef boost_param_params_ ## __LINE__ ## operator
+ boost_param_parameters_ ## __LINE__ ## operator;
+
+template <typename A0, …, typename A ## n>
+result type
+ operator()(
+ A0&& a0, …, A ## n && a ## n
+ , typename boost_param_parameters_ ## __LINE__ ## operator
+ ::match<A0, …, A ## n>::type
+ = boost_param_parameters_ ## __LINE__ ## operator()
+ )
+{
+ return this->boost_param_impl ## __LINE__ ## operator(
+ boost_param_parameters_ ## __LINE__ ## operator()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## n>(a ## n)
+ )
+ );
+}
+
+⋮
+
+template <typename A0, …, typename A ## m>
+result type
+ operator()(
+ A0&& a0, …, A ## m && a ## m
+ , typename boost_param_parameters_ ## __LINE__ ## operator
+ ::match<A0, …, A ## m>::type
+ = boost_param_parameters_ ## __LINE__ ## operator()
+ )
+{
+ return this->boost_param_impl ## __LINE__ ## operator(
+ boost_param_parameters_ ## __LINE__ ## operator()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## m>(a ## m)
+ )
+ );
+}
+
+template <typename Args>
+typename boost_param_result_ ## __LINE__ ## operator<Args>::type
+ boost_param_impl ## __LINE__ ## operator(Args const& args)
+{
+ return this->boost_param_dispatch_0boost_ ## __LINE__ ## operator(
+ static_cast<
+ typename boost_param_result_ ## __LINE__ ## operator<
+ Args
+ >::type(*)()
+ >(std::nullptr)
+ , args
+ , std::forward<
+ typename value_type<
+ Args
+ , keyword tag type of required parameter ## 0
+ >::type
+ >(args[ keyword object of required parameter ## 0])
+ , …
+ , std::forward<
+ typename value_type<
+ Args
+ , keyword tag type of required parameter ## n
+ >::type
+ >(args[ keyword object of required parameter ## n])
+ );
+}
+
+template <
+ typename ResultType
+ , typename Args
+ , typename argument name ## 0 ## _type
+ , …
+ , typename argument name ## n ## _type
+>
+ResultType
+ boost_param_dispatch_0boost_ ## __LINE__ ## operator(
+ (ResultType(*)())
+ , Args const& args
+ , argument name ## 0 ## _type&& argument name ## 0
+ , …
+ , argument name ## n ## _type&& argument name ## n
+ )
+{
+ return this->boost_param_dispatch_0boost_ ## __LINE__ ## operator(
+ static_cast<ResultType(*)()>(std::nullptr)
+ , (args, keyword object of optional parameter ## n + 1 =
+ default value of optional parameter ## n + 1
+ )
+ , std::forward< argument name ## 0 ## _type>(
+ argument name ## 0
+ )
+ , …
+ , std::forward< argument name ## n ## _type>(
+ argument name ## n
+ )
+ , std::forward<
+ typename value_type<
+ Args
+ , keyword tag type of optional parameter ## n + 1
+ >::type
+ >(default value of optional parameter ## n + 1)
+ );
+}
+
+⋮
+
+template <
+ typename ResultType
+ , typename Args
+ , typename argument name ## 0 ## _type
+ , …
+ , typename argument name ## m ## _type
+>
+ResultType
+ boost_param_dispatch_0boost_ ## __LINE__ ## operator(
+ (ResultType(*)())
+ , Args const& args
+ , argument name ## 0 ## _type&& argument name ## 0
+ , …
+ , argument name ## m ## _type&& argument name ## m
+ )
+
+
+
+
+
+
+
+ Generates a function call operator that can take in positional arguments,
+composed arguments, named arguments, and deduced arguments.
+
+
+
+
+
+| Example usage: |
+
+
+| |
+
+ The return type of each of the following function templates falls under a
+different value category.
+
+template <std::size_t N>
+std::bitset<N + 1> rvalue_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const rvalue_const_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1>& lvalue_bitset()
+{
+ static std::bitset<N + 1> lset = std::bitset<N + 1>();
+ return lset;
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const& lvalue_const_bitset()
+{
+ static std::bitset<N + 1> const clset = std::bitset<N + 1>();
+ return clset;
+}
+
+The U::evaluate_category static member
+function template has a simple job: to return the correct value category when
+passed in an object returned by one of the functions defined above. Assume
+that BOOST_PARAMETER_HAS_PERFECT_FORWARDING is defined.
+
+enum invoked
+{
+ passed_by_lvalue_reference_to_const
+ , passed_by_lvalue_reference
+ , passed_by_rvalue_reference_to_const
+ , passed_by_rvalue_reference
+};
+
+struct U
+{
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&)
+ {
+ return passed_by_lvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&)
+ {
+ return passed_by_lvalue_reference;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&&)
+ {
+ return passed_by_rvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&&)
+ {
+ return passed_by_rvalue_reference;
+ }
+};
+
+Define the named parameters that will comprise the argument specification
+that this macro will use. Ensure that all their tag types are in the same
+namespace, which is kw in this case. The
+identifiers with leading underscores can be passed to the bracket operator of
+args to extract the same argument to which
+the corresponding named parameter (without underscores) is bound, as will be
+shown later.
+
+BOOST_PARAMETER_NAME((_lrc, kw) in(lrc))
+BOOST_PARAMETER_NAME((_lr, kw) in_out(lr))
+BOOST_PARAMETER_NAME((_rrc, kw) in(rrc))
+BOOST_PARAMETER_NAME((_rr, kw) consume(rr))
+
+Use the macro as a substitute for a normal const function call operator header. Enclose the return type bool in parentheses. For each parameter, also
+enclose the expected value type in parentheses. Since the value types are
+mutually exclusive, you can wrap the parameters in a (deduced …) clause. Otherwise, just as with a
+normal function, the order in which you specify the parameters determines
+their position. Also, just as with a normal function, optional parameters
+have default values, whereas required parameters do not. Within the function
+body, either simply use the parameter name or pass the matching identifier
+with the leading underscore to the bracket operator of args to extract the corresponding
+argument. Note that the second method doesn't require std::forward to preserve value categories.
+
+struct B
+{
+ B()
+ {
+ }
+
+ BOOST_PARAMETER_CONST_FUNCTION_CALL_OPERATOR((bool), kw,
+ (deduced
+ (required
+ (lrc, (std::bitset<1>))
+ (lr, (std::bitset<2>))
+ )
+ (optional
+ (rrc, (std::bitset<3>), rvalue_const_bitset<2>())
+ (rr, (std::bitset<4>), rvalue_bitset<3>())
+ )
+ )
+ )
+ {
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference_to_const
+ , U::evaluate_category<0>(lrc)
+ );
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference
+ , U::evaluate_category<1>(lr)
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference_to_const
+ , U::evaluate_category<2>(std::forward<rrc0_type>(rrc0))
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference
+ , U::evaluate_category<3>(args[_rr0])
+ );
+
+ return true;
+ }
+};
+
+The following function calls are legal.
+
+B const b = B();
+b( // positional arguments
+ lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+ , rvalue_const_bitset<2>()
+ , rvalue_bitset<3>()
+);
+b( // positional arguments
+ lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+);
+b(( // composed arguments
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+));
+b( // named arguments
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+);
+b( // named arguments
+ _lr0 = lvalue_bitset<1>()
+ , _lrc0 = lvalue_const_bitset<0>()
+);
+
+Because the parameters were wrapped in a (deduced …) clause, the following function calls are also legal.
+
+b( // deduced arguments
+ rvalue_bitset<3>()
+ , lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+ , rvalue_const_bitset<2>()
+);
+b( // deduced arguments
+ lvalue_bitset<1>()
+ , lvalue_const_bitset<0>()
+);
+
+The test/preprocessor.cpp, test/preprocessor_deduced.cpp,
+and test/preprocessor_eval_cat_8.cpp test programs demonstrate proper usage
+of this macro.
+ |
+
+
+| Macro parameters: |
+
+
+| |
+
+
+- result is the parenthesized return type
+of the function call operator.
+- tag_namespace is the namespace in which
+the keywords used by the function call operator resides.
+- arguments is a list of argument
+specifiers, as defined below.
+
+ |
+
+
+| Argument specifiers syntax: |
+
+
+| |
+
+
+argument-specifiers ::= specifier-group0 {specifier-group0}
+
+specifier-group0 ::= specifier-group1 |
+ (
+ '(' 'deduced'
+ specifier-group1 {specifier-group1}
+ ')'
+ )
+
+specifier-group1 ::=
+ (
+ '(' 'optional'
+ optional-specifier {optional-specifier}
+ ')'
+ ) | (
+ '(' 'required'
+ required-specifier {required-specifier}
+ ')'
+ )
+
+optional-specifier ::=
+ '('
+ argument-name ',' restriction ',' default-value
+ ')'
+
+required-specifier ::=
+ '(' argument-name ',' restriction ')'
+
+restriction ::=
+ ( '*' '(' mfc ')' ) |
+ ( '(' typename ')' ) |
+ '*'
+
+
+- argument-name is any valid C++
+identifier.
+- default-value is any valid C++
+expression; if necessary, user code can compute it in terms of
+previous-name ## _type, where
+previous-name is the
+argument-name in a previous
+specifier-group0 or
+specifier-group1. This expression will
+be invoked exactly once.
+- mfc is an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is a
+Boolean Integral
+Concept; however, user code cannot compute
+mfc in terms of
+previous-name ## _type.
+- type-name is either the name of a
+target type or an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is the
+target type. If restriction uses this form, then the type of the generated name argument-name ## _type will be computed in terms
+of the target type, and the generated reference
+argument-name (but not its corresponding
+entry in args) will be cast to that
+type.
+
+ |
+
+
+
+
+- Approximate expansion:
+-
+
Where:
+
+- n denotes the minimum arity, as
+determined from arguments.
+- m denotes the maximum arity, as
+determined from arguments.
+
+
+template <typename T>
+struct boost_param_result_const_ ## __LINE__ ## operator
+{
+ typedef result type;
+};
+
+struct boost_param_params_const_ ## __LINE__ ## operator
+ : parameters<
+ list of parameter specifications, based on arguments
+ >
+{
+};
+
+typedef boost_param_params_const_ ## __LINE__ ## operator
+ boost_param_parameters_const_ ## __LINE__ ## operator;
+
+template <typename A0, …, typename A ## n>
+result type
+ operator()(
+ A0&& a0, …, A ## n && a ## n
+ , typename boost_param_parameters_const_ ## __LINE__ ## operator
+ ::match<A0, …, A ## n>::type
+ = boost_param_parameters_const_ ## __LINE__ ## operator()
+ ) const
+{
+ return this->boost_param_impl_const ## __LINE__ ## operator(
+ boost_param_parameters_const_ ## __LINE__ ## operator()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## n>(a ## n)
+ )
+ );
+}
+
+⋮
+
+template <typename A0, …, typename A ## m>
+result type
+ operator()(
+ A0&& a0, …, A ## m && a ## m
+ , typename boost_param_parameters_const_ ## __LINE__ ## operator
+ ::match<A0, …, A ## m>::type
+ = boost_param_parameters_const_ ## __LINE__ ## operator()
+ ) const
+{
+ return this->boost_param_impl_const ## __LINE__ ## operator(
+ boost_param_parameters_const_ ## __LINE__ ## operator()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## m>(a ## m)
+ )
+ );
+}
+
+template <typename Args>
+typename boost_param_result_const_ ## __LINE__ ## operator<Args>::type
+ boost_param_impl_const ## __LINE__ ## operator(Args const& args) const
+{
+ return this->
+ boost_param_dispatch_const_0boost_ ## __LINE__ ## operator(
+ static_cast<
+ typename boost_param_result_const_ ## __LINE__ ## operator<
+ Args
+ >::type(*)()
+ >(std::nullptr)
+ , args
+ , std::forward<
+ typename value_type<
+ Args
+ , keyword tag type of required parameter ## 0
+ >::type
+ >(args[ keyword object of required parameter ## 0])
+ , …
+ , std::forward<
+ typename value_type<
+ Args
+ , keyword tag type of required parameter ## n
+ >::type
+ >(args[ keyword object of required parameter ## n])
+ );
+}
+
+template <
+ typename ResultType
+ , typename Args
+ , typename argument name ## 0 ## _type
+ , …
+ , typename argument name ## n ## _type
+>
+ResultType
+ boost_param_dispatch_const_0boost_ ## __LINE__ ## operator(
+ (ResultType(*)())
+ , Args const& args
+ , argument name ## 0 ## _type&& argument name ## 0
+ , …
+ , argument name ## n ## _type&& argument name ## n
+ ) const
+{
+ return this->
+ boost_param_dispatch_const_0boost_ ## __LINE__ ## operator(
+ static_cast<ResultType(*)()>(std::nullptr)
+ , (args, keyword object of optional parameter ## n + 1 =
+ default value of optional parameter ## n + 1
+ )
+ , std::forward< argument name ## 0 ## _type>(
+ argument name ## 0
+ )
+ , …
+ , std::forward< argument name ## n ## _type>(
+ argument name ## n
+ )
+ , std::forward<
+ typename value_type<
+ Args
+ , keyword tag type of optional parameter ## n + 1
+ >::type
+ >(default value of optional parameter ## n + 1)
+ );
+}
+
+⋮
+
+template <
+ typename ResultType
+ , typename Args
+ , typename argument name ## 0 ## _type
+ , …
+ , typename argument name ## m ## _type
+>
+ResultType
+ boost_param_dispatch_const_0boost_ ## __LINE__ ## operator(
+ (ResultType(*)())
+ , Args const& args
+ , argument name ## 0 ## _type&& argument name ## 0
+ , …
+ , argument name ## m ## _type&& argument name ## m
+ ) const
+
+
+
+
+
+
+
+ Generates a constructor that can take in positional arguments, composed
+arguments, named arguments, and deduced arguments.
+
+
+
+
+
+| Example usage: |
+
+
+| |
+
+ Define the named parameters that will comprise the argument specification
+that this macro will use. Ensure that all their tag types are in the same
+namespace, which is tag by default.
+
+BOOST_PARAMETER_NAME(y)
+BOOST_PARAMETER_NAME(z)
+
+In the base class, implement a delegate constructor template that takes in
+an ArgumentPack. You must pass the identifiers with leading
+underscores to args in order to extract the
+corresponding arguments.
+
+class char_read_base
+{
+ int index;
+ char const* key;
+
+ public:
+ template <typename Args>
+ explicit char_read_base(Args const& args)
+ : index(args[_y]), key(args[_z])
+ {
+ }
+
+ BOOST_PARAMETER_FUNCTION_CALL_OPERATOR((void), tag,
+ (deduced
+ (required
+ (y, (int))
+ (z, (char const*))
+ )
+ )
+ )
+ {
+ this->index = y;
+ this->key = z;
+ }
+
+ BOOST_PARAMETER_CONST_FUNCTION_CALL_OPERATOR((char), tag,
+ (deduced
+ (required
+ (y, (bool))
+ (z, (std::map<char const*,std::string>))
+ )
+ )
+ )
+ {
+ return y ? (
+ (z.find(this->key)->second)[this->index]
+ ) : this->key[this->index];
+ }
+};
+
+Use the macro as a substitute for a normal constructor definition. Note
+the lack of an explicit body. Enclose the base type in parentheses. For each
+parameter, also enclose the expected value type in parentheses. Since the
+value types are mutually exclusive, you can wrap the parameters in a (deduced …) clause.
+
+struct char_reader : public char_read_base
+{
+ BOOST_PARAMETER_CONSTRUCTOR(char_reader, (char_read_base), tag,
+ (deduced
+ (required
+ (y, (int))
+ (z, (char const*))
+ )
+ )
+ )
+};
+
+The following char_reader constructor
+calls are legal.
+
+char const* keys[] = {"foo", "bar", "baz"};
+std::map<char const*,std::string> k2s;
+k2s[keys[0]] = std::string>("qux");
+k2s[keys[1]] = std::string>("wmb");
+k2s[keys[2]] = std::string>("zxc");
+
+// positional arguments
+char_reader r0(0, keys[0]);
+BOOST_TEST_EQ('q', (r0(true, k2s)));
+BOOST_TEST_EQ('f', (r0(false, k2s)));
+
+// named arguments
+char_reader r1(_z = keys[1], _y = 1);
+BOOST_TEST_EQ('m', (r1(_z = k2s, _y = true)));
+BOOST_TEST_EQ('a', (r1(_z = k2s, _y = false)));
+
+// deduced arguments
+char_reader r2(keys[2], 2);
+BOOST_TEST_EQ('c', (r2(k2s, true)));
+BOOST_TEST_EQ('z', (r2(k2s, false)));
+
The test/preprocessor.cpp and test/preprocessor_eval_category.cpp test programs demonstrate proper
usage of this macro.
+ |
+
+
+| Macro parameters: |
+
+
+| |
+
+
+- cls is the name of the enclosing
+class.
+- impl is the parenthesized implementation
+base class for cls.
+- tag_namespace is the namespace in which
+the keywords used by the constructor resides.
+- arguments is a list of argument
+specifiers, as defined below.
+
+ |
+
+
+| Argument specifiers syntax: |
+
+
+| |
+
+
+argument-specifiers ::= specifier-group0 {specifier-group0}
+
+specifier-group0 ::= specifier-group1 |
+ (
+ '(' 'deduced'
+ specifier-group1 {specifier-group1}
+ ')'
+ )
+
+specifier-group1 ::=
+ (
+ '(' 'optional'
+ specifier {specifier}
+ ')'
+ ) | (
+ '(' 'required'
+ specifier {specifier}
+ ')'
+ )
+
+specifier ::=
+ '(' argument-name ',' restriction ')'
+
+restriction ::=
+ ( '*' '(' mfc ')' ) |
+ ( '(' typename ')' ) |
+ '*'
+
+
+- argument-name is any valid C++
+identifier.
+- mfc is an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is a
+Boolean Integral
+Concept; however, user code cannot compute
+mfc in terms of
+previous-name ## _type.
+- type-name is either the name of a
+target type or an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is the
+target type.
+
+Note that specifier does not include default-value. It
+is up to the delegate constructor in impl to
+determine the default value of all optional arguments.
+ |
+
+
+
+
+- Approximate expansion:
+-
+
Where:
+
+- n denotes the minimum arity, as
+determined from arguments.
+- m denotes the maximum arity, as
+determined from arguments.
+
+
+struct boost_param_params_ ## __LINE__ ## ctor
+ : parameters<
+ list of parameter specifications, based on arguments
+ >
+{
+};
+
+typedef boost_param_params_ ## __LINE__ ## ctor
+ constructor_parameters ## __LINE__;
+
+template <typename A0, …, typename A ## n>
+cls(A0&& a0, …, A ## n && a ## n)
+ : impl(
+ constructor_parameters ## __LINE__(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## n>(a ## n)
+ )
+ )
+{
+}
+
+⋮
+
+template <typename A0, …, typename A ## m>
+cls(A0&& a0, …, A ## m&& a ## m)
+ : impl(
+ constructor_parameters ## __LINE__(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## m>(a ## m)
+ )
+ )
+{
+}
+
+
+
-
@@ -3071,34 +4916,423 @@ href="../../../../boost/parameter/preprocessor.hpp"
- Same as BOOST_PARAMETER_FUNCTION, except:
-
-- For the argument specifiers syntax, optional-specifier no longer
-includes default-value. It is up to the function body to determine
-the default value of all optional arguments.
-- Generated names in the enclosing scope no longer include
-boost_param_dispatch_0boost_ ## __LINE__ ##
-name or boost_param_dispatch_1boost_ ##
-__LINE__ ## name.
-- Expansion of this macro omits all overloads of boost_param_dispatch_0boost_ ## __LINE__ ## name
-and boost_param_dispatch_1boost_ ## __LINE__ ##
-name and stops at the header of boost_param_impl ## name. Therefore, only the ArgumentPack type Args and its
-object instance args are available for use
-within the function body.
-
+ Generates a function that can take in positional arguments, composed
+arguments, named arguments, and deduced arguments.
+
+
+
+
+
+| Example usage: |
+
+
+| |
+
+ The return type of each of the following function templates falls under a
+different value category.
+
+template <std::size_t N>
+std::bitset<N + 1> rvalue_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const rvalue_const_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1>& lvalue_bitset()
+{
+ static std::bitset<N + 1> lset = std::bitset<N + 1>();
+ return lset;
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const& lvalue_const_bitset()
+{
+ static std::bitset<N + 1> const clset = std::bitset<N + 1>();
+ return clset;
+}
+
+The U::evaluate_category static member
+function template has a simple job: to return the correct value category when
+passed in an object returned by one of the functions defined above. Assume
+that BOOST_PARAMETER_HAS_PERFECT_FORWARDING is defined.
+
+enum invoked
+{
+ passed_by_lvalue_reference_to_const
+ , passed_by_lvalue_reference
+ , passed_by_rvalue_reference_to_const
+ , passed_by_rvalue_reference
+};
+
+struct U
+{
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&)
+ {
+ return passed_by_lvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&)
+ {
+ return passed_by_lvalue_reference;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&&)
+ {
+ return passed_by_rvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&&)
+ {
+ return passed_by_rvalue_reference;
+ }
+};
+
+Define the named parameters that will comprise the argument specification
+that this macro will use. Ensure that all their tag types are in the same
+namespace, which is kw in this case. The
+identifiers with leading underscores can be passed to the bracket operator of
+args to extract the same argument to which
+the corresponding named parameter (without underscores) is bound, as will be
+shown later.
+
+BOOST_PARAMETER_NAME((_lrc, kw) in(lrc))
+BOOST_PARAMETER_NAME((_lr, kw) in_out(lr))
+BOOST_PARAMETER_NAME((_rrc, kw) in(rrc))
+BOOST_PARAMETER_NAME((_rr, kw) consume(rr))
+
+Use the macro as a substitute for a normal function header. Enclose the
+return type bool in parentheses. For each
+parameter, also enclose the expected value type in parentheses. Since the
+value types are mutually exclusive, you can wrap the parameters in a (deduced …) clause. Otherwise, just as with a
+normal function, the order in which you specify the parameters determines
+their position. However, unlike a normal function, default values must be
+specified within the function body. Also within the function body, you must
+pass the matching identifier with the leading underscore to the bracket
+operator of args to extract the
+corresponding argument, but at least this doesn't require std::forward to preserve value categories.
+
+BOOST_PARAMETER_BASIC_FUNCTION((bool), evaluate, kw,
+ (deduced
+ (required
+ (lrc, (std::bitset<1>))
+ (lr, (std::bitset<2>))
+ )
+ (optional
+ (rrc, (std::bitset<3>))
+ (rr, (std::bitset<4>))
+ )
+ )
+)
+{
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference_to_const
+ , U::evaluate_category<0>(args[_lrc])
+ );
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference
+ , U::evaluate_category<1>(args[_lr])
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference_to_const
+ , U::evaluate_category<2>(
+ args[_rrc0 | rvalue_const_bitset<2>()]
+ )
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference
+ , U::evaluate_category<3>(args[_rr0 | rvalue_bitset<3>()])
+ );
+
+ return true;
+}
+
+The following function calls are legal.
+
+evaluate( // positional arguments
+ lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+ , rvalue_const_bitset<2>()
+ , rvalue_bitset<3>()
+);
+evaluate( // positional arguments
+ lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+);
+evaluate(( // composed arguments
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+));
+evaluate( // named arguments
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+);
+evaluate( // named arguments
+ _lr0 = lvalue_bitset<1>()
+ , _lrc0 = lvalue_const_bitset<0>()
+);
+
+Because the parameters were wrapped in a (deduced …) clause, the following function calls are also legal.
+
+evaluate( // deduced arguments
+ rvalue_bitset<3>()
+ , lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+ , rvalue_const_bitset<2>()
+);
+evaluate( // deduced arguments
+ lvalue_bitset<1>()
+ , lvalue_const_bitset<0>()
+);
+
The test/preprocessor.cpp test program demonstrates proper usage of this
macro.
+ |
+
+
+| Macro parameters: |
+
+
+| |
+
+
+- result is the parenthesized return type
+of the function.
+- name is the base name of the function;
+it determines the name of the generated forwarding functions.
+- tag_namespace is the namespace in which
+the keywords used by the function resides.
+- arguments is a list of argument
+specifiers, as defined below.
+
+ |
+
+
+| Argument specifiers syntax: |
+
+
+| |
+
+
+argument-specifiers ::= specifier-group0 {specifier-group0}
+
+specifier-group0 ::= specifier-group1 |
+ (
+ '(' 'deduced'
+ specifier-group1 {specifier-group1}
+ ')'
+ )
+
+specifier-group1 ::=
+ (
+ '(' 'optional'
+ specifier {specifier}
+ ')'
+ ) | (
+ '(' 'required'
+ specifier {specifier}
+ ')'
+ )
+
+specifier ::=
+ '(' argument-name ',' restriction ')'
+
+restriction ::=
+ ( '*' '(' mfc ')' ) |
+ ( '(' typename ')' ) |
+ '*'
+
+
+- argument-name is any valid C++
+identifier.
+- mfc is an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is a
+Boolean Integral
+Concept; however, user code cannot compute
+mfc in terms of
+previous-name ## _type.
+- type-name is either the name of a
+target type or an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is the
+target type.
+
+Note that specifier does not include default-value. It
+is up to the function body to determine the default value of all optional
+arguments.
+ |
+
+
+
+
+- Approximate expansion:
+-
+
Where:
+
+- n denotes the minimum arity, as
+determined from arguments.
+- m denotes the maximum arity, as
+determined from arguments.
+
+
+template <typename T>
+struct boost_param_result_ ## __LINE__ ## name
+{
+ typedef result type;
+};
+
+struct boost_param_params_ ## __LINE__ ## name
+ : parameters<
+ list of parameter specifications, based on arguments
+ >
+{
+};
+
+typedef boost_param_params_ ## __LINE__ ## name
+ boost_param_parameters_ ## __LINE__ ## name;
+
+template <typename Args>
+typename boost_param_result_ ## __LINE__ ## name<Args>::type
+ boost_param_impl ## __LINE__ ## name(Args const&);
+
+template <typename A0, …, typename A ## n>
+result type
+ name(
+ A0&& a0, …, A ## n && a ## n
+ , typename boost_param_parameters_ ## __LINE__ ## name::match<
+ A0, …, A ## n
+ >::type = boost_param_parameters_ ## __LINE__ ## name()
+ )
+{
+ return boost_param_impl ## __LINE__ ## name(
+ boost_param_parameters_ ## __LINE__ ## name()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## n>(a ## n)
+ )
+ );
+}
+
+⋮
+
+template <typename A0, …, typename A ## m>
+result type
+ name(
+ A0&& a0, …, A ## m && a ## m
+ , typename boost_param_parameters_ ## __LINE__ ## name::match<
+ A0, …, A ## m
+ >::type = boost_param_parameters_ ## __LINE__ ## name()
+ )
+{
+ return boost_param_impl ## __LINE__ ## name(
+ boost_param_parameters_ ## __LINE__ ## name()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## m>(a ## m)
+ )
+ );
+}
+
+template <typename Args>
+typename boost_param_result_ ## __LINE__ ## name<Args>::type
+ boost_param_impl ## __LINE__ ## name(Args const& args)
+
+Only the ArgumentPack type Args and its object instance args are
+available for use within the function body.
+
+
-
@@ -3113,25 +5347,427 @@ href="../../../../boost/parameter/preprocessor.hpp"
- Same as BOOST_PARAMETER_BASIC_FUNCTION,
-except that:
-
-- name may be qualified by the
-static keyword to declare the member
-function and its helpers as not associated with any object of the enclosing
-type.
-- Expansion of this macro omits the forward declaration of the
-implementation function.
-
+ Generates a member function that can take in positional arguments, composed
+arguments, named arguments, and deduced arguments.
+
+
+
+
+
+| Example usage: |
+
+
+| |
+
+ The return type of each of the following function templates falls under a
+different value category.
+
+template <std::size_t N>
+std::bitset<N + 1> rvalue_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const rvalue_const_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1>& lvalue_bitset()
+{
+ static std::bitset<N + 1> lset = std::bitset<N + 1>();
+ return lset;
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const& lvalue_const_bitset()
+{
+ static std::bitset<N + 1> const clset = std::bitset<N + 1>();
+ return clset;
+}
+
+The U::evaluate_category static member
+function template has a simple job: to return the correct value category when
+passed in an object returned by one of the functions defined above. Assume
+that BOOST_PARAMETER_HAS_PERFECT_FORWARDING is defined.
+
+enum invoked
+{
+ passed_by_lvalue_reference_to_const
+ , passed_by_lvalue_reference
+ , passed_by_rvalue_reference_to_const
+ , passed_by_rvalue_reference
+};
+
+struct U
+{
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&)
+ {
+ return passed_by_lvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&)
+ {
+ return passed_by_lvalue_reference;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&&)
+ {
+ return passed_by_rvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&&)
+ {
+ return passed_by_rvalue_reference;
+ }
+};
+
+Define the named parameters that will comprise the argument specification
+that this macro will use. Ensure that all their tag types are in the same
+namespace, which is kw in this case. The
+identifiers with leading underscores can be passed to the bracket operator of
+args to extract the same argument to which
+the corresponding named parameter (without underscores) is bound, as will be
+shown later.
+
+BOOST_PARAMETER_NAME((_lrc, kw) in(lrc))
+BOOST_PARAMETER_NAME((_lr, kw) in_out(lr))
+BOOST_PARAMETER_NAME((_rrc, kw) in(rrc))
+BOOST_PARAMETER_NAME((_rr, kw) consume(rr))
+
+Use the macro as a substitute for a normal static member function header. Enclose the return type bool in parentheses. For each parameter, also
+enclose the expected value type in parentheses. Since the value types are
+mutually exclusive, you can wrap the parameters in a (deduced …) clause. Otherwise, just as with a
+normal function, the order in which you specify the parameters determines
+their position. However, unlike a normal function, default values must be
+specified within the function body. Also within the function body, you must
+pass the matching identifier with the leading underscore to the bracket
+operator of args to extract the
+corresponding argument, but at least this doesn't require std::forward to preserve value categories.
+
+struct B
+{
+ BOOST_PARAMETER_BASIC_MEMBER_FUNCTION((bool), static evaluate, kw,
+ (deduced
+ (required
+ (lrc, (std::bitset<1>))
+ (lr, (std::bitset<2>))
+ )
+ (optional
+ (rrc, (std::bitset<3>))
+ (rr, (std::bitset<4>))
+ )
+ )
+ )
+ {
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference_to_const
+ , U::evaluate_category<0>(args[_lrc])
+ );
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference
+ , U::evaluate_category<1>(args[_lr])
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference_to_const
+ , U::evaluate_category<2>(
+ args[_rrc0 | rvalue_const_bitset<2>()]
+ )
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference
+ , U::evaluate_category<3>(
+ args[_rr0 | rvalue_bitset<3>()]
+ )
+ );
+
+ return true;
+ }
+};
+
+The following function calls are legal.
+
+B::evaluate( // positional arguments
+ lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+ , rvalue_const_bitset<2>()
+ , rvalue_bitset<3>()
+);
+B::evaluate( // positional arguments
+ lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+);
+B::evaluate(( // composed arguments
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+));
+B::evaluate( // named arguments
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+);
+B::evaluate( // named arguments
+ _lr0 = lvalue_bitset<1>()
+ , _lrc0 = lvalue_const_bitset<0>()
+);
+
+Because the parameters were wrapped in a (deduced …) clause, the following function calls are also legal.
+
+B::evaluate( // deduced arguments
+ rvalue_bitset<3>()
+ , lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+ , rvalue_const_bitset<2>()
+);
+B::evaluate( // deduced arguments
+ lvalue_bitset<1>()
+ , lvalue_const_bitset<0>()
+);
+
The test/preprocessor.cpp test program demonstrates proper usage of this
macro.
+ |
+
+
+| Macro parameters: |
+
+
+| |
+
+
+- result is the parenthesized return type
+of the function.
+- name is the base name of the function;
+it determines the name of the generated forwarding functions. name may be qualified by the static keyword to declare the member function
+and its helpers as not associated with any object of the enclosing type.
+- tag_namespace is the namespace in which
+the keywords used by the function resides.
+- arguments is a list of argument
+specifiers, as defined below.
+
+ |
+
+
+| Argument specifiers syntax: |
+
+
+| |
+
+
+argument-specifiers ::= specifier-group0 {specifier-group0}
+
+specifier-group0 ::= specifier-group1 |
+ (
+ '(' 'deduced'
+ specifier-group1 {specifier-group1}
+ ')'
+ )
+
+specifier-group1 ::=
+ (
+ '(' 'optional'
+ specifier {specifier}
+ ')'
+ ) | (
+ '(' 'required'
+ specifier {specifier}
+ ')'
+ )
+
+specifier ::=
+ '(' argument-name ',' restriction ')'
+
+restriction ::=
+ ( '*' '(' mfc ')' ) |
+ ( '(' typename ')' ) |
+ '*'
+
+
+- argument-name is any valid C++
+identifier.
+- mfc is an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is a
+Boolean Integral
+Concept; however, user code cannot compute
+mfc in terms of
+previous-name ## _type.
+- type-name is either the name of a
+target type or an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is the
+target type.
+
+Note that specifier does not include default-value. It
+is up to the function body to determine the default value of all optional
+arguments.
+ |
+
+
+
+
+- Approximate expansion:
+-
+
Where:
+
+- n denotes the minimum arity, as
+determined from arguments.
+- m denotes the maximum arity, as
+determined from arguments.
+
+
+template <typename T>
+struct boost_param_result_ ## __LINE__ ## name
+{
+ typedef result type;
+};
+
+struct boost_param_params_ ## __LINE__ ## name
+ : parameters<
+ list of parameter specifications, based on arguments
+ >
+{
+};
+
+typedef boost_param_params_ ## __LINE__ ## name
+ boost_param_parameters_ ## __LINE__ ## name;
+
+template <typename A0, …, typename A ## n>
+result type
+ name(
+ A0&& a0, …, A ## n && a ## n
+ , typename boost_param_parameters_ ## __LINE__ ## name::match<
+ A0, …, A ## n
+ >::type = boost_param_parameters_ ## __LINE__ ## name()
+ )
+{
+ return this->boost_param_impl ## __LINE__ ## name(
+ boost_param_parameters_ ## __LINE__ ## name()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## n>(a ## n)
+ )
+ );
+}
+
+⋮
+
+template <typename A0, …, typename A ## m>
+result type
+ name(
+ A0&& a0, …, A ## m && a ## m
+ , typename boost_param_parameters_ ## __LINE__ ## name::match<
+ A0, …, A ## m
+ >::type = boost_param_parameters_ ## __LINE__ ## name()
+ )
+{
+ return this->boost_param_impl ## __LINE__ ## name(
+ boost_param_parameters_ ## __LINE__ ## name()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## m>(a ## m)
+ )
+ );
+}
+
+template <typename Args>
+typename boost_param_result_ ## __LINE__ ## name<Args>::type
+ boost_param_impl ## __LINE__ ## name(Args const& args)
+
+Only the ArgumentPack type Args and its object instance args are
+available for use within the function body.
+
+
-
@@ -3146,17 +5782,2872 @@ href="../../../../boost/parameter/preprocessor.hpp"
- Same as BOOST_PARAMETER_BASIC_MEMBER_FUNCTION,
-except that the overloaded forwarding member functions and their helper
-methods are const-qualified.
+ Generates a member function that can take in positional arguments, composed
+arguments, named arguments, and deduced arguments.
+
+
+
+
+
+| Example usage: |
+
+
+| |
+
+ The return type of each of the following function templates falls under a
+different value category.
+
+template <std::size_t N>
+std::bitset<N + 1> rvalue_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const rvalue_const_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1>& lvalue_bitset()
+{
+ static std::bitset<N + 1> lset = std::bitset<N + 1>();
+ return lset;
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const& lvalue_const_bitset()
+{
+ static std::bitset<N + 1> const clset = std::bitset<N + 1>();
+ return clset;
+}
+
+The U::evaluate_category static member
+function template has a simple job: to return the correct value category when
+passed in an object returned by one of the functions defined above. Assume
+that BOOST_PARAMETER_HAS_PERFECT_FORWARDING is defined.
+
+enum invoked
+{
+ passed_by_lvalue_reference_to_const
+ , passed_by_lvalue_reference
+ , passed_by_rvalue_reference_to_const
+ , passed_by_rvalue_reference
+};
+
+struct U
+{
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&)
+ {
+ return passed_by_lvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&)
+ {
+ return passed_by_lvalue_reference;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&&)
+ {
+ return passed_by_rvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&&)
+ {
+ return passed_by_rvalue_reference;
+ }
+};
+
+Define the named parameters that will comprise the argument specification
+that this macro will use. Ensure that all their tag types are in the same
+namespace, which is kw in this case. The
+identifiers with leading underscores can be passed to the bracket operator of
+args to extract the same argument to which
+the corresponding named parameter (without underscores) is bound, as will b
+shown later.
+
+BOOST_PARAMETER_NAME((_lrc, kw) in(lrc))
+BOOST_PARAMETER_NAME((_lr, kw) in_out(lr))
+BOOST_PARAMETER_NAME((_rrc, kw) in(rrc))
+BOOST_PARAMETER_NAME((_rr, kw) consume(rr))
+
+Use the macro as a substitute for a normal const member function header. Enclose the return type bool in parentheses. For each parameter, also
+enclose the expected value type in parentheses. Since the value types are
+mutually exclusive, you can wrap the parameters in a (deduced …) clause. Otherwise, just as with a
+normal function, the order in which you specify the parameters determines
+their position. However, unlike a normal function, default values must be
+specified within the function body. Also within the function body, you must
+pass the matching identifier with the leading underscore to the bracket
+operator of args to extract the
+corresponding argument, but at least this doesn't require std::forward to preserve value categories.
+
+struct B
+{
+ B()
+ {
+ }
+
+ BOOST_PARAMETER_BASIC_CONST_MEMBER_FUNCTION((bool), evaluate, kw,
+ (deduced
+ (required
+ (lrc, (std::bitset<1>))
+ (lr, (std::bitset<2>))
+ )
+ (optional
+ (rrc, (std::bitset<3>))
+ (rr, (std::bitset<4>))
+ )
+ )
+ )
+ {
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference_to_const
+ , U::evaluate_category<0>(args[_lrc])
+ );
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference
+ , U::evaluate_category<1>(args[_lr])
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference_to_const
+ , U::evaluate_category<2>(
+ args[_rrc0 | rvalue_const_bitset<2>()]
+ )
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference
+ , U::evaluate_category<3>(
+ args[_rr0 | rvalue_bitset<3>()]
+ )
+ );
+
+ return true;
+ }
+};
+
+The following function calls are legal.
+
+B const b = B();
+b.evaluate( // positional arguments
+ lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+ , rvalue_const_bitset<2>()
+ , rvalue_bitset<3>()
+);
+b.evaluate( // positional arguments
+ lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+);
+b.evaluate(( // composed arguments
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+));
+b.evaluate( // named arguments
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+);
+b.evaluate( // named arguments
+ _lr0 = lvalue_bitset<1>()
+ , _lrc0 = lvalue_const_bitset<0>()
+);
+
+Because the parameters were wrapped in a (deduced …) clause, the following function calls are also legal.
+
+b.evaluate( // deduced arguments
+ rvalue_bitset<3>()
+ , lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+ , rvalue_const_bitset<2>()
+);
+b.evaluate( // deduced arguments
+ lvalue_bitset<1>()
+ , lvalue_const_bitset<0>()
+);
+
The test/preprocessor.cpp test program demonstrates proper usage of this
macro.
+ |
+
+
+| Macro parameters: |
+
+
+| |
+
+
+- result is the parenthesized return type
+of the function.
+- name is the base name of the function;
+it determines the name of the generated forwarding functions.
+- tag_namespace is the namespace in which
+the keywords used by the function resides.
+- arguments is a list of argument
+specifiers, as defined below.
+
+ |
+
+
+| Argument specifiers syntax: |
+
+
+| |
+
+
+argument-specifiers ::= specifier-group0 {specifier-group0}
+
+specifier-group0 ::= specifier-group1 |
+ (
+ '(' 'deduced'
+ specifier-group1 {specifier-group1}
+ ')'
+ )
+
+specifier-group1 ::=
+ (
+ '(' 'optional'
+ specifier {specifier}
+ ')'
+ ) | (
+ '(' 'required'
+ specifier {specifier}
+ ')'
+ )
+
+specifier ::=
+ '(' argument-name ',' restriction ')'
+
+restriction ::=
+ ( '*' '(' mfc ')' ) |
+ ( '(' typename ')' ) |
+ '*'
+
+
+- argument-name is any valid C++
+identifier.
+- mfc is an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is a
+Boolean Integral
+Concept; however, user code cannot compute
+mfc in terms of
+previous-name ## _type.
+- type-name is either the name of a
+target type or an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is the
+target type.
+
+Note that specifier does not include default-value. It
+is up to the function body to determine the default value of all optional
+arguments.
+ |
+
+
+
+
+- Approximate expansion:
+-
+
Where:
+
+- n denotes the minimum arity, as
+determined from arguments.
+- m denotes the maximum arity, as
+determined from arguments.
+
+
+template <typename T>
+struct boost_param_result_const_ ## __LINE__ ## name
+{
+ typedef result type;
+};
+
+struct boost_param_params_const_ ## __LINE__ ## name
+ : parameters<
+ list of parameter specifications, based on arguments
+ >
+{
+};
+
+typedef boost_param_params_const_ ## __LINE__ ## name
+ boost_param_parameters_const_ ## __LINE__ ## name;
+
+template <typename A0, …, typename A ## n>
+result type
+ name(
+ A0&& a0, …, A ## n && a ## n
+ , typename boost_param_parameters_const_ ## __LINE__ ## name::match<
+ A0, …, A ## n
+ >::type = boost_param_parameters_const_ ## __LINE__ ## name()
+ ) const
+{
+ return this->boost_param_impl_const ## __LINE__ ## name(
+ boost_param_parameters_const_ ## __LINE__ ## name()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## n>(a ## n)
+ )
+ );
+}
+
+⋮
+
+template <typename A0, …, typename A ## m>
+result type
+ name(
+ A0&& a0, …, A ## m && a ## m
+ , typename boost_param_parameters_const_ ## __LINE__ ## name::match<
+ A0, …, A ## m
+ >::type = boost_param_parameters_const_ ## __LINE__ ## name()
+ ) const
+{
+ return this->boost_param_impl_const ## __LINE__ ## name(
+ boost_param_parameters_const_ ## __LINE__ ## name()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## m>(a ## m)
+ )
+ );
+}
+
+template <typename Args>
+typename boost_param_result_const_ ## __LINE__ ## name<Args>::type
+ boost_param_impl_const ## __LINE__ ## name(Args const& args) const
+
+Only the ArgumentPack type Args and its object instance args are
+available for use within the function body.
+
+
+
+
+
+
+ Generates a function call operator that can take in positional arguments,
+composed arguments, named arguments, and deduced arguments.
+
+
+
+
+
+| Example usage: |
+
+
+| |
+
+ Define the named parameters that will comprise the argument specification
+that this macro will use. Ensure that all their tag types are in the same
+namespace, which is tag by default.
+
+BOOST_PARAMETER_NAME(y)
+BOOST_PARAMETER_NAME(z)
+
+Use the macro as a substitute for a normal function call operator
+header. Enclose the return type in parentheses. For each parameter, also
+enclose the expected value type in parentheses. Since the value types are
+mutually exclusive, you can wrap the parameters in a (deduced …) clause. This is especially useful
+when implementing multiple Boost.Parameter-enabled function call operator
+overloads.
+
+class char_reader
+{
+ int index;
+ char const* key;
+
+ public:
+ explicit char_reader(char const* k) : index(0), key(k)
+ {
+ }
+
+ BOOST_PARAMETER_BASIC_FUNCTION_CALL_OPERATOR((void), tag,
+ (deduced
+ (required
+ (y, (int))
+ (z, (char const*))
+ )
+ )
+ )
+ {
+ this->index = args[_y];
+ this->key = args[_z];
+ }
+
+ BOOST_PARAMETER_BASIC_CONST_FUNCTION_CALL_OPERATOR((char), tag,
+ (deduced
+ (required
+ (y, (bool))
+ (z, (std::map<char const*,std::string>))
+ )
+ )
+ )
+ {
+ return args[_y] ? (
+ (args[_z].find(this->key)->second)[this->index]
+ ) : this->key[this->index];
+ }
+};
+
+As with regular argument-dependent lookup, the value types of the arguments
+passed in determine which function call operator overload gets invoked.
+
+char const* keys[] = {"foo", "bar", "baz"};
+std::map<char const*,std::string> k2s;
+k2s[keys[0]] = std::string>("qux");
+k2s[keys[1]] = std::string>("wmb");
+k2s[keys[2]] = std::string>("zxc");
+char_reader r(keys[0]);
+
+// positional arguments
+BOOST_TEST_EQ('q', (r(true, k2s)));
+BOOST_TEST_EQ('f', (r(false, k2s)));
+
+// named arguments
+r(_z = keys[1], _y = 1);
+BOOST_TEST_EQ('m', (r(_z = k2s, _y = true)));
+BOOST_TEST_EQ('a', (r(_z = k2s, _y = false)));
+
+// deduced arguments
+r(keys[2], 2);
+BOOST_TEST_EQ('c', (r(k2s, true)));
+BOOST_TEST_EQ('z', (r(k2s, false)));
+
+The test/preprocessor.cpp test program demonstrates proper usage of this
+macro.
+ |
+
+
+| Macro parameters: |
+
+
+| |
+
+
+- result is the parenthesized return type
+of the function call operator.
+- tag_namespace is the namespace in which
+the keywords used by the function call operator resides.
+- arguments is a list of argument
+specifiers, as defined below.
+
+ |
+
+
+| Argument specifiers syntax: |
+
+
+| |
+
+
+argument-specifiers ::= specifier-group0 {specifier-group0}
+
+specifier-group0 ::= specifier-group1 |
+ (
+ '(' 'deduced'
+ specifier-group1 {specifier-group1}
+ ')'
+ )
+
+specifier-group1 ::=
+ (
+ '(' 'optional'
+ specifier {specifier}
+ ')'
+ ) | (
+ '(' 'required'
+ specifier {specifier}
+ ')'
+ )
+
+specifier ::=
+ '(' argument-name ',' restriction ')'
+
+restriction ::=
+ ( '*' '(' mfc ')' ) |
+ ( '(' typename ')' ) |
+ '*'
+
+
+- argument-name is any valid C++
+identifier.
+- mfc is an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is a
+Boolean Integral
+Concept; however, user code cannot compute
+mfc in terms of
+previous-name ## _type.
+- type-name is either the name of a
+target type or an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is the
+target type.
+
+Note that specifier does not include default-value. It
+is up to the function body to determine the default value of all optional
+arguments.
+ |
+
+
+
+
+- Approximate expansion:
+-
+
Where:
+
+- n denotes the minimum arity, as
+determined from arguments.
+- m denotes the maximum arity, as
+determined from arguments.
+
+
+template <typename T>
+struct boost_param_result_ ## __LINE__ ## operator
+{
+ typedef result type;
+};
+
+struct boost_param_params_ ## __LINE__ ## operator
+ : parameters<
+ list of parameter specifications, based on arguments
+ >
+{
+};
+
+typedef boost_param_params_ ## __LINE__ ## operator
+ boost_param_parameters_ ## __LINE__ ## operator;
+
+template <typename A0, …, typename A ## n>
+result type
+ operator()(
+ A0&& a0, …, A ## n && a ## n
+ , typename boost_param_parameters_ ## __LINE__ ## operator
+ ::match<A0, …, A ## n>::type
+ = boost_param_parameters_ ## __LINE__ ## operator()
+ )
+{
+ return this->boost_param_impl ## __LINE__ ## operator(
+ boost_param_parameters_ ## __LINE__ ## operator()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## n>(a ## n)
+ )
+ );
+}
+
+⋮
+
+template <typename A0, …, typename A ## m>
+result type
+ operator()(
+ A0&& a0, …, A ## m && a ## m
+ , typename boost_param_parameters_ ## __LINE__ ## operator
+ ::match<A0, …, A ## m>::type
+ = boost_param_parameters_ ## __LINE__ ## operator()
+ )
+{
+ return this->boost_param_impl ## __LINE__ ## operator(
+ boost_param_parameters_ ## __LINE__ ## operator()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## m>(a ## m)
+ )
+ );
+}
+
+template <typename Args>
+typename boost_param_result_ ## __LINE__ ## operator<Args>::type
+ boost_param_impl ## __LINE__ ## operator(Args const& args)
+
+
+
+
+
+
+
+ Generates a function call operator that can take in positional arguments,
+composed arguments, named arguments, and deduced arguments.
+
+
+
+
+
+| Example usage: |
+
+
+| |
+
+ The return type of each of the following function templates falls under a
+different value category.
+
+template <std::size_t N>
+std::bitset<N + 1> rvalue_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const rvalue_const_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1>& lvalue_bitset()
+{
+ static std::bitset<N + 1> lset = std::bitset<N + 1>();
+ return lset;
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const& lvalue_const_bitset()
+{
+ static std::bitset<N + 1> const clset = std::bitset<N + 1>();
+ return clset;
+}
+
+The U::evaluate_category static member
+function template has a simple job: to return the correct value category when
+passed in an object returned by one of the functions defined above. Assume
+that BOOST_PARAMETER_HAS_PERFECT_FORWARDING is defined.
+
+enum invoked
+{
+ passed_by_lvalue_reference_to_const
+ , passed_by_lvalue_reference
+ , passed_by_rvalue_reference_to_const
+ , passed_by_rvalue_reference
+};
+
+struct U
+{
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&)
+ {
+ return passed_by_lvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&)
+ {
+ return passed_by_lvalue_reference;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&&)
+ {
+ return passed_by_rvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&&)
+ {
+ return passed_by_rvalue_reference;
+ }
+};
+
+Define the named parameters that will comprise the argument specification
+that this macro will use. Ensure that all their tag types are in the same
+namespace, which is kw in this case. The
+identifiers with leading underscores can be passed to the bracket operator of
+args to extract the same argument to which
+the corresponding named parameter (without underscores) is bound, as will be
+shown later.
+
+BOOST_PARAMETER_NAME((_lrc, kw) in(lrc))
+BOOST_PARAMETER_NAME((_lr, kw) in_out(lr))
+BOOST_PARAMETER_NAME((_rrc, kw) in(rrc))
+BOOST_PARAMETER_NAME((_rr, kw) consume(rr))
+
+Use the macro as a substitute for a normal const function call operator header. Enclose the return type bool in parentheses. For each parameter, also
+enclose the expected value type in parentheses. Since the value types are
+mutually exclusive, you can wrap the parameters in a (deduced …) clause. Otherwise, just as with a
+normal function, the order in which you specify the parameters determines
+their position. However, unlike a normal function, default values must be
+specified within the function body. Also within the function body, you must
+pass the matching identifier with the leading underscore to the bracket
+operator of args to extract the
+corresponding argument, but at least this doesn't require std::forward to preserve value categories.
+
+struct B
+{
+ B()
+ {
+ }
+
+ BOOST_PARAMETER_BASIC_CONST_FUNCTION_CALL_OPERATOR((bool), kw,
+ (deduced
+ (required
+ (lrc, (std::bitset<1>))
+ (lr, (std::bitset<2>))
+ )
+ (optional
+ (rrc, (std::bitset<3>))
+ (rr, (std::bitset<4>))
+ )
+ )
+ )
+ {
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference_to_const
+ , U::evaluate_category<0>(args[_lrc])
+ );
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference
+ , U::evaluate_category<1>(args[_lr])
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference_to_const
+ , U::evaluate_category<2>(
+ args[_rrc0 | rvalue_const_bitset<2>()]
+ )
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference
+ , U::evaluate_category<3>(
+ args[_rr0 | rvalue_bitset<3>()]
+ )
+ );
+
+ return true;
+ }
+};
+
+The following function calls are legal.
+
+B const b = B();
+b( // positional arguments
+ lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+ , rvalue_const_bitset<2>()
+ , rvalue_bitset<3>()
+);
+b( // positional arguments
+ lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+);
+b(( // composed arguments
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+));
+b( // named arguments
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+);
+b( // named arguments
+ _lr0 = lvalue_bitset<1>()
+ , _lrc0 = lvalue_const_bitset<0>()
+);
+
+Because the parameters were wrapped in a (deduced …) clause, the following function calls are also legal.
+
+b( // deduced arguments
+ rvalue_bitset<3>()
+ , lvalue_const_bitset<0>()
+ , lvalue_bitset<1>()
+ , rvalue_const_bitset<2>()
+);
+b( // deduced arguments
+ lvalue_bitset<1>()
+ , lvalue_const_bitset<0>()
+);
+
+The test/preprocessor.cpp test program demonstrates proper usage of this
+macro.
+ |
+
+
+| Macro parameters: |
+
+
+| |
+
+
+- result is the parenthesized return type
+of the function call operator.
+- tag_namespace is the namespace in which
+the keywords used by the function call operator resides.
+- arguments is a list of argument
+specifiers, as defined below.
+
+ |
+
+
+| Argument specifiers syntax: |
+
+
+| |
+
+
+argument-specifiers ::= specifier-group0 {specifier-group0}
+
+specifier-group0 ::= specifier-group1 |
+ (
+ '(' 'deduced'
+ specifier-group1 {specifier-group1}
+ ')'
+ )
+
+specifier-group1 ::=
+ (
+ '(' 'optional'
+ specifier {specifier}
+ ')'
+ ) | (
+ '(' 'required'
+ specifier {specifier}
+ ')'
+ )
+
+specifier ::=
+ '(' argument-name ',' restriction ')'
+
+restriction ::=
+ ( '*' '(' mfc ')' ) |
+ ( '(' typename ')' ) |
+ '*'
+
+
+- argument-name is any valid C++
+identifier.
+- mfc is an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is a
+Boolean Integral
+Concept; however, user code cannot compute
+mfc in terms of
+previous-name ## _type.
+- type-name is either the name of a
+target type or an MPL Binary
+Metafunction Class whose first argument will be the type of the
+corresponding argument-name, whose second
+argument will be the entire ArgumentPack, and whose return type is the
+target type.
+
+Note that specifier does not include default-value. It
+is up to the function body to determine the default value of all optional
+arguments.
+ |
+
+
+
+
+- Approximate expansion:
+-
+
Where:
+
+- n denotes the minimum arity, as
+determined from arguments.
+- m denotes the maximum arity, as
+determined from arguments.
+
+
+template <typename T>
+struct boost_param_result_const_ ## __LINE__ ## operator
+{
+ typedef result type;
+};
+
+struct boost_param_params_const_ ## __LINE__ ## operator
+ : parameters<
+ list of parameter specifications, based on arguments
+ >
+{
+};
+
+typedef boost_param_params_const_ ## __LINE__ ## operator
+ boost_param_parameters_const_ ## __LINE__ ## operator;
+
+template <typename A0, …, typename A ## n>
+result type
+ operator()(
+ A0&& a0, …, A ## n && a ## n
+ , typename boost_param_parameters_const_ ## __LINE__ ## operator
+ ::match<A0, …, A ## n>::type
+ = boost_param_parameters_const_ ## __LINE__ ## operator()
+ ) const
+{
+ return this->boost_param_impl_const ## __LINE__ ## operator(
+ boost_param_parameters_const_ ## __LINE__ ## operator()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## n>(a ## n)
+ )
+ );
+}
+
+⋮
+
+template <typename A0, …, typename A ## m>
+result type
+ operator()(
+ A0&& a0, …, A ## m && a ## m
+ , typename boost_param_parameters_const_ ## __LINE__ ## operator
+ ::match<A0, …, A ## m>::type
+ = boost_param_parameters_const_ ## __LINE__ ## operator()
+ ) const
+{
+ return this->boost_param_impl_const ## __LINE__ ## operator(
+ boost_param_parameters_const_ ## __LINE__ ## operator()(
+ std::forward<A0>(a0)
+ , …
+ , std::forward<A ## m>(a ## m)
+ )
+ );
+}
+
+template <typename Args>
+typename boost_param_result_const_ ## __LINE__ ## operator<Args>::type
+ boost_param_impl_const ## __LINE__ ## operator(Args const& args) const
+
+
+
+
+
+
+
+ Generates a function that can take in named arguments.
+
+
+
+
+
+| Example usage: |
+
+
+| |
+
+ The return type of each of the following function templates falls under a
+different value category.
+
+template <std::size_t N>
+std::bitset<N + 1> rvalue_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const rvalue_const_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1>& lvalue_bitset()
+{
+ static std::bitset<N + 1> lset = std::bitset<N + 1>();
+ return lset;
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const& lvalue_const_bitset()
+{
+ static std::bitset<N + 1> const clset = std::bitset<N + 1>();
+ return clset;
+}
+
+The U::evaluate_category static member
+function template has a simple job: to return the correct value category when
+passed in an object returned by one of the functions defined above. Assume
+that BOOST_PARAMETER_HAS_PERFECT_FORWARDING is defined.
+
+enum invoked
+{
+ passed_by_lvalue_reference_to_const
+ , passed_by_lvalue_reference
+ , passed_by_rvalue_reference_to_const
+ , passed_by_rvalue_reference
+};
+
+struct U
+{
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&)
+ {
+ return passed_by_lvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&)
+ {
+ return passed_by_lvalue_reference;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&&)
+ {
+ return passed_by_rvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&&)
+ {
+ return passed_by_rvalue_reference;
+ }
+};
+
+Named parameters are required when invoking the function; however, none of
+their tags need to be in the same namespace.
+
+BOOST_PARAMETER_NAME((_lrc, kw0) in(lrc))
+BOOST_PARAMETER_NAME((_lr, kw1) in_out(lr))
+BOOST_PARAMETER_NAME((_rrc, kw2) in(rrc))
+BOOST_PARAMETER_NAME((_rr, kw3) consume(rr))
+
+Use the macro as a substitute for a variadic function header. Enclose the
+return type bool in parentheses.
+
+BOOST_PARAMETER_NO_SPEC_FUNCTION((bool), evaluate)
+{
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference_to_const
+ , U::evaluate_category<0>(args[_lrc])
+ );
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference
+ , U::evaluate_category<1>(args[_lr])
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference_to_const
+ , U::evaluate_category<2>(
+ args[_rrc0 | rvalue_const_bitset<2>()]
+ )
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference
+ , U::evaluate_category<3>(args[_rr0 | rvalue_bitset<3>()])
+ );
+
+ return true;
+}
+
+To invoke the function, bind all its arguments to named parameters.
+
+evaluate(
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+);
+evaluate(
+ _lr0 = lvalue_bitset<1>()
+ , _lrc0 = lvalue_const_bitset<0>()
+);
+
+The test/preprocessor_eval_cat_no_spec.cpp test program demonstrates proper
+usage of this macro.
+ |
+
+
+| Macro parameters: |
+
+
+| |
+
+
+- result is the parenthesized return type
+of the function.
+- name is the base name of the function;
+it determines the name of the generated implementation function.
+
+ |
+
+
+| Argument specifiers syntax: |
+
+
+| |
+None. |
+
+
+
+
+- Approximate expansion:
+-
+
+template <typename TaggedArg0, typename ...TaggedArgs>
+struct boost_param_no_spec_result_ ## __LINE__ ## name
+{
+ typedef result type;
+};
+
+template <typename ResultType, typename Args>
+ResultType
+ boost_param_no_spec_impl ## __LINE__ ## name(
+ (ResultType(*)())
+ , Args const& args
+ );
+
+template <typename TaggedArg0, typename ...TaggedArgs>
+inline typename boost::lazy_enable_if<
+ are_tagged_arguments<TaggedArg0,TaggedArgs...>
+ , boost_param_no_spec_result_ ## __LINE__ ## name<
+ TaggedArg0
+ , TaggedArgs...
+ >
+>::type
+ name(TaggedArg0 const& arg0, TaggedArgs const&... args)
+{
+ return boost_param_no_spec_impl ## __LINE__ ## name(
+ static_cast<
+ typename
+ boost_param_no_spec_result_ ## __LINE__ ## name<
+ TaggedArg0
+ , TaggedArgs...
+ >::type(*)()
+ >(std::nullptr)
+ , compose(arg0, args...)
+ );
+}
+
+template <typename ResultType, typename Args>
+ResultType
+ boost_param_no_spec_impl ## __LINE__ ## name(
+ (ResultType(*)())
+ , Args const& args
+ )
+
+Only the ArgumentPack type Args and its object instance args are
+available for use within the function body.
+
+
+
+
+
+
+ Generates a member function that can take in named arguments.
+
+
+
+
+
+| Example usage: |
+
+
+| |
+
+ When designing a front-end class template whose back-end is configurable
+via parameterized inheritance, it can be useful to omit argument specifiers
+from a named-parameter member function so that the delegate member functions
+of the back-end classes can enforce their own specifications.
+
+template <typename B>
+struct frontend : B
+{
+ frontend() : B()
+ {
+ }
+
+ BOOST_PARAMETER_NO_SPEC_MEMBER_FUNCTION((void), initialize)
+ {
+ this->initialize_impl(args);
+ }
+};
+
+Named parameters are required when invoking the member function; however,
+none of their tags need to be in the same namespace.
+
+BOOST_PARAMETER_NAME(a0)
+BOOST_PARAMETER_NAME(a1)
+BOOST_PARAMETER_NAME(a2)
+
+For this example, each of the back-end class templates requires its own
+parameter to be present in the argument pack. In practice, such parameters
+should be optional, with default values.
+
+template <typename T>
+class backend0
+{
+ T a0;
+
+ public:
+ backend0() : a0()
+ {
+ }
+
+ T const& get_a0() const
+ {
+ return this->a0;
+ }
+
+ protected:
+ template <typename ArgPack>
+ void initialize_impl(ArgPack const& args)
+ {
+ this->a0 = args[_a0];
+ }
+};
+
+template <typename B, typename T>
+class backend1 : public B
+{
+ T a1;
+
+ public:
+ backend1() : B(), a1()
+ {
+ }
+
+ T const& get_a1() const
+ {
+ return this->a1;
+ }
+
+ protected:
+ template <typename ArgPack>
+ void initialize_impl(ArgPack const& args)
+ {
+ B::initialize_impl(args);
+ this->a1 = args[_a1];
+ }
+};
+
+template <typename B, typename T>
+class backend2 : public B
+{
+ T a2;
+
+ public:
+ backend2() : B(), a2()
+ {
+ }
+
+ T const& get_a2() const
+ {
+ return this->a2;
+ }
+
+ protected:
+ template <typename ArgPack>
+ void initialize_impl(ArgPack const& args)
+ {
+ B::initialize_impl(args);
+ this->a2 = args[_a2];
+ }
+};
+
+This example shows that while backend0
+must always be the root base class template and that frontend must always be the most derived class
+template, the other back-ends can be chained together in different orders.
+
+char const* p = "foo";
+frontend<
+ backend2<backend1<backend0<char const*>, char>, int>
+> composed_obj0;
+frontend<
+ backend1<backend2<backend0<char const*>, int>, char>
+> composed_obj1;
+composed_obj0.initialize(_a2 = 4, _a1 = ' ', _a0 = p);
+composed_obj1.initialize(_a0 = p, _a1 = ' ', _a2 = 4);
+BOOST_TEST_EQ(composed_obj0.get_a0(), composed_obj1.get_a0());
+BOOST_TEST_EQ(composed_obj0.get_a1(), composed_obj1.get_a1());
+BOOST_TEST_EQ(composed_obj0.get_a2(), composed_obj1.get_a2());
+
+The test/parameterized_inheritance.cpp and test/preprocessor_eval_cat_no_spec.cpp test programs demonstrate proper
+usage of this macro.
+ |
+
+
+| Macro parameters: |
+
+
+| |
+
+
+- result is the parenthesized return type
+of the function.
+- name is the base name of the function;
+it determines the name of the generated implementation function. name may be qualified by the static keyword to declare the member function
+and its helpers as not associated with any object of the enclosing type.
+
+ |
+
+
+| Argument specifiers syntax: |
+
+
+| |
+None. |
+
+
+
+
+- Approximate expansion:
+-
+
+template <typename TaggedArg0, typename ...TaggedArgs>
+struct boost_param_no_spec_result_ ## __LINE__ ## name
+{
+ typedef result type;
+};
+
+template <typename TaggedArg0, typename ...TaggedArgs>
+inline typename boost::lazy_enable_if<
+ are_tagged_arguments<TaggedArg0,TaggedArgs...>
+ , boost_param_no_spec_result_ ## __LINE__ ## name<
+ TaggedArg0
+ , TaggedArgs...
+ >
+>::type
+ name(TaggedArg0 const& arg0, TaggedArgs const&... args)
+{
+ return this->boost_param_no_spec_impl ## __LINE__ ## name(
+ static_cast<
+ typename
+ boost_param_no_spec_result_ ## __LINE__ ## name<
+ TaggedArg0
+ , TaggedArgs...
+ >::type(*)()
+ >(std::nullptr)
+ , compose(arg0, args...)
+ );
+}
+
+template <typename ResultType, typename Args>
+ResultType
+ boost_param_no_spec_impl ## __LINE__ ## name(
+ (ResultType(*)())
+ , Args const& args
+ )
+
+Only the ArgumentPack type Args and its object instance args are
+available for use within the function body.
+
+
+
+
+
+
+ Generates a member function that can take in named arguments.
+
+
+
+
+
+| Example usage: |
+
+
+| |
+
+ The return type of each of the following function templates falls under a
+different value category.
+
+template <std::size_t N>
+std::bitset<N + 1> rvalue_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const rvalue_const_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1>& lvalue_bitset()
+{
+ static std::bitset<N + 1> lset = std::bitset<N + 1>();
+ return lset;
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const& lvalue_const_bitset()
+{
+ static std::bitset<N + 1> const clset = std::bitset<N + 1>();
+ return clset;
+}
+
+The U::evaluate_category static member
+function template has a simple job: to return the correct value category when
+passed in an object returned by one of the functions defined above. Assume
+that BOOST_PARAMETER_HAS_PERFECT_FORWARDING is defined.
+
+enum invoked
+{
+ passed_by_lvalue_reference_to_const
+ , passed_by_lvalue_reference
+ , passed_by_rvalue_reference_to_const
+ , passed_by_rvalue_reference
+};
+
+struct U
+{
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&)
+ {
+ return passed_by_lvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&)
+ {
+ return passed_by_lvalue_reference;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&&)
+ {
+ return passed_by_rvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&&)
+ {
+ return passed_by_rvalue_reference;
+ }
+};
+
+Named parameters are required when invoking the member function; however,
+none of their tags need to be in the same namespace.
+
+BOOST_PARAMETER_NAME((_lrc, kw0) in(lrc))
+BOOST_PARAMETER_NAME((_lr, kw1) in_out(lr))
+BOOST_PARAMETER_NAME((_rrc, kw2) in(rrc))
+BOOST_PARAMETER_NAME((_rr, kw3) consume(rr))
+
+Use the macro as a substitute for a variadic function header. Enclose the
+return type bool in parentheses. The macro
+will qualify the function with the const
+keyword.
+
+struct D
+{
+ D()
+ {
+ }
+
+ BOOST_PARAMETER_NO_SPEC_CONST_MEMBER_FUNCTION((bool), evaluate_m)
+ {
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference_to_const
+ , U::evaluate_category<0>(args[_lrc])
+ );
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference
+ , U::evaluate_category<1>(args[_lr])
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference_to_const
+ , U::evaluate_category<2>(
+ args[_rrc0 | rvalue_const_bitset<2>()]
+ )
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference
+ , U::evaluate_category<3>(
+ args[_rr0 | rvalue_bitset<3>()]
+ )
+ );
+
+ return true;
+ }
+};
+
+To invoke the member function, bind all its arguments to named
+parameters.
+
+D const d = D();
+d.evaluate_m(
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+);
+d.evaluate_m(
+ _lr0 = lvalue_bitset<1>()
+ , _lrc0 = lvalue_const_bitset<0>()
+);
+
+The test/preprocessor_eval_cat_no_spec.cpp test program demonstrates proper
+usage of this macro.
+ |
+
+
+| Macro parameters: |
+
+
+| |
+
+
+- result is the parenthesized return type
+of the function.
+- name is the base name of the function;
+it determines the name of the generated implementation function.
+
+ |
+
+
+| Argument specifiers syntax: |
+
+
+| |
+None. |
+
+
+
+
+- Approximate expansion:
+-
+
+template <typename TaggedArg0, typename ...TaggedArgs>
+struct boost_param_no_spec_result_const_ ## __LINE__ ## name
+{
+ typedef result type;
+};
+
+template <typename TaggedArg0, typename ...TaggedArgs>
+inline typename boost::lazy_enable_if<
+ are_tagged_arguments<TaggedArg0,TaggedArgs...>
+ , boost_param_no_spec_result_const_ ## __LINE__ ## name<
+ TaggedArg0
+ , TaggedArgs...
+ >
+>::type
+ name(TaggedArg0 const& arg0, TaggedArgs const&... args) const
+{
+ return this->boost_param_no_spec_impl_const ## __LINE__ ## name(
+ static_cast<
+ typename
+ boost_param_no_spec_result_const_ ## __LINE__ ## name<
+ TaggedArg0
+ , TaggedArgs...
+ >::type(*)()
+ >(std::nullptr)
+ , compose(arg0, args...)
+ );
+}
+
+template <typename ResultType, typename Args>
+ResultType
+ boost_param_no_spec_impl_const ## __LINE__ ## name(
+ (ResultType(*)())
+ , Args const& args
+ ) const
+
+Only the ArgumentPack type Args and its object instance args are
+available for use within the function body.
+
+
+
+
+
+
+ Generates a function call operator that can take in named arguments.
+
+
+
+
+
+| Example usage: |
+
+
+| |
+
+ When designing a front-end class template whose back-end is configurable
+via parameterized inheritance, it can be useful to omit argument specifiers
+from a named-parameter function call operator so that the delegate member
+functions of the back-end classes can enforce their own specifications.
+
+template <typename B>
+struct frontend : B
+{
+ frontend() : B()
+ {
+ }
+
+ BOOST_PARAMETER_NO_SPEC_FUNCTION_CALL_OPERATOR((void))
+ {
+ this->initialize_impl(args);
+ }
+};
+
+Named parameters are required when invoking the function call operator;
+however, none of their tags need to be in the same namespace.
+
+BOOST_PARAMETER_NAME(a0)
+BOOST_PARAMETER_NAME(a1)
+BOOST_PARAMETER_NAME(a2)
+
+For this example, each of the back-end class templates requires its own
+parameter to be present in the argument pack. In practice, such parameters
+should be optional, with default values.
+
+template <typename T>
+class backend0
+{
+ T a0;
+
+ public:
+ backend0() : a0()
+ {
+ }
+
+ T const& get_a0() const
+ {
+ return this->a0;
+ }
+
+ protected:
+ template <typename ArgPack>
+ void initialize_impl(ArgPack const& args)
+ {
+ this->a0 = args[_a0];
+ }
+};
+
+template <typename B, typename T>
+class backend1 : public B
+{
+ T a1;
+
+ public:
+ backend1() : B(), a1()
+ {
+ }
+
+ T const& get_a1() const
+ {
+ return this->a1;
+ }
+
+ protected:
+ template <typename ArgPack>
+ void initialize_impl(ArgPack const& args)
+ {
+ B::initialize_impl(args);
+ this->a1 = args[_a1];
+ }
+};
+
+template <typename B, typename T>
+class backend2 : public B
+{
+ T a2;
+
+ public:
+ backend2() : B(), a2()
+ {
+ }
+
+ T const& get_a2() const
+ {
+ return this->a2;
+ }
+
+ protected:
+ template <typename ArgPack>
+ void initialize_impl(ArgPack const& args)
+ {
+ B::initialize_impl(args);
+ this->a2 = args[_a2];
+ }
+};
+
+This example shows that while backend0
+must always be the root base class template and that frontend must always be the most derived class
+template, the other back-ends can be chained together in different orders.
+
+char const* p = "foo";
+frontend<
+ backend2<backend1<backend0<char const*>, char>, int>
+> composed_obj0;
+frontend<
+ backend1<backend2<backend0<char const*>, int>, char>
+> composed_obj1;
+composed_obj0(_a2 = 4, _a1 = ' ', _a0 = p);
+composed_obj1(_a0 = p, _a1 = ' ', _a2 = 4);
+BOOST_TEST_EQ(composed_obj0.get_a0(), composed_obj1.get_a0());
+BOOST_TEST_EQ(composed_obj0.get_a1(), composed_obj1.get_a1());
+BOOST_TEST_EQ(composed_obj0.get_a2(), composed_obj1.get_a2());
+
+The test/parameterized_inheritance.cpp and test/preprocessor_eval_cat_no_spec.cpp test programs demonstrate proper
+usage of this macro.
+ |
+
+
+| Macro parameters: |
+
+
+| |
+
+
+- result is the parenthesized return type
+of the function call operator.
+
+ |
+
+
+| Argument specifiers syntax: |
+
+
+| |
+None. |
+
+
+
+
+- Approximate expansion:
+-
+
+template <typename TaggedArg0, typename ...TaggedArgs>
+struct boost_param_no_spec_result_ ## __LINE__ ## operator
+{
+ typedef result type;
+};
+
+template <typename TaggedArg0, typename ...TaggedArgs>
+inline typename boost::lazy_enable_if<
+ are_tagged_arguments<TaggedArg0,TaggedArgs...>
+ , boost_param_no_spec_result_ ## __LINE__ ## operator<
+ TaggedArg0
+ , TaggedArgs...
+ >
+>::type
+ operator()(TaggedArg0 const& arg0, TaggedArgs const&... args)
+{
+ return this->boost_param_no_spec_impl ## __LINE__ ## operator(
+ static_cast<
+ typename
+ boost_param_no_spec_result_ ## __LINE__ ## operator<
+ TaggedArg0
+ , TaggedArgs...
+ >::type(*)()
+ >(std::nullptr)
+ , compose(arg0, args...)
+ );
+}
+
+template <typename ResultType, typename Args>
+ResultType
+ boost_param_no_spec_impl ## __LINE__ ## operator(
+ (ResultType(*)())
+ , Args const& args
+ )
+
+Only the ArgumentPack type Args and its object instance args are
+available for use within the function body.
+
+
+
+
+
+
+ Generates a function call operator that can take in named arguments.
+
+
+
+
+
+| Example usage: |
+
+
+| |
+
+ The return type of each of the following function templates falls under a
+different value category.
+
+template <std::size_t N>
+std::bitset<N + 1> rvalue_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const rvalue_const_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1>& lvalue_bitset()
+{
+ static std::bitset<N + 1> lset = std::bitset<N + 1>();
+ return lset;
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const& lvalue_const_bitset()
+{
+ static std::bitset<N + 1> const clset = std::bitset<N + 1>();
+ return clset;
+}
+
+The U::evaluate_category static member
+function template has a simple job: to return the correct value category when
+passed in an object returned by one of the functions defined above. Assume
+that BOOST_PARAMETER_HAS_PERFECT_FORWARDING is defined.
+
+enum invoked
+{
+ passed_by_lvalue_reference_to_const
+ , passed_by_lvalue_reference
+ , passed_by_rvalue_reference_to_const
+ , passed_by_rvalue_reference
+};
+
+struct U
+{
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&)
+ {
+ return passed_by_lvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&)
+ {
+ return passed_by_lvalue_reference;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&&)
+ {
+ return passed_by_rvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&&)
+ {
+ return passed_by_rvalue_reference;
+ }
+};
+
+Named parameters are required when invoking the function call operator;
+however, none of their tags need to be in the same namespace.
+
+BOOST_PARAMETER_NAME((_lrc, kw0) in(lrc))
+BOOST_PARAMETER_NAME((_lr, kw1) in_out(lr))
+BOOST_PARAMETER_NAME((_rrc, kw2) in(rrc))
+BOOST_PARAMETER_NAME((_rr, kw3) consume(rr))
+
+Use the macro as a substitute for a variadic function call operator
+header. Enclose the return type bool in
+parentheses. The macro will qualify the function with the const keyword.
+
+struct D
+{
+ D()
+ {
+ }
+
+ BOOST_PARAMETER_NO_SPEC_CONST_FUNCTION_CALL_OPERATOR((bool))
+ {
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference_to_const
+ , U::evaluate_category<0>(args[_lrc])
+ );
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference
+ , U::evaluate_category<1>(args[_lr])
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference_to_const
+ , U::evaluate_category<2>(
+ args[_rrc0 | rvalue_const_bitset<2>()]
+ )
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference
+ , U::evaluate_category<3>(
+ args[_rr0 | rvalue_bitset<3>()]
+ )
+ );
+
+ return true;
+ }
+};
+
+To invoke the function call operator, bind all its arguments to named
+parameters.
+
+D const d = D();
+d(
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+);
+d(
+ _lr0 = lvalue_bitset<1>()
+ , _lrc0 = lvalue_const_bitset<0>()
+);
+
+The test/preprocessor_eval_cat_no_spec.cpp test program demonstrates proper
+usage of this macro.
+ |
+
+
+| Macro parameters: |
+
+
+| |
+
+
+- result is the parenthesized return type
+of the function call operator.
+
+ |
+
+
+| Argument specifiers syntax: |
+
+
+| |
+None. |
+
+
+
+
+- Approximate expansion:
+-
+
+template <typename TaggedArg0, typename ...TaggedArgs>
+struct boost_param_no_spec_result_const_ ## __LINE__ ## operator
+{
+ typedef result type;
+};
+
+template <typename TaggedArg0, typename ...TaggedArgs>
+inline typename boost::lazy_enable_if<
+ are_tagged_arguments<TaggedArg0,TaggedArgs...>
+ , boost_param_no_spec_result_const_ ## __LINE__ ## operator<
+ TaggedArg0
+ , TaggedArgs...
+ >
+>::type
+ operator()(
+ TaggedArg0 const& arg0
+ , TaggedArgs const&... args
+ ) const
+{
+ return this->boost_param_no_spec_impl_const ## __LINE__ ## operator(
+ static_cast<
+ typename
+ boost_param_no_spec_result_const_ ## __LINE__ ## operator<
+ TaggedArg0
+ , TaggedArgs...
+ >::type(*)()
+ >(std::nullptr)
+ , compose(arg0, args...)
+ );
+}
+
+template <typename ResultType, typename Args>
+ResultType
+ boost_param_no_spec_impl_const ## __LINE__ ## operator(
+ (ResultType(*)())
+ , Args const& args
+ ) const
+
+Only the ArgumentPack type Args and its object instance args are
+available for use within the function body.
+
+
+
+
+
+
+ Generates a constructor that can take in named arguments.
+
+
+
+
+
+| Example usage: |
+
+
+| |
+
+ When designing a front-end class template whose back-end is configurable
+via parameterized inheritance, it can be useful to omit argument specifiers
+from a named-parameter constructor so that the delegate constructors of the
+back-end classes can enforce their own specifications.
+
+template <typename B>
+struct frontend : B
+{
+ BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR(frontend, (B))
+};
+
+Named parameters are required when invoking the constructor; however, none
+of their tags need to be in the same namespace.
+
+BOOST_PARAMETER_NAME(a0)
+BOOST_PARAMETER_NAME(a1)
+BOOST_PARAMETER_NAME(a2)
+
+For this example, each of the back-end class templates requires its own
+parameter to be present in the argument pack. In practice, such parameters
+should be optional, with default values.
+
+struct _enabler
+{
+};
+
+template <typename T>
+class backend0
+{
+ T a0;
+
+ public:
+ template <typename ArgPack>
+ explicit backend0(
+ ArgPack const& args
+ , typename boost::enable_if<
+ is_argument_pack<ArgPack>
+ , _enabler
+ >::type = _enabler()
+ ) : a0(args[_a0])
+ {
+ }
+
+ T const& get_a0() const
+ {
+ return this->a0;
+ }
+};
+
+template <typename B, typename T>
+class backend1 : public B
+{
+ T a1;
+
+ public:
+ template <typename ArgPack>
+ explicit backend1(
+ ArgPack const& args
+ , typename boost::enable_if<
+ is_argument_pack<ArgPack>
+ , _enabler
+ >::type = _enabler()
+ ) : B(args), a1(args[_a1])
+ {
+ }
+
+ T const& get_a1() const
+ {
+ return this->a1;
+ }
+};
+
+template <typename B, typename T>
+class backend2 : public B
+{
+ T a2;
+
+ public:
+ template <typename ArgPack>
+ explicit backend2(
+ ArgPack const& args
+ , typename boost::enable_if<
+ is_argument_pack<ArgPack>
+ , _enabler
+ >::type = _enabler()
+ ) : B(args), a2(args[_a2])
+ {
+ }
+
+ T const& get_a2() const
+ {
+ return this->a2;
+ }
+};
+
+This example shows that while backend0
+must always be the root base class template and that frontend must always be the most derived class
+template, the other back-ends can be chained together in different orders.
+
+char const* p = "foo";
+frontend<
+ backend2<backend1<backend0<char const*>, char>, int>
+> composed_obj0(_a2 = 4, _a1 = ' ', _a0 = p);
+frontend<
+ backend1<backend2<backend0<char const*>, int>, char>
+> composed_obj1(_a0 = p, _a1 = ' ', _a2 = 4);
+BOOST_TEST_EQ(composed_obj0.get_a0(), composed_obj1.get_a0());
+BOOST_TEST_EQ(composed_obj0.get_a1(), composed_obj1.get_a1());
+BOOST_TEST_EQ(composed_obj0.get_a2(), composed_obj1.get_a2());
+
+The test/parameterized_inheritance.cpp and test/preprocessor_eval_cat_no_spec.cpp test programs demonstrate proper
+usage of this macro.
+ |
+
+
+| Macro parameters: |
+
+
+| |
+
+
+- cls is the name of the enclosing
+class.
+- impl is the parenthesized implementation
+base class for cls.
+
+ |
+
+
+| Argument specifiers syntax: |
+
+
+| |
+None. |
+
+
+
+
+- Approximate expansion:
+-
+
+template <
+ template <
+ typename TaggedArg0
+ , typename ...TaggedArgs
+ , typename = typename boost::enable_if<
+ are_tagged_arguments<TaggedArg0,TaggedArgs...>
+ >::type
+>
+inline explicit cls(
+ TaggedArg0 const& arg0
+ , TaggedArgs const&... args
+) : impl(compose(arg0, args...))
+{
+}
+
+
+
+
+
+
+
+ Generates a constructor that can take in named arguments.
+
+
+
+
+
+| Example usage: |
+
+
+| |
+
+ The return type of each of the following functon templates falls under a
+different value category.
+
+template <std::size_t N>
+std::bitset<N + 1> rvalue_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const rvalue_const_bitset()
+{
+ return std::bitset<N + 1>();
+}
+
+template <std::size_t N>
+std::bitset<N + 1>& lvalue_bitset()
+{
+ static std::bitset<N + 1> lset = std::bitset<N + 1>();
+ return lset;
+}
+
+template <std::size_t N>
+std::bitset<N + 1> const& lvalue_const_bitset()
+{
+ static std::bitset<N + 1> const clset = std::bitset<N + 1>();
+ return clset;
+}
+
+The U::evaluate_category static member
+function template has a simple job: to return the correct value category when
+passed in an object returned by one of the functions defined above. Assume
+that BOOST_PARAMETER_HAS_PERFECT_FORWARDING is defined.
+
+enum invoked
+{
+ passed_by_lvalue_reference_to_const
+ , passed_by_lvalue_reference
+ , passed_by_rvalue_reference_to_const
+ , passed_by_rvalue_reference
+};
+
+struct U
+{
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&)
+ {
+ return passed_by_lvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&)
+ {
+ return passed_by_lvalue_reference;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1> const&&)
+ {
+ return passed_by_rvalue_reference_to_const;
+ }
+
+ template <std::size_t N>
+ static invoked evaluate_category(std::bitset<N + 1>&&)
+ {
+ return passed_by_rvalue_reference;
+ }
+};
+
+Named parameters are required when invoking the constructor; however, none
+of their tags need to be in the same namespace.
+
+BOOST_PARAMETER_NAME((_lrc, kw0) in(lrc))
+BOOST_PARAMETER_NAME((_lr, kw1) in_out(lr))
+BOOST_PARAMETER_NAME((_rrc, kw2) in(rrc))
+BOOST_PARAMETER_NAME((_rr, kw3) consume(rr))
+
+Unlike BOOST_PARAMETER_NO_SPEC_CONSTRUCTOR, this
+macro doesn't require a base class, only a delegate function to which the
+generated constructor can pass its ArgumentPack.
+
+struct D
+{
+ BOOST_PARAMETER_NO_SPEC_NO_BASE_CONSTRUCTOR(D, D::_evaluate)
+
+ private:
+ template <typename Args>
+ static bool _evaluate(Args const& args)
+ {
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference_to_const
+ , U::evaluate_category<0>(args[_lrc])
+ );
+ BOOST_TEST_EQ(
+ passed_by_lvalue_reference
+ , U::evaluate_category<1>(args[_lr])
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference_to_const
+ , U::evaluate_category<2>(
+ args[_rrc0 | rvalue_const_bitset<2>()]
+ )
+ );
+ BOOST_TEST_EQ(
+ passed_by_rvalue_reference
+ , U::evaluate_category<3>(
+ args[_rr0 | rvalue_bitset<3>()]
+ )
+ );
+
+ return true;
+ }
+};
+
+To invoke the constructor, bind all its arguments to named parameters.
+
+D dp0(
+ _rr0 = rvalue_bitset<3>()
+ , _lrc0 = lvalue_const_bitset<0>()
+ , _lr0 = lvalue_bitset<1>()
+ , _rrc0 = rvalue_const_bitset<2>()
+);
+D dp1(
+ _lr0 = lvalue_bitset<1>()
+ , _lrc0 = lvalue_const_bitset<0>()
+);
+
+The test/preprocessor_eval_cat_no_spec.cpp test program demonstrates proper
+usage of this macro.
+ |
+
+
+| Macro parameters: |
+
+
+| |
+
+
+- cls is the name of the enclosing
+class.
+- func is a function that takes in the
+ArgumentPack that the generated constructor passes on.
+
+ |
+
+
+| Argument specifiers syntax: |
+
+
+| |
+None. |
+
+
+
+
+- Approximate expansion:
+-
+
+template <
+ template <
+ typename TaggedArg0
+ , typename ...TaggedArgs
+ , typename = typename boost::enable_if<
+ are_tagged_arguments<TaggedArg0,TaggedArgs...>
+ >::type
+>
+inline explicit cls(
+ TaggedArg0 const& arg0
+ , TaggedArgs const&... args
+)
+{
+ func(compose(arg0, args...));
+}
+
+
+
-
@@ -3198,7 +8689,7 @@ namespace namespace-name {
struct tag-name
{
- static char const* keyword_name()
+ static constexpr char const* keyword_name()
{
return ##tag-name;
}
@@ -3209,11 +8700,10 @@ namespace namespace-name {
};
}
-::boost::parameter::keyword<tag-namespace::tag-name> const&
- object-name = ::boost::parameter::keyword<
- tag-namespace::tag-name
- >::instance;
+keyword<tag-namespace::tag-name> const& object-name
+ = keyword<tag-namespace::tag-name>::instance;
Else If name is of the form:
@@ -3251,7 +8741,7 @@ namespace tag {
struct tag-name
{
- static char const* keyword_name()
+ static constexpr char const* keyword_name()
{
return ##tag-name;
}
@@ -3262,9 +8752,10 @@ namespace tag {
};
}
-::boost::parameter::keyword<tag::tag-name> const& _ ## tag-name
- = ::boost::parameter::keyword<tag::tag-name>::instance;
+keyword<tag::tag-name> const& _ ## tag-name
+ = keyword<tag::tag-name>::instance;
Else
Treats name as if it were of the form:
@@ -3273,7 +8764,7 @@ forward(tag-name)
-
@@ -3317,7 +8808,7 @@ namespace tag {
struct tag-name
{
- static char const* keyword_name()
+ static constexpr char const* keyword_name()
{
return ##tag-name;
}
@@ -3325,18 +8816,20 @@ namespace tag {
typedef unspecified _;
typedef unspecified _1;
typedef boost::parameter::qualifier ## _reference qualifier;
- static ::boost::parameter::keyword<tag-name> const& alias;
+ static keyword<tag-name> const& alias;
};
- ::boost::parameter::keyword<tag-name> const& tag-name::alias
- = ::boost::parameter::keyword<tag-name>::instance;
+ keyword<tag-name> const& tag-name::alias
+ = keyword<tag-name>::instance;
}
-::boost::parameter::keyword<tag::tag-name> const& _ ## tag-name
- = ::boost::parameter::keyword<tag::tag-name>::instance;
+keyword<tag::tag-name> const& name
+ = keyword<tag::tag-name>::instance;
Else
Treats name as if it were of the form:
@@ -3345,7 +8838,7 @@ forward(tag-name)
-
@@ -3372,8 +8865,8 @@ namespace tag {
}
template <typename T>
-struct name
- : ::boost::parameter::template_keyword<tag::name, T>
+struct name : template_keyword<tag::name, T>
{
};
@@ -3383,7 +8876,7 @@ href="../../test/function_type_tpl_param.cpp"
of this macro.
-
Deprecated
@@ -3423,10 +8916,6 @@ class="docutils literal">l < h
- If BOOST_PARAMETER_HAS_PERFECT_FORWARDING is
-#defined, then:
- Expands to:
-
@@ -3443,16 +8932,15 @@ r
return name_with_named_params(
pk(
std::forward<A1>(a1)
+href="http://en.cppreference.com/w/cpp/utility/forward"
+>forward<A1>(a1)
, std::forward<A2>(a2)
+href="http://en.cppreference.com/w/cpp/utility/forward"
+>forward<A2>(a2)
, …
, std::forward<A ## l>(a ## l)
+href="http://en.cppreference.com/w/cpp/utility/forward"
+>forward<A ## l>(a ## l)
)
);
}
@@ -3483,21 +8971,20 @@ href="../../../preprocessor/doc/ref/inc.html">BOOST_PP_INC(name_with_named_params(
pk(
std::forward<A1>(a1)
+href="http://en.cppreference.com/w/cpp/utility/forward"
+>forward<A1>(a1)
, std::forward<A2>(a2)
+href="http://en.cppreference.com/w/cpp/utility/forward"
+>forward<A2>(a2)
, …
, std::forward<A ## l>(a ## l)
+href="http://en.cppreference.com/w/cpp/utility/forward"
+>forward<A ## l>(a ## l)
, std::forward<A ## BOOST_PP_INC(l)>(a ## forward<A ## BOOST_PP_INC(l)>(a ## BOOST_PP_INC(l))
)
@@ -3518,164 +9005,28 @@ r
return name_with_named_params(
pk(
std::forward<A1>(a1)
+href="http://en.cppreference.com/w/cpp/utility/forward"
+>forward<A1>(a1)
, std::forward<A2>(a2)
+href="http://en.cppreference.com/w/cpp/utility/forward"
+>forward<A2>(a2)
, …
, std::forward<A ## h>(a ## h)
+href="http://en.cppreference.com/w/cpp/utility/forward"
+>forward<A ## h>(a ## h)
)
);
}
- If BOOST_PARAMETER_HAS_PERFECT_FORWARDING is not
-#defined, then:
-
-- Expands to:
--
-
-template <typename A1, typename A2, …, typename A ## l>
-r
- name(
- A1 const& a1, A2 const& a2, …, A ## l const& a ## l
- , typename p::match<A1, A2, …, A ## l>::type pk = p()
- )
-{
- return name_with_named_params(pk(a1, a2, …, a ## l));
-}
-
-… exponential number of overloads …
-⋮
-
-template <typename A1, typename A2, …, typename A ## l>
-r
- name(
- A1& a1, A2& a2, …, A ## l & a ## l
- , typename p::match<A1, A2, …, A ## l>::type pk = p()
- )
-{
- return name_with_named_params(pk(a1, a2, …, a ## l));
-}
-
-template <
- typename A1
- , typename A2
- , …
- , typename A ## l
- , typename A ## BOOST_PP_INC(l)
->
-r
- name(
- A1 const& a1, A2 const& a2, …, A ## l const& a ## l
- , A ## BOOST_PP_INC(l) const& a ## BOOST_PP_INC(l)
- , typename p::match<A1, A2, …, Al, A ## BOOST_PP_INC(l)>::type pk = p()
- )
-{
- return name_with_named_params(
- pk(a1, a2, …, a ## l, a ## BOOST_PP_INC(l))
- );
-}
-
-… exponential number of overloads …
-⋮
-
-template <
- typename A1
- , typename A2
- , …
- , typename A ## l
- , typename A ## BOOST_PP_INC(l)
->
-r
- name(
- A1& a1, A2& a2, …, A ## l & a ## l
- , A ## BOOST_PP_INC(l) & a ## BOOST_PP_INC(l)
- , typename p::match<A1, A2, …, Al, A ## BOOST_PP_INC(l)>::type pk = p()
- )
-{
- return name_with_named_params(
- pk(a1, a2, …, a ## l, a ## BOOST_PP_INC(l))
- );
-}
-
-⋮
-
-template <typename A1, typename A2, …, typename A ## h>
-r
- name(
- A1 const& a1, A2 const& a2, …, A ## h const& a ## h
- , typename p::match<A1, A2, …, A ## h>::type pk = p()
- )
-{
- return name_with_named_params(pk(a1, a2, …, a ## h));
-}
-
-… exponential number of overloads …
-⋮
-
-template <typename A1, typename A2, …, typename A ## h>
-r
- name(
- A1& a1, A2& a2, …, A ## h& a ## h
- , typename p::match<A1, A2, …, A ## h>::type pk = p()
- )
-{
- return name_with_named_params(pk(a1, a2, …, a ## h));
-}
-
-
-
The test/macros.cpp and test/macros_eval_category.cpp
test programs demonstrate proper usage of this macro.
7.6 ...Outside Of
+>8.8 ...Outside Of
This Library
- If Boost.Config defines the macro
BOOST_NO_FUNCTION_TEMPLATE_ORDERING,
-then the macro BOOST_NO_FUNCTION_TEMPLATE_ORDERING, then
+the macros BOOST_PARAMETER_HAS_PERFECT_FORWARDING will be left undefined;
-otherwise, the code generation macros would not work correctly.
+>BOOST_PARAMETER_HAS_PERFECT_FORWARDING and BOOST_PARAMETER_CAN_USE_MP11 will be left
+undefined; otherwise, the code generation macros would not work
+correctly.
+If Boost.Config defines the macro
+BOOST_NO_SFINAE, then the macros BOOST_PARAMETER_HAS_PERFECT_FORWARDING and
+BOOST_PARAMETER_CAN_USE_MP11 will be left
+undefined; otherwise, keyword types generated by BOOST_PARAMETER_NAME and BOOST_PARAMETER_NESTED_KEYWORD would not work correctly.
+ If Boost.Config defines the macro
+BOOST_NO_CXX11_RVALUE_REFERENCES, then the
+macros BOOST_PARAMETER_HAS_PERFECT_FORWARDING and BOOST_PARAMETER_CAN_USE_MP11 will be left
+undefined.
+ If Boost.Config defines the macro
+BOOST_NO_CXX11_VARIADIC_TEMPLATES, then the
+macros BOOST_PARAMETER_HAS_PERFECT_FORWARDING and BOOST_PARAMETER_CAN_USE_MP11 will be left
+undefined.
+ If Boost.Config defines the macro
+BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS, then the macros BOOST_PARAMETER_HAS_PERFECT_FORWARDING and BOOST_PARAMETER_CAN_USE_MP11 will be left
+undefined.
+ If Boost.Config defines the macro
+BOOST_NO_CXX11_CONSTEXPR, then the macro BOOST_PARAMETER_CAN_USE_MP11 will be left
+undefined.
If Boost.Config defines the macro
BOOST_NO_SFINAE, then the macro
-BOOST_PARAMETER_HAS_PERFECT_FORWARDING
-will be left undefined; otherwise, keyword types generated by
-BOOST_PARAMETER_NAME and
-BOOST_PARAMETER_NESTED_KEYWORD would
-not work correctly.
+> BOOST_NO_CXX11_DECLTYPE_N3276, then the
+macro BOOST_PARAMETER_CAN_USE_MP11 will be left
+undefined.
If Boost.Config defines the macro
BOOST_NO_CXX11_RVALUE_REFERENCES, then
-the macro BOOST_PARAMETER_HAS_PERFECT_FORWARDING will be left undefined.
+> BOOST_NO_CXX11_AUTO_DECLARATIONS, then
+the macro BOOST_PARAMETER_CAN_USE_MP11 will be
+left undefined.
If Boost.Config defines the macro
BOOST_NO_CXX11_VARIADIC_TEMPLATES, then
-the macro BOOST_PARAMETER_HAS_PERFECT_FORWARDING will be left undefined.
+href="../../../config/doc/html/boost_config/boost_macro_reference.html"> BOOST_NO_CXX11_TEMPLATE_ALIASES, then the
+macro BOOST_PARAMETER_CAN_USE_MP11 will be left
+undefined.
+ If Boost.Config defines the macro
+BOOST_NO_CXX11_STATIC_ASSERT, then the
+macro BOOST_PARAMETER_CAN_USE_MP11 will be left
+undefined.
+ If Boost.Config defines the macro
+BOOST_NO_CXX11_HDR_TYPE_TRAITS, then the
+macro BOOST_PARAMETER_CAN_USE_MP11 will be left
+undefined.
+ If Boost.Config defines the macro
+BOOST_NO_CXX11_HDR_INITIALIZER_LIST, then
+the macro BOOST_PARAMETER_CAN_USE_MP11 will be
+left undefined.
+ If Boost.Config defines the macro
+BOOST_NO_CXX11_HDR_TUPLE, then the macro BOOST_PARAMETER_CAN_USE_MP11 will be left
+undefined.
If Boost.Fusion defines the macro
underlying the nested parameters will be
::boost::fusion::list.
+> boost::fusion::list.
If Boost.Fusion defines the macro
underlying the nested parameters will be
::boost::fusion::deque.
+> boost::fusion::deque.
The value that Boost.MPL defines the macro
- 8 Tutorial
+ 9 Tutorial
Follow this
link to the Boost.Parameter tutorial documentation.
@@ -4117,9 +9633,8 @@ class="docutils literal">BOOST_NO_RESULT_OF is #defined, boost::result_of<F()>::type is replaced by F::result_type. |
+>result_of