| 1 | #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) |
| 2 | |
| 3 | #include <boost/proto/transform/detail/preprocessed/lazy.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/lazy.hpp") |
| 9 | #endif |
| 10 | |
| 11 | /////////////////////////////////////////////////////////////////////////////// |
| 12 | /// \file lazy.hpp |
| 13 | /// Contains definition of the lazy<> transform. |
| 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, (0, BOOST_PROTO_MAX_ARITY, <boost/proto/transform/detail/lazy.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 |
| 32 | |
| 33 | #define N BOOST_PP_ITERATION() |
| 34 | |
| 35 | /// \brief A PrimitiveTransform that uses <tt>make\<\></tt> to build |
| 36 | /// a CallableTransform, and then uses <tt>call\<\></tt> to apply it. |
| 37 | /// |
| 38 | /// <tt>lazy\<\></tt> is useful as a higher-order transform, when the |
| 39 | /// transform to be applied depends on the current state of the |
| 40 | /// transformation. The invocation of the <tt>make\<\></tt> transform |
| 41 | /// evaluates any nested transforms, and the resulting type is treated |
| 42 | /// as a CallableTransform, which is evaluated with <tt>call\<\></tt>. |
| 43 | template<typename Object BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)> |
| 44 | struct lazy<Object(BOOST_PP_ENUM_PARAMS(N, A))> |
| 45 | : transform<lazy<Object(BOOST_PP_ENUM_PARAMS(N, A))> > |
| 46 | { |
| 47 | template<typename Expr, typename State, typename Data> |
| 48 | struct impl |
| 49 | : call< |
| 50 | typename make<Object>::template impl<Expr, State, Data>::result_type |
| 51 | (BOOST_PP_ENUM_PARAMS(N, A)) |
| 52 | >::template impl<Expr, State, Data> |
| 53 | {}; |
| 54 | }; |
| 55 | |
| 56 | #if N > 0 |
| 57 | template<typename Object BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)> |
| 58 | struct lazy<Object(BOOST_PP_ENUM_PARAMS(N, A)...)> |
| 59 | : transform<lazy<Object(BOOST_PP_ENUM_PARAMS(N, A)...)> > |
| 60 | { |
| 61 | template<typename Expr, typename State, typename Data> |
| 62 | struct impl |
| 63 | : lazy< |
| 64 | typename detail::expand_pattern< |
| 65 | proto::arity_of<Expr>::value |
| 66 | , BOOST_PP_CAT(A, BOOST_PP_DEC(N)) |
| 67 | , detail::BOOST_PP_CAT(expand_pattern_rest_, BOOST_PP_DEC(N))< |
| 68 | Object |
| 69 | BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_DEC(N), A) |
| 70 | > |
| 71 | >::type |
| 72 | >::template impl<Expr, State, Data> |
| 73 | {}; |
| 74 | }; |
| 75 | #endif |
| 76 | |
| 77 | #undef N |
| 78 | |
| 79 | #endif |
| 80 | |