MCPcopy Create free account
hub / github.com/andreasfertig/programming-with-cpp20 / match

Function match

09.13-fixedString3/main.cpp:47–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45
46template<typename T>
47constexpr static bool match(const char c)
48{
49 switch(c) { // #B Our specifier to type mapping table
50 case 'd': return plain_same_v<int, T>;
51 case 'c': return plain_same_v<char, T>;
52 case 'f': return plain_same_v<double, T>;
53 case 's': // #C Character strings are a bit more difficult
54 return (plain_same_v<char,
55 std::remove_all_extents_t<T>> and
56 std::is_array_v<T>) or
57 (plain_same_v<char*,
58 std::remove_all_extents_t<T>> and
59 std::is_pointer_v<T>);
60 default: return false;
61 }
62}
63
64template<int I, typename CharT>
65constexpr auto get(const std::span<const CharT>& str)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected