space.qbk 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. [#space]
  2. [section space]
  3. [h1 Synopsis]
  4. struct space;
  5. This is a [link parser parser].
  6. [h1 Description]
  7. `space` accepts one white space character. The result of parsing is the parsed
  8. character.
  9. [h1 Header]
  10. #include <boost/metaparse/space.hpp>
  11. [h1 Expression semantics]
  12. The following are equivalent:
  13. space
  14. accept_when<one_char, util::is_whitespace<>, errors::whitespace_expected>
  15. [h1 Example]
  16. #include <boost/metaparse/space.hpp>
  17. #include <boost/metaparse/start.hpp>
  18. #include <boost/metaparse/string.hpp>
  19. #include <boost/metaparse/is_error.hpp>
  20. #include <boost/metaparse/get_remaining.hpp>
  21. #include <type_traits>
  22. using namespace boost::metaparse;
  23. static_assert(
  24. std::is_same<
  25. BOOST_METAPARSE_STRING(" foo"),
  26. get_remaining<space::apply<BOOST_METAPARSE_STRING(" foo"), start>>::type
  27. >::type::value,
  28. "it should consume the first space of the input"
  29. );
  30. static_assert(
  31. is_error<space::apply<BOOST_METAPARSE_STRING("x"), start>>::type::value,
  32. "it should return an error when the input does not begin with a whitespace"
  33. );
  34. [endsect]