transform.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef BOOST_METAPARSE_V1_TRANSFORM_HPP
  2. #define BOOST_METAPARSE_V1_TRANSFORM_HPP
  3. // Copyright Abel Sinkovics ([email protected]) 2009 - 2010.
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #include <boost/metaparse/v1/accept.hpp>
  8. #include <boost/metaparse/v1/get_result.hpp>
  9. #include <boost/metaparse/v1/get_remaining.hpp>
  10. #include <boost/metaparse/v1/get_position.hpp>
  11. #include <boost/metaparse/v1/unless_error.hpp>
  12. #include <boost/mpl/eval_if.hpp>
  13. namespace boost
  14. {
  15. namespace metaparse
  16. {
  17. namespace v1
  18. {
  19. template <class P, class T>
  20. struct transform
  21. {
  22. private:
  23. template <class S, class Pos>
  24. struct no_error :
  25. accept<
  26. typename T::template apply<
  27. typename get_result<typename P::template apply<S, Pos> >::type
  28. >::type,
  29. get_remaining<typename P::template apply<S, Pos> >,
  30. get_position<typename P::template apply<S, Pos> >
  31. >
  32. {};
  33. public:
  34. typedef transform type;
  35. template <class S, class Pos>
  36. struct apply :
  37. unless_error<typename P::template apply<S, Pos>, no_error<S, Pos> >
  38. {};
  39. };
  40. }
  41. }
  42. }
  43. #endif