Remove FMT_USE_USER_LITERALS

This commit is contained in:
Victor Zverovich 2024-09-11 08:54:54 -07:00
parent f924d16e47
commit 1bde49e545
5 changed files with 15 additions and 34 deletions

View File

@ -2671,8 +2671,9 @@ class context : private detail::locale_ref {
/// Constructs a `context` object. References to the arguments are stored
/// in the object so make sure they have appropriate lifetimes.
FMT_CONSTEXPR context(iterator out, format_args a, detail::locale_ref l = {})
: locale_ref(l), out_(out), args_(a) {}
FMT_CONSTEXPR context(iterator out, format_args args,
detail::locale_ref loc = {})
: locale_ref(loc), out_(out), args_(args) {}
context(context&&) = default;
context(const context&) = delete;
void operator=(const context&) = delete;

View File

@ -166,17 +166,6 @@ FMT_END_NAMESPACE
# endif
#endif
#ifndef FMT_USE_USER_LITERALS
// EDG based compilers (Intel, NVIDIA, Elbrus, etc), GCC and MSVC support UDLs.
# if (FMT_HAS_FEATURE(cxx_user_literals) || FMT_GCC_VERSION || \
FMT_MSC_VERSION >= 1900) && \
(!defined(__EDG_VERSION__) || __EDG_VERSION__ >= /* UDL feature */ 480)
# define FMT_USE_USER_LITERALS 1
# else
# define FMT_USE_USER_LITERALS 0
# endif
#endif
// Defining FMT_REDUCE_INT_INSTANTIATIONS to 1, will reduce the number of
// integer formatter template instantiations to just one by only using the
// largest integer type. This results in a reduction in binary size but will
@ -1078,9 +1067,9 @@ template <typename OutputIt, typename Char> class generic_context {
enum { builtin_types = FMT_BUILTIN_TYPES };
constexpr generic_context(OutputIt out,
basic_format_args<generic_context> ctx_args,
basic_format_args<generic_context> args,
detail::locale_ref loc = {})
: out_(out), args_(ctx_args), loc_(loc) {}
: out_(out), args_(args), loc_(loc) {}
generic_context(generic_context&&) = default;
generic_context(const generic_context&) = delete;
void operator=(const generic_context&) = delete;
@ -3768,7 +3757,6 @@ FMT_CONSTEXPR void handle_dynamic_spec(
if (kind != arg_id_kind::none) value = get_dynamic_spec(kind, ref, ctx);
}
#if FMT_USE_USER_LITERALS
#if FMT_USE_NONTYPE_TEMPLATE_ARGS
template <typename T, typename Char, size_t N,
fmt::detail_exported::fixed_string<Char, N> Str>
@ -3804,7 +3792,6 @@ template <typename Char> struct udl_arg {
}
};
#endif // FMT_USE_NONTYPE_TEMPLATE_ARGS
#endif // FMT_USE_USER_LITERALS
template <typename Char> struct format_handler {
parse_context<Char> parse_ctx;
@ -4125,7 +4112,6 @@ struct formatter<detail::float128, Char>
: detail::native_formatter<detail::float128, Char,
detail::type::float_type> {};
#if FMT_USE_USER_LITERALS
inline namespace literals {
/**
* User-defined literal equivalent of `fmt::arg`.
@ -4146,7 +4132,6 @@ constexpr auto operator""_a(const char* s, size_t) -> detail::udl_arg<char> {
}
#endif
} // namespace literals
#endif // FMT_USE_USER_LITERALS
/// A fast integer formatter.
class format_int {

View File

@ -127,14 +127,13 @@ constexpr auto make_wformat_args(T&... args)
return fmt::make_format_args<wformat_context>(args...);
}
#if !FMT_USE_NONTYPE_TEMPLATE_ARGS
inline namespace literals {
#if FMT_USE_USER_LITERALS && !FMT_USE_NONTYPE_TEMPLATE_ARGS
constexpr auto operator""_a(const wchar_t* s, size_t)
-> detail::udl_arg<wchar_t> {
inline auto operator""_a(const wchar_t* s, size_t) -> detail::udl_arg<wchar_t> {
return {s};
}
#endif
} // namespace literals
#endif
template <typename It, typename Sentinel>
auto join(It begin, Sentinel end, wstring_view sep)

View File

@ -2005,7 +2005,6 @@ TEST(format_test, custom_format_compile_time_string) {
EXPECT_EQ(fmt::format(FMT_STRING("{}"), const_answer), "42");
}
#if FMT_USE_USER_LITERALS
TEST(format_test, named_arg_udl) {
using namespace fmt::literals;
auto udl_a = fmt::format("{first}{second}{first}{third}", "first"_a = "abra",
@ -2017,7 +2016,6 @@ TEST(format_test, named_arg_udl) {
EXPECT_EQ(fmt::format("{answer}", "answer"_a = Answer()), "42");
}
#endif // FMT_USE_USER_LITERALS
TEST(format_test, enum) { EXPECT_EQ(fmt::format("{}", foo), "0"); }

View File

@ -144,7 +144,6 @@ TEST(format_test, wide_format_to_n) {
EXPECT_EQ(L"BC x", fmt::wstring_view(buffer, 4));
}
#if FMT_USE_USER_LITERALS
TEST(xchar_test, named_arg_udl) {
using namespace fmt::literals;
auto udl_a =
@ -155,7 +154,6 @@ TEST(xchar_test, named_arg_udl) {
fmt::arg(L"second", L"cad"), fmt::arg(L"third", 99)),
udl_a);
}
#endif // FMT_USE_USER_LITERALS
TEST(xchar_test, print) {
// Check that the wide print overload compiles.