Skip to content

Commit cbaa826

Browse files
authored
fix: correctly wrap std::format (#49)
1 parent 62634fb commit cbaa826

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

ecsact/codegen/plugin.hh

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
#include <string_view>
77
#include <cstring>
88
#include <iterator>
9-
#ifdef __cpp_lib_format
10-
# include <format>
11-
#endif
9+
#include <format>
1210
#include "ecsact/runtime/common.h"
1311
#include "ecsact/codegen/plugin.h"
1412

@@ -106,37 +104,35 @@ struct codegen_plugin_context {
106104
}
107105
}
108106

109-
#ifdef __cpp_lib_format
110107
template<typename... Args>
111108
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)...);
113110
write_(str.data(), static_cast<int32_t>(str.size()));
114111
}
115112

116113
template<typename... Args>
117114
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)...);
119116
report_(ECSACT_CODEGEN_REPORT_INFO, str.data(), str.size());
120117
}
121118

122119
template<typename... Args>
123120
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)...);
125122
report_(ECSACT_CODEGEN_REPORT_WARNING, str.data(), str.size());
126123
}
127124

128125
template<typename... Args>
129126
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)...);
131128
report_(ECSACT_CODEGEN_REPORT_ERROR, str.data(), str.size());
132129
}
133130

134131
template<typename... Args>
135132
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)...);
137134
report_(ECSACT_CODEGEN_REPORT_FATAL, str.data(), str.size());
138135
}
139-
#endif
140136
};
141137

142138
} // namespace ecsact

0 commit comments

Comments
 (0)