mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-08 12:20:06 +00:00
Remove FMT_USE_USER_LITERALS
This commit is contained in:
parent
f924d16e47
commit
1bde49e545
@ -2671,8 +2671,9 @@ class context : private detail::locale_ref {
|
|||||||
|
|
||||||
/// Constructs a `context` object. References to the arguments are stored
|
/// Constructs a `context` object. References to the arguments are stored
|
||||||
/// in the object so make sure they have appropriate lifetimes.
|
/// in the object so make sure they have appropriate lifetimes.
|
||||||
FMT_CONSTEXPR context(iterator out, format_args a, detail::locale_ref l = {})
|
FMT_CONSTEXPR context(iterator out, format_args args,
|
||||||
: locale_ref(l), out_(out), args_(a) {}
|
detail::locale_ref loc = {})
|
||||||
|
: locale_ref(loc), out_(out), args_(args) {}
|
||||||
context(context&&) = default;
|
context(context&&) = default;
|
||||||
context(const context&) = delete;
|
context(const context&) = delete;
|
||||||
void operator=(const context&) = delete;
|
void operator=(const context&) = delete;
|
||||||
|
@ -166,17 +166,6 @@ FMT_END_NAMESPACE
|
|||||||
# endif
|
# endif
|
||||||
#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
|
// Defining FMT_REDUCE_INT_INSTANTIATIONS to 1, will reduce the number of
|
||||||
// integer formatter template instantiations to just one by only using the
|
// integer formatter template instantiations to just one by only using the
|
||||||
// largest integer type. This results in a reduction in binary size but will
|
// 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 };
|
enum { builtin_types = FMT_BUILTIN_TYPES };
|
||||||
|
|
||||||
constexpr generic_context(OutputIt out,
|
constexpr generic_context(OutputIt out,
|
||||||
basic_format_args<generic_context> ctx_args,
|
basic_format_args<generic_context> args,
|
||||||
detail::locale_ref loc = {})
|
detail::locale_ref loc = {})
|
||||||
: out_(out), args_(ctx_args), loc_(loc) {}
|
: out_(out), args_(args), loc_(loc) {}
|
||||||
generic_context(generic_context&&) = default;
|
generic_context(generic_context&&) = default;
|
||||||
generic_context(const generic_context&) = delete;
|
generic_context(const generic_context&) = delete;
|
||||||
void operator=(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 (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 <typename T, typename Char, size_t N,
|
template <typename T, typename Char, size_t N,
|
||||||
fmt::detail_exported::fixed_string<Char, N> Str>
|
fmt::detail_exported::fixed_string<Char, N> Str>
|
||||||
struct static_named_arg : view {
|
struct static_named_arg : view {
|
||||||
@ -3795,7 +3783,7 @@ struct udl_arg {
|
|||||||
return static_named_arg<T, Char, N, Str>(std::forward<T>(value));
|
return static_named_arg<T, Char, N, Str>(std::forward<T>(value));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
# else
|
#else
|
||||||
template <typename Char> struct udl_arg {
|
template <typename Char> struct udl_arg {
|
||||||
const Char* str;
|
const Char* str;
|
||||||
|
|
||||||
@ -3803,8 +3791,7 @@ template <typename Char> struct udl_arg {
|
|||||||
return {str, std::forward<T>(value)};
|
return {str, std::forward<T>(value)};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
# endif // FMT_USE_NONTYPE_TEMPLATE_ARGS
|
#endif // FMT_USE_NONTYPE_TEMPLATE_ARGS
|
||||||
#endif // FMT_USE_USER_LITERALS
|
|
||||||
|
|
||||||
template <typename Char> struct format_handler {
|
template <typename Char> struct format_handler {
|
||||||
parse_context<Char> parse_ctx;
|
parse_context<Char> parse_ctx;
|
||||||
@ -4125,7 +4112,6 @@ struct formatter<detail::float128, Char>
|
|||||||
: detail::native_formatter<detail::float128, Char,
|
: detail::native_formatter<detail::float128, Char,
|
||||||
detail::type::float_type> {};
|
detail::type::float_type> {};
|
||||||
|
|
||||||
#if FMT_USE_USER_LITERALS
|
|
||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
/**
|
/**
|
||||||
* User-defined literal equivalent of `fmt::arg`.
|
* User-defined literal equivalent of `fmt::arg`.
|
||||||
@ -4135,18 +4121,17 @@ inline namespace literals {
|
|||||||
* using namespace fmt::literals;
|
* using namespace fmt::literals;
|
||||||
* fmt::print("The answer is {answer}.", "answer"_a=42);
|
* fmt::print("The answer is {answer}.", "answer"_a=42);
|
||||||
*/
|
*/
|
||||||
# if FMT_USE_NONTYPE_TEMPLATE_ARGS
|
#if FMT_USE_NONTYPE_TEMPLATE_ARGS
|
||||||
template <detail_exported::fixed_string Str> constexpr auto operator""_a() {
|
template <detail_exported::fixed_string Str> constexpr auto operator""_a() {
|
||||||
using char_t = remove_cvref_t<decltype(Str.data[0])>;
|
using char_t = remove_cvref_t<decltype(Str.data[0])>;
|
||||||
return detail::udl_arg<char_t, sizeof(Str.data) / sizeof(char_t), Str>();
|
return detail::udl_arg<char_t, sizeof(Str.data) / sizeof(char_t), Str>();
|
||||||
}
|
}
|
||||||
# else
|
#else
|
||||||
constexpr auto operator""_a(const char* s, size_t) -> detail::udl_arg<char> {
|
constexpr auto operator""_a(const char* s, size_t) -> detail::udl_arg<char> {
|
||||||
return {s};
|
return {s};
|
||||||
}
|
}
|
||||||
# endif
|
#endif
|
||||||
} // namespace literals
|
} // namespace literals
|
||||||
#endif // FMT_USE_USER_LITERALS
|
|
||||||
|
|
||||||
/// A fast integer formatter.
|
/// A fast integer formatter.
|
||||||
class format_int {
|
class format_int {
|
||||||
|
@ -127,14 +127,13 @@ constexpr auto make_wformat_args(T&... args)
|
|||||||
return fmt::make_format_args<wformat_context>(args...);
|
return fmt::make_format_args<wformat_context>(args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !FMT_USE_NONTYPE_TEMPLATE_ARGS
|
||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
#if FMT_USE_USER_LITERALS && !FMT_USE_NONTYPE_TEMPLATE_ARGS
|
inline auto operator""_a(const wchar_t* s, size_t) -> detail::udl_arg<wchar_t> {
|
||||||
constexpr auto operator""_a(const wchar_t* s, size_t)
|
|
||||||
-> detail::udl_arg<wchar_t> {
|
|
||||||
return {s};
|
return {s};
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
} // namespace literals
|
} // namespace literals
|
||||||
|
#endif
|
||||||
|
|
||||||
template <typename It, typename Sentinel>
|
template <typename It, typename Sentinel>
|
||||||
auto join(It begin, Sentinel end, wstring_view sep)
|
auto join(It begin, Sentinel end, wstring_view sep)
|
||||||
|
@ -2005,7 +2005,6 @@ TEST(format_test, custom_format_compile_time_string) {
|
|||||||
EXPECT_EQ(fmt::format(FMT_STRING("{}"), const_answer), "42");
|
EXPECT_EQ(fmt::format(FMT_STRING("{}"), const_answer), "42");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FMT_USE_USER_LITERALS
|
|
||||||
TEST(format_test, named_arg_udl) {
|
TEST(format_test, named_arg_udl) {
|
||||||
using namespace fmt::literals;
|
using namespace fmt::literals;
|
||||||
auto udl_a = fmt::format("{first}{second}{first}{third}", "first"_a = "abra",
|
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");
|
EXPECT_EQ(fmt::format("{answer}", "answer"_a = Answer()), "42");
|
||||||
}
|
}
|
||||||
#endif // FMT_USE_USER_LITERALS
|
|
||||||
|
|
||||||
TEST(format_test, enum) { EXPECT_EQ(fmt::format("{}", foo), "0"); }
|
TEST(format_test, enum) { EXPECT_EQ(fmt::format("{}", foo), "0"); }
|
||||||
|
|
||||||
@ -2521,7 +2519,7 @@ TEST(format_test, writer) {
|
|||||||
TEST(format_test, bitint) {
|
TEST(format_test, bitint) {
|
||||||
using fmt::detail::bitint;
|
using fmt::detail::bitint;
|
||||||
using fmt::detail::ubitint;
|
using fmt::detail::ubitint;
|
||||||
|
|
||||||
EXPECT_EQ(fmt::format("{}", ubitint<3>(7)), "7");
|
EXPECT_EQ(fmt::format("{}", ubitint<3>(7)), "7");
|
||||||
EXPECT_EQ(fmt::format("{}", bitint<7>()), "0");
|
EXPECT_EQ(fmt::format("{}", bitint<7>()), "0");
|
||||||
|
|
||||||
|
@ -144,7 +144,6 @@ TEST(format_test, wide_format_to_n) {
|
|||||||
EXPECT_EQ(L"BC x", fmt::wstring_view(buffer, 4));
|
EXPECT_EQ(L"BC x", fmt::wstring_view(buffer, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FMT_USE_USER_LITERALS
|
|
||||||
TEST(xchar_test, named_arg_udl) {
|
TEST(xchar_test, named_arg_udl) {
|
||||||
using namespace fmt::literals;
|
using namespace fmt::literals;
|
||||||
auto udl_a =
|
auto udl_a =
|
||||||
@ -155,7 +154,6 @@ TEST(xchar_test, named_arg_udl) {
|
|||||||
fmt::arg(L"second", L"cad"), fmt::arg(L"third", 99)),
|
fmt::arg(L"second", L"cad"), fmt::arg(L"third", 99)),
|
||||||
udl_a);
|
udl_a);
|
||||||
}
|
}
|
||||||
#endif // FMT_USE_USER_LITERALS
|
|
||||||
|
|
||||||
TEST(xchar_test, print) {
|
TEST(xchar_test, print) {
|
||||||
// Check that the wide print overload compiles.
|
// Check that the wide print overload compiles.
|
||||||
|
Loading…
Reference in New Issue
Block a user