Workaround bug for old msvc

This commit is contained in:
Jeremy 2024-03-31 23:47:28 -05:00
parent 0dd71cebb7
commit 599d6abd6c
No known key found for this signature in database
GPG Key ID: BE03111EB7ED6E2E

View File

@ -302,20 +302,27 @@ namespace microfmt {
}
}
template<typename... Args>
#if defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L
template<typename... Args>
std::string format(std::string_view fmt, Args&&... args) {
#else
std::string format(const std::string& fmt, Args&&... args) {
#endif
return detail::format<sizeof...(args)>(fmt.begin(), fmt.end(), {detail::format_value(args)...});
}
inline std::string format(std::string_view fmt) {
return std::string(fmt);
}
#endif
template<typename... Args>
std::string format(const char* fmt, Args&&... args) {
return detail::format<sizeof...(args)>(fmt, fmt + std::strlen(fmt), {detail::format_value(args)...});
}
// working around an old msvc bug https://godbolt.org/z/88T8hrzzq mre: https://godbolt.org/z/drd8echbP
inline std::string format(const char* fmt) {
return std::string(fmt);
}
template<typename S, typename... Args>
void print(const S& fmt, Args&&... args) {
std::cout<<format(fmt, args...);