| 35 | |
| 36 | template<typename T, class... Args> |
| 37 | void Formatter(string& buffer, |
| 38 | std::string_view v, |
| 39 | const T& t, |
| 40 | const Args&... args) |
| 41 | { |
| 42 | using PT = std::remove_cv_t<T>; |
| 43 | |
| 44 | if constexpr(std::is_same_v<int, PT>) { |
| 45 | if('d' != v[0]) { throw int{3}; } |
| 46 | buffer.append(itoa(t)); |
| 47 | |
| 48 | } else if constexpr(std::is_convertible_v<PT, std::string_view>) { |
| 49 | if('s' != v[0]) { throw int{4}; } |
| 50 | buffer.append(t); |
| 51 | |
| 52 | } else { |
| 53 | throw int{6}; |
| 54 | } |
| 55 | |
| 56 | v.remove_prefix(1); |
| 57 | |
| 58 | if constexpr(sizeof...(Args) > 0) { Formatter<Args...>(buffer, v, args...); } |
| 59 | } |
| 60 | |
| 61 | template<class... Args> |
| 62 | string format(std::string_view fmt, const Args&... args); |