Blame view

3rdparty/boost_1_81_0/libs/metaparse/doc/spaces.qbk 1.05 KB
73ef4ff3   Hu Chunming   提交三方库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  [#spaces]
  [section spaces]
  
  [h1 Synopsis]
  
    struct spaces;
  
  This is a [link parser parser].
  
  [h1 Description]
  
  `spaces` accepts any number of whitespace characters. It requires at least one
  to be present.
  
  [h1 Header]
  
    #include <boost/metaparse/spaces.hpp>
  
  [h1 Expression semantics]
  
    spaces
  
  is equivalent to
  
    repeated1<space>
  
  [h1 Example]
  
    #include <boost/metaparse/spaces.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<spaces::apply<BOOST_METAPARSE_STRING("  foo"), start>>::type
      >::type::value,
      "it should consume all whitespaces at the beginning of the input"
    );
    
    static_assert(
      is_error<spaces::apply<BOOST_METAPARSE_STRING("x"), start>>::type::value,
      "it should return an error when the input does not begin with a whitespace"
    );
  
  [endsect]