mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
Stop using deprecated UDL templates
This commit is contained in:
@ -147,20 +147,6 @@ FMT_END_NAMESPACE
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FMT_USE_UDL_TEMPLATE
|
|
||||||
// EDG frontend based compilers (icc, nvcc, PGI, etc) and GCC < 6.4 do not
|
|
||||||
// properly support UDL templates and GCC >= 9 warns about them.
|
|
||||||
# if FMT_USE_USER_DEFINED_LITERALS && \
|
|
||||||
(!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 501) && \
|
|
||||||
((FMT_GCC_VERSION >= 604 && __cplusplus >= 201402L) || \
|
|
||||||
FMT_CLANG_VERSION >= 304) && \
|
|
||||||
!defined(__PGI) && !defined(__NVCC__)
|
|
||||||
# define FMT_USE_UDL_TEMPLATE 1
|
|
||||||
# else
|
|
||||||
# define FMT_USE_UDL_TEMPLATE 0
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FMT_USE_FLOAT
|
#ifndef FMT_USE_FLOAT
|
||||||
# define FMT_USE_FLOAT 1
|
# define FMT_USE_FLOAT 1
|
||||||
#endif
|
#endif
|
||||||
@ -3995,17 +3981,6 @@ void vprint(basic_string_view<Char> format_str, wformat_args args) {
|
|||||||
|
|
||||||
#if FMT_USE_USER_DEFINED_LITERALS
|
#if FMT_USE_USER_DEFINED_LITERALS
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
# if FMT_USE_UDL_TEMPLATE
|
|
||||||
template <typename Char, Char... CHARS> class udl_formatter {
|
|
||||||
public:
|
|
||||||
template <typename... Args>
|
|
||||||
std::basic_string<Char> operator()(Args&&... args) const {
|
|
||||||
static FMT_CONSTEXPR_DECL Char s[] = {CHARS..., '\0'};
|
|
||||||
return format(FMT_STRING(s), std::forward<Args>(args)...);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
# else
|
|
||||||
template <typename Char> struct udl_formatter {
|
template <typename Char> struct udl_formatter {
|
||||||
basic_string_view<Char> str;
|
basic_string_view<Char> str;
|
||||||
|
|
||||||
@ -4014,7 +3989,6 @@ template <typename Char> struct udl_formatter {
|
|||||||
return format(str, std::forward<Args>(args)...);
|
return format(str, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
# endif // FMT_USE_UDL_TEMPLATE
|
|
||||||
|
|
||||||
template <typename Char> struct udl_arg {
|
template <typename Char> struct udl_arg {
|
||||||
const Char* str;
|
const Char* str;
|
||||||
@ -4026,18 +4000,6 @@ template <typename Char> struct udl_arg {
|
|||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
# if FMT_USE_UDL_TEMPLATE
|
|
||||||
# pragma GCC diagnostic push
|
|
||||||
# pragma GCC diagnostic ignored "-Wpedantic"
|
|
||||||
# if FMT_CLANG_VERSION
|
|
||||||
# pragma GCC diagnostic ignored "-Wgnu-string-literal-operator-template"
|
|
||||||
# endif
|
|
||||||
template <typename Char, Char... CHARS>
|
|
||||||
constexpr detail::udl_formatter<Char, CHARS...> operator""_format() {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
# pragma GCC diagnostic pop
|
|
||||||
# else
|
|
||||||
/**
|
/**
|
||||||
\rst
|
\rst
|
||||||
User-defined literal equivalent of :func:`fmt::format`.
|
User-defined literal equivalent of :func:`fmt::format`.
|
||||||
@ -4056,7 +4018,6 @@ constexpr detail::udl_formatter<wchar_t> operator"" _format(const wchar_t* s,
|
|||||||
size_t n) {
|
size_t n) {
|
||||||
return {{s, n}};
|
return {{s, n}};
|
||||||
}
|
}
|
||||||
# endif // FMT_USE_UDL_TEMPLATE
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\rst
|
\rst
|
||||||
|
@ -37,14 +37,6 @@ void test_format_api() {
|
|||||||
fmt::format_to_n(wbuffer, 3, FMT_STRING(L"{}"), 12345);
|
fmt::format_to_n(wbuffer, 3, FMT_STRING(L"{}"), 12345);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_literals_api() {
|
|
||||||
#if FMT_USE_UDL_TEMPLATE
|
|
||||||
using namespace fmt::literals;
|
|
||||||
"{}c{}"_format("ab", 1);
|
|
||||||
L"{}c{}"_format(L"ab", 1);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_chrono() {
|
void test_chrono() {
|
||||||
fmt::format(FMT_STRING("{}"), std::chrono::seconds(42));
|
fmt::format(FMT_STRING("{}"), std::chrono::seconds(42));
|
||||||
fmt::format(FMT_STRING(L"{}"), std::chrono::seconds(42));
|
fmt::format(FMT_STRING(L"{}"), std::chrono::seconds(42));
|
||||||
@ -67,7 +59,6 @@ void test_range() {
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
test_format_api();
|
test_format_api();
|
||||||
test_literals_api();
|
|
||||||
test_chrono();
|
test_chrono();
|
||||||
test_text_style();
|
test_text_style();
|
||||||
test_range();
|
test_range();
|
||||||
|
Reference in New Issue
Block a user