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