|
6 | 6 | #include <string_view> |
7 | 7 | #include <cstring> |
8 | 8 | #include <iterator> |
9 | | -#ifdef __cpp_lib_format |
10 | | -# include <format> |
11 | | -#endif |
| 9 | +#include <format> |
12 | 10 | #include "ecsact/runtime/common.h" |
13 | 11 | #include "ecsact/codegen/plugin.h" |
14 | 12 |
|
@@ -106,37 +104,35 @@ struct codegen_plugin_context { |
106 | 104 | } |
107 | 105 | } |
108 | 106 |
|
109 | | -#ifdef __cpp_lib_format |
110 | 107 | template<typename... Args> |
111 | 108 | auto writef(std::format_string<Args...> fmt, Args&&... args) { |
112 | | - auto str = std::format(fmt, std::make_format_args(args...)); |
| 109 | + auto str = std::format(fmt, std::forward(args)...); |
113 | 110 | write_(str.data(), static_cast<int32_t>(str.size())); |
114 | 111 | } |
115 | 112 |
|
116 | 113 | template<typename... Args> |
117 | 114 | auto info(std::format_string<Args...> fmt, Args&&... args) { |
118 | | - auto str = std::format(fmt, std::make_format_args(args...)); |
| 115 | + auto str = std::format(fmt, std::forward<Args>(args)...); |
119 | 116 | report_(ECSACT_CODEGEN_REPORT_INFO, str.data(), str.size()); |
120 | 117 | } |
121 | 118 |
|
122 | 119 | template<typename... Args> |
123 | 120 | auto warn(std::format_string<Args...> fmt, Args&&... args) { |
124 | | - auto str = std::format(fmt, std::make_format_args(args...)); |
| 121 | + auto str = std::format(fmt, std::forward<Args>(args)...); |
125 | 122 | report_(ECSACT_CODEGEN_REPORT_WARNING, str.data(), str.size()); |
126 | 123 | } |
127 | 124 |
|
128 | 125 | template<typename... Args> |
129 | 126 | auto error(std::format_string<Args...> fmt, Args&&... args) { |
130 | | - auto str = std::format(fmt, std::make_format_args(args...)); |
| 127 | + auto str = std::format(fmt, std::forward<Args>(args)...); |
131 | 128 | report_(ECSACT_CODEGEN_REPORT_ERROR, str.data(), str.size()); |
132 | 129 | } |
133 | 130 |
|
134 | 131 | template<typename... Args> |
135 | 132 | auto fatal(std::format_string<Args...> fmt, Args&&... args) { |
136 | | - auto str = std::format(fmt, std::make_format_args(args...)); |
| 133 | + auto str = std::format(fmt, std::forward<Args>(args)...); |
137 | 134 | report_(ECSACT_CODEGEN_REPORT_FATAL, str.data(), str.size()); |
138 | 135 | } |
139 | | -#endif |
140 | 136 | }; |
141 | 137 |
|
142 | 138 | } // namespace ecsact |
0 commit comments