Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
repeat.hpp File Reference
Include dependency graph for repeat.hpp:
This graph shows which files directly or indirectly include this file:

Macros

#define BOOST_PROTO_ref_a_aux(Z, N, DATA)   boost::ref(BOOST_PP_CAT(proto_a, N))
 INTERNAL ONLY. More...
 
#define BOOST_PROTO_typename_A(N)   BOOST_PP_ENUM_PARAMS(N, typename proto_A)
 Generates a sequence like typename A0, typename A1, ... More...
 
#define BOOST_PROTO_A_const_ref(N)   BOOST_PP_ENUM_BINARY_PARAMS(N, proto_A, const & BOOST_PP_INTERCEPT)
 Generates a sequence like A0 const &, A1 const &, ... More...
 
#define BOOST_PROTO_A_ref(N)   BOOST_PP_ENUM_BINARY_PARAMS(N, proto_A, & BOOST_PP_INTERCEPT)
 Generates a sequence like A0 &, A1 &, ... More...
 
#define BOOST_PROTO_A(N)   BOOST_PP_ENUM_PARAMS(N, proto_A)
 Generates a sequence like A0, A1, ... More...
 
#define BOOST_PROTO_A_const(N)   BOOST_PP_ENUM_PARAMS(N, const proto_A)
 Generates a sequence like A0 const, A1 const, ... More...
 
#define BOOST_PROTO_A_const_ref_a(N)   BOOST_PP_ENUM_BINARY_PARAMS(N, proto_A, const &proto_a)
 Generates a sequence like A0 const &a0, A1 const &a0, ... More...
 
#define BOOST_PROTO_A_ref_a(N)   BOOST_PP_ENUM_BINARY_PARAMS(N, proto_A, &proto_a)
 Generates a sequence like A0 &a0, A1 &a0, ... More...
 
#define BOOST_PROTO_ref_a(N)   BOOST_PP_ENUM(N, BOOST_PROTO_ref_a_aux, ~)
 Generates a sequence like boost::ref(a0), boost::ref(a1), ... More...
 
#define BOOST_PROTO_a(N)   BOOST_PP_ENUM_PARAMS(N, proto_a)
 Generates a sequence like a0, a1, ... More...
 
#define BOOST_PROTO_invoke(Z, N, DATA)   BOOST_PP_TUPLE_ELEM(5,0,DATA)(N, BOOST_PP_TUPLE_ELEM(5,1,DATA), BOOST_PP_TUPLE_ELEM(5,2,DATA), BOOST_PP_TUPLE_ELEM(5,3,DATA), BOOST_PP_TUPLE_ELEM(5,4,DATA))
 INTERNAL ONLY. More...
 
#define BOOST_PROTO_REPEAT_FROM_TO_EX(FROM, TO, MACRO, typename_A, A, A_a, a)   BOOST_PP_REPEAT_FROM_TO(FROM, TO, BOOST_PROTO_invoke, (MACRO, typename_A, A, A_a, a))
 Repeatedly invoke the specified macro. More...
 
#define BOOST_PROTO_REPEAT_FROM_TO(FROM, TO, MACRO)   BOOST_PROTO_REPEAT_FROM_TO_EX(FROM, TO, MACRO, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
 Repeatedly invoke the specified macro. More...
 
#define BOOST_PROTO_REPEAT_EX(MACRO, typename_A, A, A_a, a)   BOOST_PROTO_REPEAT_FROM_TO_EX(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), MACRO, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
 Repeatedly invoke the specified macro. More...
 
#define BOOST_PROTO_REPEAT(MACRO)   BOOST_PROTO_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), MACRO)
 Repeatedly invoke the specified macro. More...
 
#define BOOST_PROTO_LOCAL_ITERATE()   <boost/proto/detail/local.hpp>
 Repeatedly invoke the specified macro. More...
 

Macro Definition Documentation

#define BOOST_PROTO_A (   N)    BOOST_PP_ENUM_PARAMS(N, proto_A)

Generates a sequence like A0, A1, ...

#define BOOST_PROTO_a (   N)    BOOST_PP_ENUM_PARAMS(N, proto_a)

Generates a sequence like a0, a1, ...

#define BOOST_PROTO_A_const (   N)    BOOST_PP_ENUM_PARAMS(N, const proto_A)

Generates a sequence like A0 const, A1 const, ...

#define BOOST_PROTO_A_const_ref (   N)    BOOST_PP_ENUM_BINARY_PARAMS(N, proto_A, const & BOOST_PP_INTERCEPT)

Generates a sequence like A0 const &, A1 const &, ...

#define BOOST_PROTO_A_const_ref_a (   N)    BOOST_PP_ENUM_BINARY_PARAMS(N, proto_A, const &proto_a)

Generates a sequence like A0 const &a0, A1 const &a0, ...

#define BOOST_PROTO_A_ref (   N)    BOOST_PP_ENUM_BINARY_PARAMS(N, proto_A, & BOOST_PP_INTERCEPT)

Generates a sequence like A0 &, A1 &, ...

#define BOOST_PROTO_A_ref_a (   N)    BOOST_PP_ENUM_BINARY_PARAMS(N, proto_A, &proto_a)

Generates a sequence like A0 &a0, A1 &a0, ...

#define BOOST_PROTO_invoke (   Z,
  N,
  DATA 
)    BOOST_PP_TUPLE_ELEM(5,0,DATA)(N, BOOST_PP_TUPLE_ELEM(5,1,DATA), BOOST_PP_TUPLE_ELEM(5,2,DATA), BOOST_PP_TUPLE_ELEM(5,3,DATA), BOOST_PP_TUPLE_ELEM(5,4,DATA))

INTERNAL ONLY.

#define BOOST_PROTO_LOCAL_ITERATE ( )    <boost/proto/detail/local.hpp>

Repeatedly invoke the specified 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:

1 #include BOOST_PROTO_LOCAL_ITERATE()

Example:

1 // Generate BOOST_PROTO_MAX_ARITY-1 overloads of the
2 // following construct() function template.
3 #define BOOST_PROTO_LOCAL_MACRO(N, typename_A, A_const_ref, \
4  A_const_ref_a, ref_a) \
5 template<typename T, typename_A(N)> \
6 typename proto::result_of::make_expr< \
7  proto::tag::function \
8  , construct_helper<T> \
9  , A_const_ref(N) \
10 >::type const \
11 construct(A_const_ref_a(N)) \
12 { \
13  return proto::make_expr< \
14  proto::tag::function \
15  >( \
16  construct_helper<T>() \
17  , ref_a(N) \
18  ); \
19 }
20 #define BOOST_PROTO_LOCAL_LIMITS (1, BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY))
21 #include BOOST_PROTO_LOCAL_ITERATE()

The above inclusion of BOOST_PROTO_LOCAL_ITERATE() will generate the following code:

1 template<typename T, typename A0>
2 typename proto::result_of::make_expr<
3  proto::tag::function
4  , construct_helper<T>
5  , A0 const &
6 >::type const
7 construct(A0 const & a0)
8 {
9  return proto::make_expr<
10  proto::tag::function
11  >(
12  construct_helper<T>()
13  , boost::ref(a0)
14  );
15 }
16 
17 template<typename T, typename A0, typename A1>
18 typename proto::result_of::make_expr<
19  proto::tag::function
20  , construct_helper<T>
21  , A0 const &
22  , A1 const &
23 >::type const
24 construct(A0 const & a0, A1 const & a1)
25 {
26  return proto::make_expr<
27  proto::tag::function
28  >(
29  construct_helper<T>()
30  , boost::ref(a0)
31  , boost::ref(a1)
32  );
33 }
34 
35 // ... 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
#define BOOST_PROTO_ref_a (   N)    BOOST_PP_ENUM(N, BOOST_PROTO_ref_a_aux, ~)

Generates a sequence like boost::ref(a0), boost::ref(a1), ...

#define BOOST_PROTO_ref_a_aux (   Z,
  N,
  DATA 
)    boost::ref(BOOST_PP_CAT(proto_a, N))

INTERNAL ONLY.

#define BOOST_PROTO_REPEAT (   MACRO)    BOOST_PROTO_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), MACRO)

Repeatedly invoke the specified macro.

BOOST_PROTO_REPEAT() is used generate the kind of repetitive code that is typical of EDSLs built with Proto. BOOST_PROTO_REPEAT(MACRO) is equivalent to:

1 MACRO(1, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
2 MACRO(2, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
3 ...
4 MACRO(BOOST_PROTO_MAX_ARITY, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
#define BOOST_PROTO_REPEAT_EX (   MACRO,
  typename_A,
  A,
  A_a,
 
)    BOOST_PROTO_REPEAT_FROM_TO_EX(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), MACRO, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)

Repeatedly invoke the specified macro.

BOOST_PROTO_REPEAT_EX() is used 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:

1 MACRO(1, typename_A, A, A_a, a)
2 MACRO(2, typename_A, A, A_a, a)
3 ...
4 MACRO(BOOST_PROTO_MAX_ARITY, typename_A, A, A_a, a)
#define BOOST_PROTO_REPEAT_FROM_TO (   FROM,
  TO,
  MACRO 
)    BOOST_PROTO_REPEAT_FROM_TO_EX(FROM, TO, MACRO, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)

Repeatedly invoke the specified macro.

BOOST_PROTO_REPEAT_FROM_TO() is used 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:

1 MACRO(FROM, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
2 MACRO(FROM+1, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)
3 ...
4 MACRO(TO-1, BOOST_PROTO_typename_A, BOOST_PROTO_A_const_ref, BOOST_PROTO_A_const_ref_a, BOOST_PROTO_ref_a)

Example:

1 // Generate BOOST_PROTO_MAX_ARITY-1 overloads of the
2 // following construct() function template.
3 #define M0(N, typename_A, A_const_ref, A_const_ref_a, ref_a) \
4 template<typename T, typename_A(N)> \
5 typename proto::result_of::make_expr< \
6  proto::tag::function \
7  , construct_helper<T> \
8  , A_const_ref(N) \
9 >::type const \
10 construct(A_const_ref_a(N)) \
11 { \
12  return proto::make_expr< \
13  proto::tag::function \
14  >( \
15  construct_helper<T>() \
16  , ref_a(N) \
17  ); \
18 }
19 BOOST_PROTO_REPEAT_FROM_TO(1, BOOST_PROTO_MAX_ARITY, M0)
20 #undef M0

The above invocation of BOOST_PROTO_REPEAT_FROM_TO() will generate the following code:

1 template<typename T, typename A0>
2 typename proto::result_of::make_expr<
3  proto::tag::function
4  , construct_helper<T>
5  , A0 const &
6 >::type const
7 construct(A0 const & a0)
8 {
9  return proto::make_expr<
10  proto::tag::function
11  >(
12  construct_helper<T>()
13  , boost::ref(a0)
14  );
15 }
16 
17 template<typename T, typename A0, typename A1>
18 typename proto::result_of::make_expr<
19  proto::tag::function
20  , construct_helper<T>
21  , A0 const &
22  , A1 const &
23 >::type const
24 construct(A0 const & a0, A1 const & a1)
25 {
26  return proto::make_expr<
27  proto::tag::function
28  >(
29  construct_helper<T>()
30  , boost::ref(a0)
31  , boost::ref(a1)
32  );
33 }
34 
35 // ... and so on, up to BOOST_PROTO_MAX_ARITY-1 arguments ...
#define BOOST_PROTO_REPEAT_FROM_TO_EX (   FROM,
  TO,
  MACRO,
  typename_A,
  A,
  A_a,
 
)    BOOST_PP_REPEAT_FROM_TO(FROM, TO, BOOST_PROTO_invoke, (MACRO, typename_A, A, A_a, a))

Repeatedly invoke the specified macro.

BOOST_PROTO_REPEAT_FROM_TO_EX() is used 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:

1 MACRO(FROM, typename_A, A, A_a, a)
2 MACRO(FROM+1, typename_A, A, A_a, a)
3 ...
4 MACRO(TO-1, typename_A, A, A_a, a)
#define BOOST_PROTO_typename_A (   N)    BOOST_PP_ENUM_PARAMS(N, typename proto_A)

Generates a sequence like typename A0, typename A1, ...