• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[#is_whitespace]
2[section is_whitespace]
3
4[h1 Synopsis]
5
6  namespace util
7  {
8    template <class C>
9    struct is_whitespace;
10  }
11
12This is a [link lazy_metafunction lazy template metafunction] that supports
13[link currying currying].
14
15[table Arguments
16  [[Name] [Type]]
17  [[`C`]  [[link boxed_value boxed] character value]]
18]
19
20[h1 Description]
21
22Checks if `C` is a whitespace character. Returns a boxed boolean value.
23
24[h1 Header]
25
26  #include <boost/metaparse/util/is_whitespace.hpp>
27
28[h1 Expression semantics]
29
30For any `C` nullary template metafunction returning a wrapped character value
31the following are equivalent:
32
33  is_whitespace<C>::type
34  is_whitespace<>::type::apply<C>::type
35  is_whitespace_c<C::type::value>::type
36
37[h1 Example]
38
39  #include <boost/metaparse/util/is_whitespace.hpp>
40
41  #include <type_traits>
42
43  using namespace boost::metaparse;
44
45  struct returns_char
46  {
47    using type = std::integral_constant<char, ' '>;
48  };
49
50  static_assert(
51    util::is_whitespace<std::integral_constant<char, ' '>>::type::value,
52    "a space should be a whitespace character"
53  );
54
55  static_assert(
56    !util::is_whitespace<std::integral_constant<char, '0'>>::type::value,
57    "a number should not be a whitespace character"
58  );
59
60  static_assert(
61    util::is_whitespace<>::type
62      ::apply<std::integral_constant<char, '\t'>>::type::value,
63    "it should support currying"
64  );
65
66  static_assert(
67    util::is_whitespace<returns_char>::type::value,
68    "it should support lazy evaluation"
69  );
70
71[endsect]
72
73