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

Function sample2

sample/Extractor-Pattern.cpp:59–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57inline constexpr PhoneNumber phone_number;
58
59void sample2()
60{
61 using namespace matchit;
62
63 using namespace std::literals;
64 // auto const s = "match@it"sv;
65 auto const s = "415123456"sv;
66 Id<std::string_view> address, domain;
67 match(s)(
68 pattern | app(email, some(ds(address, domain))) =
69 [&]
70 { std::cout << "got an email"; },
71 pattern | app(phone_number, some(ds("415", _, _))) =
72 [&]
73 { std::cout << "got a San Francisco phone number"; }
74 // ˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆˆ extractor pattern
75 );
76 std::cout << std::endl;
77}
78
79int32_t main()
80{

Callers 1

mainFunction · 0.70

Calls 3

appFunction · 0.85
matchFunction · 0.50
dsFunction · 0.50

Tested by

no test coverage detected