MCPcopy Create free account
hub / github.com/BowenFu/matchit.cpp / detectTuplePattern

Function detectTuplePattern

sample/detectTuplePattern.cpp:6–17  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5template <typename Tuple>
6constexpr int32_t detectTuplePattern(Tuple const &tuple)
7{
8 using namespace matchit;
9 return match(tuple)(
10 // clang-format off
11 pattern | ds(2, ooo, 2) = expr(4),
12 pattern | ds(2, ooo ) = expr(3),
13 pattern | ds(ooo, 2 ) = expr(2),
14 pattern | ds(ooo ) = expr(1)
15 // clang-format on
16 );
17}
18
19static_assert(detectTuplePattern(std::make_tuple(2, 3, 5, 7, 2)) == 4);
20

Callers 2

mainFunction · 0.85

Calls 3

matchFunction · 0.50
dsFunction · 0.50
exprFunction · 0.50

Tested by

no test coverage detected