]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) |
2 | ||
3 | #include <boost/proto/detail/preprocessed/and_n.hpp> | |
4 | ||
5 | #elif !defined(BOOST_PP_IS_ITERATING) | |
6 | ||
7 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) | |
8 | #pragma wave option(preserve: 2, line: 0, output: "preprocessed/and_n.hpp") | |
9 | #endif | |
10 | ||
11 | /////////////////////////////////////////////////////////////////////////////// | |
12 | /// \file and_n.hpp | |
13 | /// Definitions of and_N, and_impl | |
14 | // | |
15 | // Copyright 2008 Eric Niebler. Distributed under the Boost | |
16 | // Software License, Version 1.0. (See accompanying file | |
17 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
18 | ||
19 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) | |
20 | #pragma wave option(preserve: 1) | |
21 | #endif | |
22 | ||
23 | #define BOOST_PP_ITERATION_PARAMS_1 \ | |
24 | (3, (2, BOOST_PP_MAX(BOOST_PROTO_MAX_ARITY, BOOST_PROTO_MAX_LOGICAL_ARITY), <boost/proto/detail/and_n.hpp>)) | |
25 | #include BOOST_PP_ITERATE() | |
26 | ||
27 | #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) | |
28 | #pragma wave option(output: null) | |
29 | #endif | |
30 | ||
31 | #else // BOOST_PP_IS_ITERATING | |
32 | ||
33 | #define N BOOST_PP_ITERATION() | |
34 | ||
35 | // Assymetry here between the handling of and_N and or_N because | |
36 | // and_N is used by lambda_matches up to BOOST_PROTO_MAX_ARITY, | |
37 | // regardless of how low BOOST_PROTO_MAX_LOGICAL_ARITY is. | |
38 | template<bool B, BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(N), typename P)> | |
39 | struct BOOST_PP_CAT(and_, N) | |
40 | #if 2 == N | |
41 | : mpl::bool_<P0::value> | |
42 | {}; | |
43 | #else | |
44 | : BOOST_PP_CAT(and_, BOOST_PP_DEC(N))< | |
45 | P0::value BOOST_PP_COMMA_IF(BOOST_PP_SUB(N,2)) | |
46 | BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_DEC(N), P) | |
47 | > | |
48 | {}; | |
49 | #endif | |
50 | ||
51 | template<BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(N), typename P)> | |
52 | struct BOOST_PP_CAT(and_, N)<false, BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(N), P)> | |
53 | : mpl::false_ | |
54 | {}; | |
55 | ||
56 | #if N <= BOOST_PROTO_MAX_LOGICAL_ARITY | |
57 | ||
58 | template<BOOST_PP_ENUM_PARAMS(N, typename G), typename Expr, typename State, typename Data> | |
59 | struct _and_impl<proto::and_<BOOST_PP_ENUM_PARAMS(N, G)>, Expr, State, Data> | |
60 | : proto::transform_impl<Expr, State, Data> | |
61 | { | |
62 | #define M0(Z, N, DATA) \ | |
63 | typedef \ | |
64 | typename proto::when<proto::_, BOOST_PP_CAT(G, N)> \ | |
65 | ::template impl<Expr, State, Data> \ | |
66 | BOOST_PP_CAT(Gimpl, N); \ | |
67 | /**/ | |
68 | BOOST_PP_REPEAT(N, M0, ~) | |
69 | #undef M0 | |
70 | ||
71 | typedef typename BOOST_PP_CAT(Gimpl, BOOST_PP_DEC(N))::result_type result_type; | |
72 | ||
73 | result_type operator()( | |
74 | typename _and_impl::expr_param e | |
75 | , typename _and_impl::state_param s | |
76 | , typename _and_impl::data_param d | |
77 | ) const | |
78 | { | |
79 | // Fix: jfalcou - 12/29/2010 | |
80 | // Avoid the use of comma operator here so as not to find Proto's | |
81 | // by accident. | |
82 | // expands to G0()(e,s,d); G1()(e,s,d); ... G{N-1}()(e,s,d); | |
83 | #define M0(Z,N,DATA) BOOST_PP_CAT(Gimpl,N)()(e,s,d); | |
84 | BOOST_PP_REPEAT(BOOST_PP_DEC(N),M0,~) | |
85 | return BOOST_PP_CAT(Gimpl,BOOST_PP_DEC(N))()(e,s,d); | |
86 | #undef M0 | |
87 | } | |
88 | }; | |
89 | ||
90 | #endif | |
91 | ||
92 | #undef N | |
93 | ||
94 | #endif |