Contains macros to ease the generation of repetitious code constructs.
Repeatedly invoke the specified macro.
BOOST_PROTO_REPEAT() is used to generate the kind of repetitive
code that is typical of EDSLs built with Proto.
BOOST_PROTO_REPEAT(MACRO)
is equivalent to:
MACRO(1, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
MACRO(2, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
...
MACRO(BOOST_PROTO_MAX_ARITY, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
Example:
See BOOST_PROTO_REPEAT_FROM_TO().
Repeatedly invoke the specified macro.
BOOST_PROTO_REPEAT_FROM_TO() is used to generate the kind of repetitive
code that is typical of EDSLs built with Proto.
BOOST_PROTO_REPEAT_FROM_TO(FROM, TO, MACRO)
is equivalent to:
MACRO(FROM, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
MACRO(FROM+1, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
...
MACRO(TO-1, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
Example:
// Generate BOOST_PROTO_MAX_ARITY-1 overloads of the
// following construct() function template.
#define M0(N, typename_A, A_const_ref, A_const_ref_a, ref_a) \
template<typename T, typename_A(N)> \
typename proto::result_of::make_expr< \
proto::tag::function \
, construct_helper<T> \
, A_const_ref(N) \
>::type const \
construct(A_const_ref_a(N)) \
{ \
return proto::make_expr< \
proto::tag::function \
>( \
construct_helper<T>() \
, ref_a(N) \
); \
}
BOOST_PROTO_REPEAT_FROM_TO(1, BOOST_PROTO_MAX_ARITY, M0)
#undef M0
The above invocation of BOOST_PROTO_REPEAT_FROM_TO()
will generate the following code:
template<typename T, typename A0>
typename proto::result_of::make_expr<
proto::tag::function
, construct_helper<T>
, A0 const &
>::type const
construct(A0 const & a0)
{
return proto::make_expr<
proto::tag::function
>(
construct_helper<T>()
, boost::ref(a0)
);
}
template<typename T, typename A0, typename A1>
typename proto::result_of::make_expr<
proto::tag::function
, construct_helper<T>
, A0 const &
, A1 const &
>::type const
construct(A0 const & a0, A1 const & a1)
{
return proto::make_expr<
proto::tag::function
>(
construct_helper<T>()
, boost::ref(a0)
, boost::ref(a1)
);
}
// ... and so on, up to BOOST_PROTO_MAX_ARITY-1 arguments ...
Repeatedly invoke the specified macro.
BOOST_PROTO_REPEAT_EX() is used to generate the kind of repetitive
code that is typical of EDSLs built with Proto.
BOOST_PROTO_REPEAT_EX(MACRO, typename_A, A, A_a, a)
is equivalent to:
MACRO(1, typename_A, A, A_a, a)
MACRO(2, typename_A, A, A_a, a)
...
MACRO(BOOST_PROTO_MAX_ARITY, typename_A, A, A_a, a)
Example:
See BOOST_PROTO_REPEAT_FROM_TO().
Repeatedly invoke the specified macro.
BOOST_PROTO_REPEAT_FROM_TO_EX() is used to generate the kind of repetitive
code that is typical of EDSLs built with Proto.
BOOST_PROTO_REPEAT_FROM_TO_EX(FROM, TO, MACRO, typename_A, A, A_a, a)
is equivalent to:
MACRO(FROM, typename_A, A, A_a, a)
MACRO(FROM+1, typename_A, A, A_a, a)
...
MACRO(TO-1, typename_A, A, A_a, a)
Example:
See BOOST_PROTO_REPEAT_FROM_TO().
Vertical repetition of a user-supplied macro.
BOOST_PROTO_LOCAL_ITERATE() is used generate the kind of repetitive code that is typical
of EDSLs built with Proto. This macro causes the user-defined macro BOOST_PROTO_LOCAL_MACRO() to
be expanded with values in the range specified by BOOST_PROTO_LOCAL_LIMITS.
Usage:
#include BOOST_PROTO_LOCAL_ITERATE()
Example:
// Generate BOOST_PROTO_MAX_ARITY-1 overloads of the
// following construct() function template.
#define BOOST_PROTO_LOCAL_MACRO(N, typename_A, A_const_ref, A_const_ref_a, ref_a)\
template<typename T, typename_A(N)> \
typename proto::result_of::make_expr< \
proto::tag::function \
, construct_helper<T> \
, A_const_ref(N) \
>::type const \
construct(A_const_ref_a(N)) \
{ \
return proto::make_expr< \
proto::tag::function \
>( \
construct_helper<T>() \
, ref_a(N) \
); \
}
#define BOOST_PROTO_LOCAL_LIMITS (1, BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY))
#include BOOST_PROTO_LOCAL_ITERATE()
The above inclusion of BOOST_PROTO_LOCAL_ITERATE()
will generate the following code:
template<typename T, typename A0>
typename proto::result_of::make_expr<
proto::tag::function
, construct_helper<T>
, A0 const &
>::type const
construct(A0 const & a0)
{
return proto::make_expr<
proto::tag::function
>(
construct_helper<T>()
, boost::ref(a0)
);
}
template<typename T, typename A0, typename A1>
typename proto::result_of::make_expr<
proto::tag::function
, construct_helper<T>
, A0 const &
, A1 const &
>::type const
construct(A0 const & a0, A1 const & a1)
{
return proto::make_expr<
proto::tag::function
>(
construct_helper<T>()
, boost::ref(a0)
, boost::ref(a1)
);
}
// ... and so on, up to BOOST_PROTO_MAX_ARITY-1 arguments ...
If BOOST_PROTO_LOCAL_LIMITS is not defined by the user, it defaults
to (1, BOOST_PROTO_MAX_ARITY).
At each iteration, BOOST_PROTO_LOCAL_MACRO() is invoked with the current
iteration number and the following 4 macro parameters:
BOOST_PROTO_LOCAL_typename_A
BOOST_PROTO_LOCAL_A
BOOST_PROTO_LOCAL_A_a
BOOST_PROTO_LOCAL_a
If these macros are not defined by the user, they default respectively to:
BOOST_PROTO_typename_A
BOOST_PROTO_A_const_ref
BOOST_PROTO_A_const_ref_a
BOOST_PROTO_ref_a
After including BOOST_PROTO_LOCAL_ITERATE(), the
following macros are automatically undefined:
BOOST_PROTO_LOCAL_MACRO
BOOST_PROTO_LOCAL_LIMITS
BOOST_PROTO_LOCAL_typename_A
BOOST_PROTO_LOCAL_A
BOOST_PROTO_LOCAL_A_a
BOOST_PROTO_LOCAL_a
Generates sequences like
typename A0,
typename A1, …
typename AN-1
.
Intended for use with the BOOST_PROTO_REPEAT()
and BOOST_PROTO_LOCAL_ITERATE() macros.
BOOST_PROTO_typename_A(N) generates sequences like:
typename A0, typename A1, … typename AN-1
Generates sequences like
A0 const &,
A1 const &, …
AN-1 const &
.
Intended for use with the BOOST_PROTO_REPEAT()
and BOOST_PROTO_LOCAL_ITERATE() macros.
BOOST_PROTO_A_const_ref(N) generates sequences like:
A0 const &, A1 const &, … AN-1 const &
Generates sequences like
A0 &,
A1 &, …
AN-1 &
.
Intended for use with the BOOST_PROTO_REPEAT()
and BOOST_PROTO_LOCAL_ITERATE() macros.
BOOST_PROTO_A_ref(N) generates sequences like:
A0 &, A1 &, … AN-1 &
Generates sequences like
A0,
A1, …
AN-1
.
Intended for use with the BOOST_PROTO_REPEAT()
and BOOST_PROTO_LOCAL_ITERATE() macros.
BOOST_PROTO_A(N) generates sequences like:
A0, A1, … AN-1
Generates sequences like
A0 const,
A1 const, …
AN-1 const
.
Intended for use with the BOOST_PROTO_REPEAT()
and BOOST_PROTO_LOCAL_ITERATE() macros.
BOOST_PROTO_A_const(N) generates sequences like:
A0 const, A1 const, … AN-1 const
Generates sequences like
A0 const & a0,
A1 const & a1, …
AN-1 const & aN-1
.
Intended for use with the BOOST_PROTO_REPEAT()
and BOOST_PROTO_LOCAL_ITERATE() macros.
BOOST_PROTO_A_const_ref_a(N) generates sequences like:
A0 const & a0, A1 const & a1, … AN-1 const & aN-1
Generates sequences like
A0 & a0,
A1 & a1, …
AN-1 & aN-1
.
Intended for use with the BOOST_PROTO_REPEAT()
and BOOST_PROTO_LOCAL_ITERATE() macros.
BOOST_PROTO_A_ref_a(N) generates sequences like:
A0 & a0, A1 & a1, … AN-1 & aN-1
Generates sequences like
boost::ref(a0),
boost::ref(a1), …
boost::ref(aN-1)
.
Intended for use with the BOOST_PROTO_REPEAT()
and BOOST_PROTO_LOCAL_ITERATE() macros.
BOOST_PROTO_ref_a(N) generates sequences like:
boost::ref(a0), boost::ref(a1), … boost::ref(aN-1)
Generates sequences like
a0,
a1, …
aN-1
.
Intended for use with the BOOST_PROTO_REPEAT()
and BOOST_PROTO_LOCAL_ITERATE() macros.
BOOST_PROTO_a(N) generates sequences like:
a0, a1, … aN-1