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

Function Formatter

12.19-constevalParmCheck1/main.cpp:122–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120
121template<typename T, class... Args>
122constexpr void Formatter(string& buffer,
123 std::string_view v,
124 const T& t,
125 const Args&... args)
126{
127 using PT = std::remove_cv_t<T>;
128
129 if constexpr(std::is_same_v<int, PT>) {
130 if('d' != v[0]) { throw int{3}; }
131 buffer.append(itoa(t));
132
133 } else if constexpr(std::is_convertible_v<PT, std::string_view>) {
134 if('s' != v[0]) { throw int{4}; }
135 buffer.append(t);
136
137 } else {
138 throw int{6};
139 }
140
141 v.remove_prefix(1);
142
143 if constexpr(sizeof...(Args) > 0) {
144 Formatter<Args...>(buffer, v, args...);
145 }
146}
147
148template<class... Args>
149struct basic_format_string {

Callers 2

basic_format_stringMethod · 0.70
formatFunction · 0.70

Calls 1

itoaFunction · 0.70

Tested by

no test coverage detected