except.hpp 922 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef BOOST_METAPARSE_V1_EXCEPT_HPP
  2. #define BOOST_METAPARSE_V1_EXCEPT_HPP
  3. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2009 - 2011.
  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/is_error.hpp>
  8. #include <boost/metaparse/v1/accept.hpp>
  9. #include <boost/metaparse/v1/reject.hpp>
  10. #include <boost/mpl/if.hpp>
  11. namespace boost
  12. {
  13. namespace metaparse
  14. {
  15. namespace v1
  16. {
  17. template <class P, class Result, class ErrorMsg>
  18. struct except
  19. {
  20. typedef except type;
  21. template <class S, class Pos>
  22. struct apply :
  23. boost::mpl::if_<
  24. is_error<typename P::template apply<S, Pos> >,
  25. accept<Result, S, Pos>,
  26. reject<ErrorMsg, Pos>
  27. >
  28. {};
  29. };
  30. }
  31. }
  32. }
  33. #endif