• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[#is_error]
2[section is_error]
3
4[h1 Synopsis]
5
6  template <class C>
7  struct is_error;
8
9
10This is a [link lazy_metafunction lazy template metafunction] that supports
11[link currying currying].
12
13[table Arguments
14  [[Name] [Type]]
15  [[`C`]  [[link accept accept] or [link reject reject] value]]
16]
17
18[h1 Description]
19
20Determines if `C` is a parsing error or not. Returns a [link boxed_value boxed]
21boolean value.
22
23[h1 Header]
24
25  #include <boost/metaparse/is_error.hpp>
26
27[h1 Expression semantics]
28
29For any `e` parsing error `is_error<c>::type` is a wrapped compile-time `true`
30value, for any other `c` class `is_error<c>::type` is a wrapped compile-time
31`false` value.
32
33[h1 Example]
34
35  #include <boost/metaparse/is_error.hpp>
36  #include <boost/metaparse/accept.hpp>
37  #include <boost/metaparse/reject.hpp>
38  #include <boost/metaparse/string.hpp>
39  #include <boost/metaparse/start.hpp>
40  #include <boost/metaparse/define_error.hpp>
41
42  #include <type_traits>
43
44  using namespace boost::metaparse;
45
46  BOOST_METAPARSE_DEFINE_ERROR(sample_error, "Sample error message");
47
48  struct returns_reject
49  {
50    typedef reject<sample_error, start> type;
51  };
52
53  static_assert(
54    !is_error<
55      accept<
56        std::integral_constant<int, 13>,
57        BOOST_METAPARSE_STRING("foo"),
58        start
59      >
60    >::type::value,
61    "an accept should not be an error"
62  );
63
64  static_assert(
65    is_error<reject<sample_error, start>>::type::value,
66    "an reject should be an error"
67  );
68
69  static_assert(
70    is_error<>::type::apply<reject<sample_error, start>>::type::value,
71    "it should support currying"
72  );
73
74  static_assert(
75    is_error<returns_reject>::type::value,
76    "it should support lazy evaluation"
77  );
78
79[endsect]
80
81