@@ -151,20 +151,6 @@ FMT_END_NAMESPACE
151
151
# endif // FMT_USE_EXCEPTIONS
152
152
#endif // FMT_THROW
153
153
154
- #ifdef FMT_NO_UNIQUE_ADDRESS
155
- // Use the provided definition.
156
- #elif FMT_CPLUSPLUS < 202002L
157
- // Not supported.
158
- #elif FMT_HAS_CPP_ATTRIBUTE(no_unique_address)
159
- # define FMT_NO_UNIQUE_ADDRESS [[no_unique_address]]
160
- // VS2019 v16.10 and later except clang-cl (https://reviews.llvm.org/D110485).
161
- #elif FMT_MSC_VERSION >= 1929 && !FMT_CLANG_VERSION
162
- # define FMT_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
163
- #endif
164
- #ifndef FMT_NO_UNIQUE_ADDRESS
165
- # define FMT_NO_UNIQUE_ADDRESS
166
- #endif
167
-
168
154
// Defining FMT_REDUCE_INT_INSTANTIATIONS to 1, will reduce the number of
169
155
// integer formatter template instantiations to just one by only using the
170
156
// largest integer type. This results in a reduction in binary size but will
@@ -241,7 +227,9 @@ FMT_CONSTEXPR inline void abort_fuzzing_if(bool condition) {
241
227
#if defined(FMT_USE_STRING_VIEW)
242
228
template <typename Char> using std_string_view = std::basic_string_view<Char>;
243
229
#else
244
- template <typename T> struct std_string_view {};
230
+ template <typename Char> struct std_string_view {
231
+ operator basic_string_view<Char>() const ;
232
+ };
245
233
#endif
246
234
247
235
template <typename Char, Char... C> struct string_literal {
@@ -1217,7 +1205,7 @@ FMT_CONSTEXPR FMT_INLINE auto format_decimal(Char* out, UInt value,
1217
1205
}
1218
1206
1219
1207
template <typename Char, typename UInt, typename OutputIt,
1220
- FMT_ENABLE_IF (is_back_insert_iterator< OutputIt>::value)>
1208
+ FMT_ENABLE_IF (!std::is_pointer< remove_cvref_t < OutputIt> >::value)>
1221
1209
FMT_CONSTEXPR auto format_decimal (OutputIt out, UInt value, int num_digits)
1222
1210
-> OutputIt {
1223
1211
if (auto ptr = to_pointer<Char>(out, to_unsigned (num_digits))) {
@@ -1853,7 +1841,9 @@ template <typename Char> class digit_grouping {
1853
1841
}
1854
1842
1855
1843
public:
1856
- explicit digit_grouping (locale_ref loc, bool localized = true ) {
1844
+ template <typename Locale,
1845
+ FMT_ENABLE_IF (std::is_same<Locale, locale_ref>::value)>
1846
+ explicit digit_grouping (Locale loc, bool localized = true ) {
1857
1847
if (!localized) return ;
1858
1848
auto sep = thousands_sep<Char>(loc);
1859
1849
grouping_ = sep.grouping ;
@@ -3653,6 +3643,12 @@ FMT_CONSTEXPR auto native_formatter<T, Char, TYPE>::format(
3653
3643
return write <Char>(ctx.out (), val, specs, ctx.locale ());
3654
3644
}
3655
3645
3646
+ // DEPRECATED! https://github.com/fmtlib/fmt/issues/4292.
3647
+ template <typename T, typename Enable = void >
3648
+ struct is_locale : std::false_type {};
3649
+ template <typename T>
3650
+ struct is_locale <T, void_t <decltype(T::classic())>> : std::true_type {};
3651
+
3656
3652
// DEPRECATED!
3657
3653
template <typename Char = char > struct vformat_args {
3658
3654
using type = basic_format_args<buffered_context<Char>>;
@@ -3974,8 +3970,7 @@ template <typename T, typename Char = char> struct nested_formatter {
3974
3970
write (basic_appender<Char>(buf));
3975
3971
auto specs = format_specs ();
3976
3972
specs.width = width_;
3977
- specs.set_fill (
3978
- basic_string_view<Char>(specs_.fill <Char>(), specs_.fill_size ()));
3973
+ specs.copy_fill_from (specs_);
3979
3974
specs.set_align (specs_.align ());
3980
3975
return detail::write <Char>(
3981
3976
ctx.out (), basic_string_view<Char>(buf.data (), buf.size ()), specs);
@@ -4135,41 +4130,46 @@ FMT_API void format_system_error(detail::buffer<char>& out, int error_code,
4135
4130
// Can be used to report errors from destructors.
4136
4131
FMT_API void report_system_error (int error_code, const char * message) noexcept ;
4137
4132
4138
- inline auto vformat (detail::locale_ref loc, string_view fmt, format_args args)
4133
+ template <typename Locale, FMT_ENABLE_IF(detail::is_locale<Locale>::value)>
4134
+ inline auto vformat (const Locale& loc, string_view fmt, format_args args)
4139
4135
-> std::string {
4140
4136
auto buf = memory_buffer ();
4141
- detail::vformat_to (buf, fmt, args, loc);
4137
+ detail::vformat_to (buf, fmt, args, detail::locale_ref ( loc) );
4142
4138
return {buf.data (), buf.size ()};
4143
4139
}
4144
4140
4145
- template <typename ... T>
4146
- FMT_INLINE auto format (detail::locale_ref loc, format_string<T...> fmt,
4147
- T&&... args) -> std::string {
4141
+ template <typename Locale, typename ... T,
4142
+ FMT_ENABLE_IF (detail::is_locale<Locale>::value)>
4143
+ FMT_INLINE auto format (const Locale& loc, format_string<T...> fmt, T&&... args)
4144
+ -> std::string {
4148
4145
return vformat (loc, fmt.str , vargs<T...>{{args...}});
4149
4146
}
4150
4147
4151
- template <typename OutputIt,
4148
+ template <typename OutputIt, typename Locale,
4152
4149
FMT_ENABLE_IF (detail::is_output_iterator<OutputIt, char >::value)>
4153
- auto vformat_to (OutputIt out, detail::locale_ref loc, string_view fmt,
4150
+ auto vformat_to (OutputIt out, const Locale& loc, string_view fmt,
4154
4151
format_args args) -> OutputIt {
4155
4152
auto && buf = detail::get_buffer<char >(out);
4156
- detail::vformat_to (buf, fmt, args, loc);
4153
+ detail::vformat_to (buf, fmt, args, detail::locale_ref ( loc) );
4157
4154
return detail::get_iterator (buf, out);
4158
4155
}
4159
4156
4160
- template <typename OutputIt, typename ... T,
4161
- FMT_ENABLE_IF (detail::is_output_iterator<OutputIt, char >::value)>
4162
- FMT_INLINE auto format_to (OutputIt out, detail::locale_ref loc,
4157
+ template <typename OutputIt, typename Locale, typename ... T,
4158
+ FMT_ENABLE_IF (detail::is_output_iterator<OutputIt, char >::value&&
4159
+ detail::is_locale<Locale>::value)>
4160
+ FMT_INLINE auto format_to (OutputIt out, const Locale& loc,
4163
4161
format_string<T...> fmt, T&&... args) -> OutputIt {
4164
4162
return fmt::vformat_to (out, loc, fmt.str , vargs<T...>{{args...}});
4165
4163
}
4166
4164
4167
- template <typename ... T>
4168
- FMT_NODISCARD FMT_INLINE auto formatted_size (detail::locale_ref loc,
4165
+ template <typename Locale, typename ... T,
4166
+ FMT_ENABLE_IF (detail::is_locale<Locale>::value)>
4167
+ FMT_NODISCARD FMT_INLINE auto formatted_size (const Locale& loc,
4169
4168
format_string<T...> fmt,
4170
4169
T&&... args) -> size_t {
4171
4170
auto buf = detail::counting_buffer<>();
4172
- detail::vformat_to (buf, fmt.str , vargs<T...>{{args...}}, loc);
4171
+ detail::vformat_to (buf, fmt.str , vargs<T...>{{args...}},
4172
+ detail::locale_ref (loc));
4173
4173
return buf.count ();
4174
4174
}
4175
4175
0 commit comments