spaces.qbk 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. [#spaces]
  2. [section spaces]
  3. [h1 Synopsis]
  4. struct spaces;
  5. This is a [link parser parser].
  6. [h1 Description]
  7. `spaces` accepts any number of whitespace characters. It requires at least one
  8. to be present.
  9. [h1 Header]
  10. #include <boost/metaparse/spaces.hpp>
  11. [h1 Expression semantics]
  12. spaces
  13. is equivalent to
  14. repeated1<space>
  15. [h1 Example]
  16. #include <boost/metaparse/spaces.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<spaces::apply<BOOST_METAPARSE_STRING(" foo"), start>>::type
  27. >::type::value,
  28. "it should consume all whitespaces at the beginning of the input"
  29. );
  30. static_assert(
  31. is_error<spaces::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]