as_sequence.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // as_sequence.hpp
  3. //
  4. // Copyright 2008 Eric Niebler. Distributed under the Boost
  5. // Software License, Version 1.0. (See accompanying file
  6. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. #ifndef BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_SEQUENCE_HPP_EAN_04_01_2007
  8. #define BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_SEQUENCE_HPP_EAN_04_01_2007
  9. // MS compatible compilers support #pragma once
  10. #if defined(_MSC_VER)
  11. # pragma once
  12. #endif
  13. #include <boost/mpl/assert.hpp>
  14. #include <boost/type_traits/is_same.hpp>
  15. #include <boost/xpressive/detail/detail_fwd.hpp>
  16. #include <boost/xpressive/detail/static/static.hpp>
  17. namespace boost { namespace xpressive { namespace grammar_detail
  18. {
  19. template<typename Grammar, typename Callable = proto::callable>
  20. struct in_sequence : proto::transform<in_sequence<Grammar, Callable> >
  21. {
  22. template<typename Expr, typename State, typename Data>
  23. struct impl : proto::transform_impl<Expr, State, Data>
  24. {
  25. typedef
  26. detail::static_xpression<
  27. typename Grammar::template impl<Expr, State, Data>::result_type
  28. , State
  29. >
  30. result_type;
  31. result_type operator ()(
  32. typename impl::expr_param expr
  33. , typename impl::state_param state
  34. , typename impl::data_param data
  35. ) const
  36. {
  37. return result_type(
  38. typename Grammar::template impl<Expr, State, Data>()(expr, state, data)
  39. , state
  40. );
  41. }
  42. };
  43. };
  44. }}}
  45. #endif