123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- #ifndef BOOST_SPIRIT_CLASSIC_PHOENIX_PRIMITIVES_HPP
- #define BOOST_SPIRIT_CLASSIC_PHOENIX_PRIMITIVES_HPP
- #include <boost/spirit/home/classic/phoenix/actor.hpp>
- namespace phoenix {
- template <int N>
- struct argument {
- template <typename TupleT>
- struct result { typedef typename tuple_element<N, TupleT>::type type; };
- template <typename TupleT>
- typename tuple_element<N, TupleT>::type
- eval(TupleT const& args) const
- {
- tuple_index<N> const idx;
- return args[idx];
- }
- };
- actor<argument<0> > const arg1 = argument<0>();
- actor<argument<1> > const arg2 = argument<1>();
- actor<argument<2> > const arg3 = argument<2>();
- #if PHOENIX_LIMIT > 3
- actor<argument<3> > const arg4 = argument<3>();
- actor<argument<4> > const arg5 = argument<4>();
- actor<argument<5> > const arg6 = argument<5>();
- #if PHOENIX_LIMIT > 6
- actor<argument<6> > const arg7 = argument<6>();
- actor<argument<7> > const arg8 = argument<7>();
- actor<argument<8> > const arg9 = argument<8>();
- #if PHOENIX_LIMIT > 9
- actor<argument<9> > const arg10 = argument<9>();
- actor<argument<10> > const arg11 = argument<10>();
- actor<argument<11> > const arg12 = argument<11>();
- #if PHOENIX_LIMIT > 12
- actor<argument<12> > const arg13 = argument<12>();
- actor<argument<13> > const arg14 = argument<13>();
- actor<argument<14> > const arg15 = argument<14>();
- #endif
- #endif
- #endif
- #endif
- template <typename T>
- struct value {
- typedef typename boost::remove_reference<T>::type plain_t;
- template <typename TupleT>
- struct result { typedef plain_t const type; };
- value(plain_t val_)
- : val(val_) {}
- template <typename TupleT>
- plain_t const
- eval(TupleT const& ) const
- {
- return val;
- }
- plain_t val;
- };
- template <typename T>
- inline actor<value<T> > const
- val(T v)
- {
- return value<T>(v);
- }
- template <typename BaseT>
- void
- val(actor<BaseT> const& v);
- template <typename T>
- struct as_actor {
- typedef actor<value<T> > type;
- static type convert(T const& x)
- { return value<T>(x); }
- };
- template <typename T, int N>
- struct as_actor<T[N]> {
- typedef actor<value<T const*> > type;
- static type convert(T const x[N])
- { return value<T const*>(x); }
- };
- #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
- #pragma warning(push)
- #pragma warning(disable:4512)
- #endif
- template <typename T>
- struct variable {
- template <typename TupleT>
- struct result { typedef T& type; };
- variable(T& var_)
- : var(var_) {}
- template <typename TupleT>
- T&
- eval(TupleT const& ) const
- {
- return var;
- }
- T& var;
- };
- #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
- #pragma warning(pop)
- #endif
- template <typename T>
- inline actor<variable<T> > const
- var(T& v)
- {
- return variable<T>(v);
- }
- template <typename T>
- inline actor<variable<T const> > const
- const_(T const& v)
- {
- return variable<T const>(v);
- }
- template <typename BaseT>
- void
- var(actor<BaseT> const& v);
- template <typename BaseT>
- void
- const_(actor<BaseT> const& v);
- }
- #endif
|