diff --git a/include/fmt/base.h b/include/fmt/base.h index d1cb5ef6..5868f332 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -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; diff --git a/include/fmt/format.h b/include/fmt/format.h index 5412b3d8..b84004ef 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -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 class generic_context { enum { builtin_types = FMT_BUILTIN_TYPES }; constexpr generic_context(OutputIt out, - basic_format_args ctx_args, + basic_format_args 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,8 +3757,7 @@ 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 +#if FMT_USE_NONTYPE_TEMPLATE_ARGS template Str> struct static_named_arg : view { @@ -3795,7 +3783,7 @@ struct udl_arg { return static_named_arg(std::forward(value)); } }; -# else +#else template struct udl_arg { const Char* str; @@ -3803,8 +3791,7 @@ template struct udl_arg { return {str, std::forward(value)}; } }; -# endif // FMT_USE_NONTYPE_TEMPLATE_ARGS -#endif // FMT_USE_USER_LITERALS +#endif // FMT_USE_NONTYPE_TEMPLATE_ARGS template struct format_handler { parse_context parse_ctx; @@ -4125,7 +4112,6 @@ struct formatter : detail::native_formatter {}; -#if FMT_USE_USER_LITERALS inline namespace literals { /** * User-defined literal equivalent of `fmt::arg`. @@ -4135,18 +4121,17 @@ inline namespace literals { * using namespace fmt::literals; * fmt::print("The answer is {answer}.", "answer"_a=42); */ -# if FMT_USE_NONTYPE_TEMPLATE_ARGS +#if FMT_USE_NONTYPE_TEMPLATE_ARGS template constexpr auto operator""_a() { using char_t = remove_cvref_t; return detail::udl_arg(); } -# else +#else constexpr auto operator""_a(const char* s, size_t) -> detail::udl_arg { return {s}; } -# endif +#endif } // namespace literals -#endif // FMT_USE_USER_LITERALS /// A fast integer formatter. class format_int { diff --git a/include/fmt/xchar.h b/include/fmt/xchar.h index fcbf1457..30334a34 100644 --- a/include/fmt/xchar.h +++ b/include/fmt/xchar.h @@ -127,14 +127,13 @@ constexpr auto make_wformat_args(T&... args) return fmt::make_format_args(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 { +inline auto operator""_a(const wchar_t* s, size_t) -> detail::udl_arg { return {s}; } -#endif } // namespace literals +#endif template auto join(It begin, Sentinel end, wstring_view sep) diff --git a/test/format-test.cc b/test/format-test.cc index a5f91b8c..bac32a07 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -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"); } @@ -2521,7 +2519,7 @@ TEST(format_test, writer) { TEST(format_test, bitint) { using fmt::detail::bitint; using fmt::detail::ubitint; - + EXPECT_EQ(fmt::format("{}", ubitint<3>(7)), "7"); EXPECT_EQ(fmt::format("{}", bitint<7>()), "0"); diff --git a/test/xchar-test.cc b/test/xchar-test.cc index 52946cae..215b659f 100644 --- a/test/xchar-test.cc +++ b/test/xchar-test.cc @@ -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.