Macro BOOST_PROTO_LOCAL_ITERATE
BOOST_PROTO_LOCAL_ITERATE — Vertical repetition of a user-supplied macro.
Synopsis
BOOST_PROTO_LOCAL_ITERATE()
Description
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:
#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()
Вышеприведенное включение<BOOST_PROTO_LOCAL_ITERATE()
>сгенерирует следующий код:
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)
);
}
Если<BOOST_PROTO_LOCAL_LIMITS
>не определен пользователем, то по умолчанию<(1, BOOST_PROTO_MAX_ARITY)
>.
На каждой итерации<BOOST_PROTO_LOCAL_MACRO()
>вызывается текущий номер итерации и следующие 4 макропараметра:
- <
BOOST_PROTO_LOCAL_typename_A
>
- <
BOOST_PROTO_LOCAL_A
>
- <
BOOST_PROTO_LOCAL_A_a
>
- <
BOOST_PROTO_LOCAL_a
>
Если эти макросы не определены пользователем, они по умолчанию соответственно:
После включения<BOOST_PROTO_LOCAL_ITERATE()
>следующие макросы автоматически не определяются:
- <
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
>