1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- [#space]
- [section space]
- [h1 Synopsis]
- struct space;
- This is a [link parser parser].
- [h1 Description]
- `space` accepts one white space character. The result of parsing is the parsed
- character.
- [h1 Header]
- #include <boost/metaparse/space.hpp>
- [h1 Expression semantics]
- The following are equivalent:
- space
-
- accept_when<one_char, util::is_whitespace<>, errors::whitespace_expected>
- [h1 Example]
- #include <boost/metaparse/space.hpp>
- #include <boost/metaparse/start.hpp>
- #include <boost/metaparse/string.hpp>
- #include <boost/metaparse/is_error.hpp>
- #include <boost/metaparse/get_remaining.hpp>
-
- #include <type_traits>
-
- using namespace boost::metaparse;
-
- static_assert(
- std::is_same<
- BOOST_METAPARSE_STRING(" foo"),
- get_remaining<space::apply<BOOST_METAPARSE_STRING(" foo"), start>>::type
- >::type::value,
- "it should consume the first space of the input"
- );
-
- static_assert(
- is_error<space::apply<BOOST_METAPARSE_STRING("x"), start>>::type::value,
- "it should return an error when the input does not begin with a whitespace"
- );
- [endsect]
|