MCPcopy Create free account
hub / github.com/boostorg/parser / compile_or_attribute

Function compile_or_attribute

test/compile_or_attribute.cpp:11–382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9using namespace boost::parser;
10
11void compile_or_attribute()
12{
13 char const chars[] = "";
14 auto first = std::begin(chars);
15 auto const last = std::end(chars);
16
17 // scalar and eps
18 {
19 constexpr auto parser = int_ | eps;
20 using attr_t = decltype(prefix_parse(first, last, parser));
21 static_assert(
22 std::is_same_v<attr_t, std::optional<std::optional<int>>>);
23 static_assert(std::is_same_v<
24 attribute_t<
25 decltype(BOOST_PARSER_SUBRANGE(first, last)),
26 decltype(parser)>,
27 std::optional<int>>);
28 }
29
30 // scalar | scalar
31 {
32 constexpr auto parser = char_ | char_;
33 using attr_t = decltype(prefix_parse(first, last, parser));
34 static_assert(std::is_same_v<attr_t, std::optional<char>>);
35 static_assert(std::is_same_v<
36 attribute_t<
37 decltype(BOOST_PARSER_SUBRANGE(first, last)),
38 decltype(parser)>,
39 char>);
40 }
41 {
42 constexpr auto parser = char_ | char_ | eps;
43 using attr_t = decltype(prefix_parse(first, last, parser));
44 static_assert(
45 std::is_same_v<attr_t, std::optional<std::optional<char>>>);
46 static_assert(std::is_same_v<
47 attribute_t<
48 decltype(BOOST_PARSER_SUBRANGE(first, last)),
49 decltype(parser)>,
50 std::optional<char>>);
51 }
52 {
53 constexpr auto parser = int_ | char_;
54 using attr_t = decltype(prefix_parse(first, last, parser));
55 static_assert(
56 std::is_same_v<attr_t, std::optional<std::variant<int, char>>>);
57 static_assert(std::is_same_v<
58 attribute_t<
59 decltype(BOOST_PARSER_SUBRANGE(first, last)),
60 decltype(parser)>,
61 std::variant<int, char>>);
62 }
63 {
64 constexpr auto parser = int_ | char_ | eps;
65 using attr_t = decltype(prefix_parse(first, last, parser));
66 static_assert(std::is_same_v<
67 attr_t,
68 std::optional<std::optional<std::variant<int, char>>>>);

Callers 1

mainFunction · 0.85

Calls 4

prefix_parseFunction · 0.85
beginFunction · 0.50
endFunction · 0.50
stringClass · 0.50

Tested by 1

mainFunction · 0.68