Chris@16: #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) Chris@16: Chris@16: #include Chris@16: Chris@16: #elif !defined(BOOST_PP_IS_ITERATING) Chris@16: Chris@16: #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) Chris@16: #pragma wave option(preserve: 2, line: 0, output: "preprocessed/when.hpp") Chris@16: #endif Chris@16: Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: /// \file when.hpp Chris@16: /// Definition of when transform. Chris@16: // Chris@16: // Copyright 2008 Eric Niebler. Distributed under the Boost Chris@16: // Software License, Version 1.0. (See accompanying file Chris@16: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) Chris@16: #pragma wave option(preserve: 1) Chris@16: #endif Chris@16: Chris@16: #define BOOST_PP_ITERATION_PARAMS_1 \ Chris@16: (3, (0, BOOST_PROTO_MAX_ARITY, )) Chris@16: #include BOOST_PP_ITERATE() Chris@16: Chris@16: #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) Chris@16: #pragma wave option(output: null) Chris@16: #endif Chris@16: Chris@16: #else Chris@16: Chris@16: #define N BOOST_PP_ITERATION() Chris@16: Chris@16: /// \brief A grammar element and a PrimitiveTransform that associates Chris@16: /// a transform with the grammar. Chris@16: /// Chris@16: /// Use when\<\> to override a grammar's default transform Chris@16: /// with a custom transform. It is for used when composing larger Chris@16: /// transforms by associating smaller transforms with individual Chris@16: /// rules in your grammar, as in the following transform which Chris@16: /// counts the number of terminals in an expression. Chris@16: /// Chris@16: /// \code Chris@16: /// // Count the terminals in an expression tree. Chris@16: /// // Must be invoked with initial state == mpl::int_<0>(). Chris@16: /// struct CountLeaves Chris@16: /// : or_< Chris@16: /// when, mpl::next<_state>()> Chris@16: /// , otherwise > Chris@16: /// > Chris@16: /// {}; Chris@16: /// \endcode Chris@16: /// Chris@16: /// The when\ form accepts either a Chris@16: /// CallableTransform or an ObjectTransform as its second parameter. Chris@16: /// when\<\> uses is_callable\::value to Chris@16: /// distinguish between the two, and uses call\<\> to Chris@16: /// evaluate CallableTransforms and make\<\> to evaluate Chris@16: /// ObjectTransforms. Chris@16: template Chris@16: struct when Chris@16: : detail::when_impl Chris@16: {}; Chris@16: Chris@16: #if N > 0 Chris@16: /// \brief A grammar element and a PrimitiveTransform that associates Chris@16: /// a transform with the grammar. Chris@16: /// Chris@16: /// Use when\<\> to override a grammar's default transform Chris@16: /// with a custom transform. It is for used when composing larger Chris@16: /// transforms by associating smaller transforms with individual Chris@16: /// rules in your grammar, as in the following transform which Chris@16: /// counts the number of terminals in an expression. Chris@16: /// Chris@16: /// \code Chris@16: /// // Count the terminals in an expression tree. Chris@16: /// // Must be invoked with initial state == mpl::int_<0>(). Chris@16: /// struct CountLeaves Chris@16: /// : or_< Chris@16: /// when, mpl::next<_state>()> Chris@16: /// , otherwise > Chris@16: /// > Chris@16: /// {}; Chris@16: /// \endcode Chris@16: /// Chris@16: /// The when\ form accepts either a Chris@16: /// CallableTransform or an ObjectTransform as its second parameter. Chris@16: /// when\<\> uses is_callable\::value to Chris@16: /// distinguish between the two, and uses call\<\> to Chris@16: /// evaluate CallableTransforms and make\<\> to evaluate Chris@16: /// ObjectTransforms. Chris@16: template Chris@16: struct when Chris@16: : detail::when_impl Chris@16: {}; Chris@16: #endif Chris@16: Chris@16: #undef N Chris@16: Chris@16: #endif