• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[#spaces]
2[section spaces]
3
4[h1 Synopsis]
5
6  struct spaces;
7
8This is a [link parser parser].
9
10[h1 Description]
11
12`spaces` accepts any number of whitespace characters. It requires at least one
13to be present.
14
15[h1 Header]
16
17  #include <boost/metaparse/spaces.hpp>
18
19[h1 Expression semantics]
20
21  spaces
22
23is equivalent to
24
25  repeated1<space>
26
27[h1 Example]
28
29  #include <boost/metaparse/spaces.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<spaces::apply<BOOST_METAPARSE_STRING("  foo"), start>>::type
43    >::type::value,
44    "it should consume all whitespaces at the beginning of the input"
45  );
46
47  static_assert(
48    is_error<spaces::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