get_message.qbk 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. [#get_message]
  2. [section get_message]
  3. [h1 Synopsis]
  4. template <class E>
  5. struct get_message;
  6. This is a [link lazy_metafunction lazy template metafunction].
  7. [table Arguments
  8. [[Name] [Type]]
  9. [[`E`] [[link reject reject] value]]
  10. ]
  11. [h1 Description]
  12. Returns the error message of a parsing failure.
  13. [h1 Header]
  14. #include <boost/metaparse/get_message.hpp>
  15. [h1 Example]
  16. #include <boost/metaparse/get_message.hpp>
  17. #include <boost/metaparse/start.hpp>
  18. #include <boost/metaparse/reject.hpp>
  19. #include <boost/metaparse/define_error.hpp>
  20. #include <type_traits>
  21. using namespace boost::metaparse;
  22. BOOST_METAPARSE_DEFINE_ERROR(sample_error, "Sample error message");
  23. struct returns_reject
  24. {
  25. using type = reject<sample_error, start>;
  26. };
  27. static_assert(
  28. std::is_same<
  29. sample_error,
  30. get_message<reject<sample_error, start>>::type
  31. >::type::value,
  32. "It should return the message"
  33. );
  34. static_assert(
  35. std::is_same<sample_error, get_message<returns_reject>::type>::type::value,
  36. "It should support lazy evaluation"
  37. );
  38. [endsect]