mirror of
https://github.com/fmtlib/fmt.git
synced 2025-08-03 12:44:49 +02:00
Use static_assert instead of SFINAE in arg(...)
This commit is contained in:
@@ -1416,8 +1416,9 @@ typename buffer_context<Char>::type::iterator vformat_to(
|
|||||||
fmt::print("Elapsed time: {s:.2f} seconds", fmt::arg("s", 1.23));
|
fmt::print("Elapsed time: {s:.2f} seconds", fmt::arg("s", 1.23));
|
||||||
\endrst
|
\endrst
|
||||||
*/
|
*/
|
||||||
template <typename S, typename T, FMT_ENABLE_IF(internal::is_string<S>::value)>
|
template <typename S, typename T>
|
||||||
inline internal::named_arg<T, FMT_CHAR(S)> arg(const S& name, const T& arg) {
|
inline internal::named_arg<T, FMT_CHAR(S)> arg(const S& name, const T& arg) {
|
||||||
|
static_assert(internal::is_string<S>::value, "");
|
||||||
return {name, arg};
|
return {name, arg};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1472,6 +1473,7 @@ inline std::basic_string<Char> vformat(
|
|||||||
std::string message = fmt::format("The answer is {}", 42);
|
std::string message = fmt::format("The answer is {}", 42);
|
||||||
\endrst
|
\endrst
|
||||||
*/
|
*/
|
||||||
|
// Use SFINAE instead of static_assert because of color overload of fmt::format.
|
||||||
template <typename S, typename... Args,
|
template <typename S, typename... Args,
|
||||||
FMT_ENABLE_IF(internal::is_string<S>::value)>
|
FMT_ENABLE_IF(internal::is_string<S>::value)>
|
||||||
inline std::basic_string<FMT_CHAR(S)> format(const S& format_str,
|
inline std::basic_string<FMT_CHAR(S)> format(const S& format_str,
|
||||||
|
Reference in New Issue
Block a user