From 4533970bfe2a32827b90f59a418d1cf2a9398550 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Fri, 15 Dec 2023 14:22:34 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20clang-format=20affected=20files!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/fmt/color.h | 51 ++++++----- include/fmt/compile.h | 26 +++--- include/fmt/core.h | 187 +++++++++++++++++++++----------------- include/fmt/format.h | 48 +++++----- include/fmt/xchar.h | 97 ++++++++++---------- test/output-range-test.cc | 28 +++--- 6 files changed, 234 insertions(+), 203 deletions(-) diff --git a/include/fmt/color.h b/include/fmt/color.h index d21d9898..99a8e1ee 100644 --- a/include/fmt/color.h +++ b/include/fmt/color.h @@ -543,10 +543,11 @@ inline std::basic_string format(const text_style& ts, const S& format_str, Formats a string with the given text_style and writes the output to ``out``. */ template || std::output_iterator, Char>)> -auto vformat_to( - Output&& out, const text_style& ts, basic_string_view format_str, - basic_format_args>> args) { + FMT_ENABLE_IF(std::ranges::output_range || + std::output_iterator, Char>)> +auto vformat_to(Output&& out, const text_style& ts, + basic_string_view format_str, + basic_format_args>> args) { auto&& buf = detail::get_appendable_buffer(std::forward(out)); detail::vformat_to(buf, ts, format_str, args); return detail::get_iterator(buf, out); @@ -555,7 +556,8 @@ auto vformat_to( /** \rst Formats arguments with the given text_style, writes the result to the output - iterator or range ``out`` and returns the iterator past the end of the output range. + iterator or range ``out`` and returns the iterator past the end of the output + range. **Example**:: @@ -565,13 +567,15 @@ auto vformat_to( \endrst */ template > - || std::output_iterator, char_t>) - && detail::is_string::value, - FMT_ENABLE_IF(enable)> + bool enable = + (std::ranges::output_range> || + std::output_iterator, + char_t>)&&detail::is_string::value, + FMT_ENABLE_IF(enable)> inline auto format_to(Output&& out, const text_style& ts, const S& format_str, Args&&... args) { - return vformat_to(std::forward(out), ts, detail::to_string_view(format_str), + return vformat_to(std::forward(out), ts, + detail::to_string_view(format_str), fmt::make_format_args>>(args...)); } @@ -579,8 +583,8 @@ inline auto format_to(Output&& out, const text_style& ts, const S& format_str, Formats a string with the given text_style and writes the output to ``out``. */ template - || std::output_iterator, Char>)> + FMT_ENABLE_IF(std::ranges::output_range || + std::output_iterator, Char>)> auto vformat_into( Output&& out, const text_style& ts, basic_string_view format_str, basic_format_args>> args) { @@ -602,14 +606,16 @@ auto vformat_into( \endrst */ template > - || std::output_iterator, char_t>) - && detail::is_string::value, - FMT_ENABLE_IF(enable)> + bool enable = + (std::ranges::output_range> || + std::output_iterator, + char_t>)&&detail::is_string::value, + FMT_ENABLE_IF(enable)> inline auto format_into(Output&& out, const text_style& ts, const S& format_str, - Args&&... args) { - return vformat_into(std::forward(out), ts, detail::to_string_view(format_str), - fmt::make_format_args>>(args...)); + Args&&... args) { + return vformat_into( + std::forward(out), ts, detail::to_string_view(format_str), + fmt::make_format_args>>(args...)); } #else /** @@ -637,10 +643,9 @@ OutputIt vformat_to( fmt::emphasis::bold | fg(fmt::color::red), "{}", 42); \endrst */ -template < - typename OutputIt, typename S, typename... Args, - bool enable = detail::is_output_iterator>::value && - detail::is_string::value> +template >::value&& + detail::is_string::value> inline auto format_to(OutputIt out, const text_style& ts, const S& format_str, Args&&... args) -> typename std::enable_if::type { diff --git a/include/fmt/compile.h b/include/fmt/compile.h index 10a309ed..44b8fe43 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -471,7 +471,7 @@ FMT_INLINE std::basic_string format(const S&, } } -#if FMT_OUTPUT_RANGES +# if FMT_OUTPUT_RANGES template ::value)> FMT_CONSTEXPR auto format_to(Output&& out, const S&, Args&&... args) { @@ -479,12 +479,12 @@ FMT_CONSTEXPR auto format_to(Output&& out, const S&, Args&&... args) { if constexpr (std::is_same, detail::unknown_format>()) { return fmt::format_to( - std::forward(out), - static_cast>(S()), - std::forward(args)...); + std::forward(out), + static_cast>(S()), + std::forward(args)...); } else { - return fmt::format_to(std::forward(out), - compiled, std::forward(args)...); + return fmt::format_to(std::forward(out), compiled, + std::forward(args)...); } } @@ -495,15 +495,15 @@ FMT_CONSTEXPR auto format_into(Output&& out, const S&, Args&&... args) { if constexpr (std::is_same, detail::unknown_format>()) { return fmt::format_into( - std::forward(out), - static_cast>(S()), - std::forward(args)...); + std::forward(out), + static_cast>(S()), + std::forward(args)...); } else { - return fmt::format_into(std::forward(out), - compiled, std::forward(args)...); + return fmt::format_into(std::forward(out), compiled, + std::forward(args)...); } } -#else +# else template ::value)> FMT_CONSTEXPR OutputIt format_to(OutputIt out, const S&, Args&&... args) { @@ -517,7 +517,7 @@ FMT_CONSTEXPR OutputIt format_to(OutputIt out, const S&, Args&&... args) { return fmt::format_to(out, compiled, std::forward(args)...); } } -#endif +# endif #endif template = 201606L)\ - && defined(__cpp_lib_ranges) && (__cpp_lib_ranges >= 201911L )\ - && defined(__cpp_concepts) && (__cpp_concepts >= 202002L) \ - && defined(__cpp_lib_concepts) && (__cpp_lib_concepts >= 201907L) +# if FMT_RANGE_CHECKS && defined(__cpp_if_constexpr) && \ + (__cpp_if_constexpr >= 201606L) && defined(__cpp_lib_ranges) && \ + (__cpp_lib_ranges >= 201911L) && defined(__cpp_concepts) && \ + (__cpp_concepts >= 202002L) && defined(__cpp_lib_concepts) && \ + (__cpp_lib_concepts >= 201907L) # define FMT_OUTPUT_RANGES 1 # else # define FMT_OUTPUT_RANGES 0 @@ -243,7 +243,8 @@ #ifndef FMT_UNICODE # if FMT_CLANG_VERSION # define FMT_UNICODE 1 -# elif defined(_MSVC_EXECUTION_CHARACTER_SET) && (_MSVC_EXECUTION_CHARACTER_SET == 65001) +# elif defined(_MSVC_EXECUTION_CHARACTER_SET) && \ + (_MSVC_EXECUTION_CHARACTER_SET == 65001) # define FMT_UNICODE 1 # else # define FMT_UNICODE !FMT_MSC_VERSION @@ -826,9 +827,10 @@ FMT_CONSTEXPR auto copy_str(InputIt begin, InputSen end, OutputIt out) template , U>::value && is_char::value)> + std::is_same, U>::value&& is_char::value)> FMT_CONSTEXPR auto copy_str(T* begin, T* end, U* out) -> U* { - if (is_constant_evaluated()) return copy_str(begin, end, out); + if (is_constant_evaluated()) + return copy_str(begin, end, out); auto size = to_unsigned(end - begin); if (size > 0) memcpy(out, begin, size * sizeof(U)); return out + size; @@ -836,30 +838,34 @@ FMT_CONSTEXPR auto copy_str(T* begin, T* end, U* out) -> U* { #if FMT_OUTPUT_RANGES -template -FMT_CONSTEXPR auto copy_str(InputIt begin, InputSen end, OutputIt out, OutputSen out_end) +template +FMT_CONSTEXPR auto copy_str(InputIt begin, InputSen end, OutputIt out, + OutputSen out_end) -> std::ranges::subrange { if constexpr (std::is_same::value) { // minor speed optimization - auto out_current = copy_str(std::move(begin), std::move(end), std::move(out)); - return { std::move(out_current), std::move(out_end) }; - } - else { + auto out_current = + copy_str(std::move(begin), std::move(end), std::move(out)); + return {std::move(out_current), std::move(out_end)}; + } else { while (begin != end && out != out_end) *out++ = static_cast(*begin++); - return { std::move(out), std::move(out_end) }; + return {std::move(out), std::move(out_end)}; } } template , U>::value && is_char::value)> -FMT_CONSTEXPR auto copy_str(T* begin, T* end, U* out, U* out_end) -> std::ranges::subrange { - if (is_constant_evaluated()) return copy_str(begin, end, out, out_end); + std::is_same, U>::value&& is_char::value)> +FMT_CONSTEXPR auto copy_str(T* begin, T* end, U* out, U* out_end) + -> std::ranges::subrange { + if (is_constant_evaluated()) + return copy_str(begin, end, out, out_end); auto size = to_unsigned(end - begin); auto out_size = to_unsigned(out_end - out); if (size > out_size) size = out_size; if (size > 0) memcpy(out, begin, size * sizeof(U)); - return { out + size, out_end }; + return {out + size, out_end}; } #endif @@ -1013,7 +1019,8 @@ class iterator_buffer final : public Traits, public buffer { template class range_buffer final : public Traits, public buffer { private: - using Subrange_ = std::ranges::subrange, std::ranges::sentinel_t>; + using Subrange_ = std::ranges::subrange, + std::ranges::sentinel_t>; Subrange_ out_; enum { buffer_size = 256 }; T data_[buffer_size]; @@ -1024,8 +1031,7 @@ class range_buffer final : public Traits, public buffer { } void flush() { - if (std::ranges::empty(out_)) - return; + if (std::ranges::empty(out_)) return; auto size = this->size(); this->clear(); auto it_end = copy_str(data_, data_ + this->limit(size), @@ -1036,9 +1042,13 @@ class range_buffer final : public Traits, public buffer { public: template explicit range_buffer(Out&& out, size_t n = buffer_size) - : Traits(n), buffer(data_, 0, buffer_size), out_(std::forward(out)) {} + : Traits(n), + buffer(data_, 0, buffer_size), + out_(std::forward(out)) {} range_buffer(range_buffer&& other) - : Traits(other), buffer(data_, 0, buffer_size), out_(std::move(other.out_)) {} + : Traits(other), + buffer(data_, 0, buffer_size), + out_(std::move(other.out_)) {} ~range_buffer() { flush(); } auto out() -> Subrange_ { @@ -1049,9 +1059,12 @@ class range_buffer final : public Traits, public buffer { }; template -class range_buffer, T, Traits> final : public Traits, public buffer { +class range_buffer, T, Traits> final + : public Traits, + public buffer { private: - using Subrange_ = std::ranges::subrange, std::ranges::sentinel_t>; + using Subrange_ = std::ranges::subrange, + std::ranges::sentinel_t>; Output& out_; enum { buffer_size = 256 }; T data_[buffer_size]; @@ -1071,7 +1084,9 @@ class range_buffer, T, Traits> final : public explicit range_buffer(Output& out, size_t n = buffer_size) : Traits(n), buffer(data_, 0, buffer_size), out_(out) {} range_buffer(range_buffer&& other) - : Traits(other), buffer(data_, 0, buffer_size), out_(std::move(other.out_)) {} + : Traits(other), + buffer(data_, 0, buffer_size), + out_(std::move(other.out_)) {} ~range_buffer() { flush(); } auto out() -> Subrange_ { @@ -1082,9 +1097,12 @@ class range_buffer, T, Traits> final : public }; template -class range_buffer, T, Traits> final : public Traits, public buffer { +class range_buffer, T, Traits> final + : public Traits, + public buffer { private: - using Subrange_ = std::ranges::subrange, std::ranges::sentinel_t>; + using Subrange_ = std::ranges::subrange, + std::ranges::sentinel_t>; Output& out_; enum { buffer_size = 256 }; T data_[buffer_size]; @@ -1097,14 +1115,17 @@ class range_buffer, T, Traits> final : public Trait void flush() { auto size = this->size(); this->clear(); - copy_str(data_, data_ + this->limit(size), std::inserter(out_, out_.end())); + copy_str(data_, data_ + this->limit(size), + std::inserter(out_, out_.end())); } public: explicit range_buffer(Output& out, size_t n = buffer_size) : Traits(n), buffer(data_, 0, buffer_size), out_(out) {} range_buffer(range_buffer&& other) - : Traits(other), buffer(data_, 0, buffer_size), out_(std::move(other.out_)) {} + : Traits(other), + buffer(data_, 0, buffer_size), + out_(std::move(other.out_)) {} ~range_buffer() { flush(); } auto out() -> Subrange_ { @@ -1775,43 +1796,39 @@ struct is_container_push_backable : std::false_type {}; template struct is_container_push_backable< - Container, T, - void_t().push_back(std::declval()))> -> : std::true_type {}; + Container, T, + void_t().push_back(std::declval()))>> + : std::true_type {}; template struct is_container_insertable : std::false_type {}; template struct is_container_insertable< - Container, T, - void_t().insert( - std::declval>(), - std::declval() - ))> -> : std::integral_constant::value -> {}; + Container, T, + void_t().insert( + std::declval>(), + std::declval()))>> + : std::integral_constant::value> { +}; #endif // Maps an output iterator to a buffer. #if FMT_OUTPUT_RANGES -template -decltype(auto) get_buffer(Output&& out) { +template decltype(auto) get_buffer(Output&& out) { if constexpr (std::ranges::output_range) { return range_buffer, T>(std::forward(out)); - } - else if constexpr (is_back_insert_iterator>::value) { + } else if constexpr (is_back_insert_iterator>::value) { using Container_ = typename remove_cvref_t::container_type; if constexpr (std::is_base_of, Container_>::value) { return get_container(out); + } else { + return iterator_buffer, T>( + std::forward(out)); } - else { - return iterator_buffer, T>(std::forward(out)); - } - } - else { - return iterator_buffer, T>(std::forward(out)); + } else { + return iterator_buffer, T>( + std::forward(out)); } } @@ -1823,17 +1840,14 @@ decltype(auto) get_appendable_buffer(Output&& out) { if constexpr (is_container_push_backable::value) { using Iterator_ = std::back_insert_iterator>; return range_buffer(std::forward(out)); - } - else { + } else { using Iterator_ = std::insert_iterator>; return range_buffer(std::forward(out)); } - } - else { + } else { return range_buffer, T>(std::forward(out)); } - } - else { + } else { return get_buffer(std::forward(out)); } } @@ -1944,8 +1958,8 @@ struct out_storage { using range = void; Out out_; - template , out_storage>::value)> + template , + out_storage>::value)> FMT_CONSTEXPR out_storage(Value&& value) : out_(std::forward(value)) {} out_storage(out_storage&&) = default; @@ -1955,15 +1969,14 @@ struct out_storage { }; #if FMT_OUTPUT_RANGES -template -struct out_storage { +template struct out_storage { using iterator = std::ranges::iterator_t; using sentinel = std::ranges::sentinel_t; using range = std::ranges::subrange; range out_; - template , out_storage>::value)> + template , + out_storage>::value)> FMT_CONSTEXPR out_storage(Value&& value) : out_(std::forward(value)) {} out_storage(out_storage&&) = default; @@ -2086,10 +2099,9 @@ template class basic_format_context { Storage_ out_storage_; basic_format_args args_; detail::locale_ref loc_; - using ItOrRange_ = conditional_t< - std::is_void::value, - typename Storage_::iterator, - typename Storage_::range>; + using ItOrRange_ = + conditional_t::value, + typename Storage_::iterator, typename Storage_::range>; public: using iterator = typename Storage_::iterator; @@ -2132,9 +2144,11 @@ template class basic_format_context { // Advances the begin iterator to ``it``. void advance_to(ItOrRange_ it_or_range) { #if FMT_OUTPUT_RANGES - if (!detail::is_back_insert_iterator()) out_storage_.out_ = std::move(it_or_range); + if (!detail::is_back_insert_iterator()) + out_storage_.out_ = std::move(it_or_range); #else - if (!detail::is_back_insert_iterator()) out_storage_.out_ = it_or_range; + if (!detail::is_back_insert_iterator()) + out_storage_.out_ = it_or_range; #endif } @@ -3194,8 +3208,8 @@ FMT_NODISCARD FMT_INLINE auto format(format_string fmt, T&&... args) rather than directly writing if it is a typical insertable contianer type. */ template - || std::output_iterator, char>)> + FMT_ENABLE_IF(std::ranges::output_range || + std::output_iterator, char>)> auto vformat_to(Output&& out, string_view fmt, format_args args) { auto&& buf = detail::get_appendable_buffer(std::forward(out)); detail::vformat_to(buf, fmt, args, {}); @@ -3205,8 +3219,8 @@ auto vformat_to(Output&& out, string_view fmt, format_args args) { /** Formats a string and writes the output to ``out``, writing directly into the range [begin, end). */ template - || std::output_iterator, char>)> + FMT_ENABLE_IF(std::ranges::output_range || + std::output_iterator, char>)> auto vformat_into(Output&& out, string_view fmt, format_args args) { auto&& buf = detail::get_buffer(std::forward(out)); detail::vformat_to(buf, fmt, args, {}); @@ -3229,7 +3243,8 @@ auto vformat_to(OutputIt out, string_view fmt, format_args args) -> OutputIt { Formats ``args`` according to specifications in ``fmt``, writes the result to the output range or iterator ``out`` and returns the subrange past the end of the output range. `format_to` will write to the end of a container (if it is an - insertable container). `format_to` does not append a terminating null character. + insertable container). `format_to` does not append a terminating null + character. **Example**:: @@ -3243,18 +3258,20 @@ auto vformat_to(OutputIt out, string_view fmt, format_args args) -> OutputIt { \endrst */ template - || std::output_iterator, char>)> + FMT_ENABLE_IF(std::ranges::output_range || + std::output_iterator, char>)> FMT_INLINE auto format_to(Output&& out, format_string fmt, T&&... args) { - return vformat_to(std::forward(out), fmt, fmt::make_format_args(args...)); + return vformat_to(std::forward(out), fmt, + fmt::make_format_args(args...)); } /** \rst Formats ``args`` according to specifications in ``fmt``, writes the result into the output range or iterator ``out`` and returns the subrange past the end of - the output range. `format_into` does not append into a contianer and only writes - into it. `format_into` does not append or write a terminating null character. + the output range. `format_into` does not append into a contianer and only + writes into it. `format_into` does not append or write a terminating null + character. **Example**:: @@ -3263,10 +3280,12 @@ FMT_INLINE auto format_to(Output&& out, format_string fmt, T&&... args) { \endrst */ template - || std::output_iterator, char>)> -FMT_INLINE auto format_into(Output&& out, format_string fmt, T&&... args) { - return vformat_into(std::forward(out), fmt, fmt::make_format_args(args...)); + FMT_ENABLE_IF(std::ranges::output_range || + std::output_iterator, char>)> +FMT_INLINE auto format_into(Output&& out, format_string fmt, + T&&... args) { + return vformat_into(std::forward(out), fmt, + fmt::make_format_args(args...)); } #else /** diff --git a/include/fmt/format.h b/include/fmt/format.h index abf4a92f..0bbefadb 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1063,8 +1063,8 @@ namespace detail_exported { #if FMT_USE_NONTYPE_TEMPLATE_ARGS template struct fixed_string { constexpr fixed_string(const Char (&str)[N]) { - detail::copy_str(static_cast(str), - static_cast(str + N), data); + detail::copy_str( + static_cast(str), static_cast(str + N), data); } Char data[N] = {}; }; @@ -1161,10 +1161,10 @@ using uint32_or_64_or_128_t = template using uint64_or_128_t = conditional_t() <= 64, uint64_t, uint128_t>; -#define FMT_POWERS_OF_10(factor) \ - factor * 10, (factor) * 100, (factor) * 1000, (factor) * 10000, \ - (factor) * 100000, (factor) * 1000000, (factor) * 10000000, \ - (factor) * 100000000, (factor) * 1000000000 +#define FMT_POWERS_OF_10(factor) \ + factor * 10, (factor)*100, (factor)*1000, (factor)*10000, (factor)*100000, \ + (factor)*1000000, (factor)*10000000, (factor)*100000000, \ + (factor)*1000000000 // Converts value in the range [0, 100) to a string. constexpr const char* digits2(size_t value) { @@ -4543,10 +4543,9 @@ inline auto format(const Locale& loc, format_string fmt, T&&... args) #if FMT_OUTPUT_RANGES template - || std::output_iterator) - && detail::is_locale::value)> + FMT_ENABLE_IF((std::ranges::output_range || + std::output_iterator< + Output, char>)&&detail::is_locale::value)> auto vformat_to(Output&& out, const Locale& loc, string_view fmt, format_args args) { auto&& buf = detail::get_appendable_buffer(std::forward(out)); @@ -4555,12 +4554,11 @@ auto vformat_to(Output&& out, const Locale& loc, string_view fmt, } template - || std::output_iterator) - && detail::is_locale::value)> + FMT_ENABLE_IF((std::ranges::output_range || + std::output_iterator< + Output, char>)&&detail::is_locale::value)> auto vformat_into(Output&& out, const Locale& loc, string_view fmt, - format_args args) { + format_args args) { auto&& buf = detail::get_buffer(std::forward(out)); detail::vformat_to(buf, fmt, args, detail::locale_ref(loc)); return detail::get_iterator(buf, out); @@ -4568,22 +4566,24 @@ auto vformat_into(Output&& out, const Locale& loc, string_view fmt, template - || std::output_iterator, char>) - && detail::is_locale::value)> + (std::ranges::output_range || + std::output_iterator, + char>)&&detail::is_locale::value)> FMT_INLINE auto format_to(Output&& out, const Locale& loc, format_string fmt, T&&... args) { - return vformat_to(std::forward(out), loc, fmt, fmt::make_format_args(args...)); + return vformat_to(std::forward(out), loc, fmt, + fmt::make_format_args(args...)); } template - || std::output_iterator, char>) - && detail::is_locale::value)> + (std::ranges::output_range || + std::output_iterator, + char>)&&detail::is_locale::value)> FMT_INLINE auto format_into(Output&& out, const Locale& loc, - format_string fmt, T&&... args) { - return vformat_into(std::forward(out), loc, fmt, fmt::make_format_args(args...)); + format_string fmt, T&&... args) { + return vformat_into(std::forward(out), loc, fmt, + fmt::make_format_args(args...)); } #else template , - FMT_ENABLE_IF((std::ranges::output_range - || std::output_iterator, Char>) - && detail::is_exotic_char::value)> + FMT_ENABLE_IF(( + std::ranges::output_range || + std::output_iterator, + Char>)&&detail::is_exotic_char::value)> auto vformat_to(Output&& out, const S& format_str, - basic_format_args>> args) -{ + basic_format_args>> args) { auto&& buf = detail::get_appendable_buffer(std::forward(out)); detail::vformat_to(buf, detail::to_string_view(format_str), args); return detail::get_iterator(buf, out); } template , - FMT_ENABLE_IF((std::ranges::output_range - || std::output_iterator, Char>) - && detail::is_exotic_char::value)> -auto vformat_into(Output&& out, const S& format_str, - basic_format_args>> args) -{ + FMT_ENABLE_IF(( + std::ranges::output_range || + std::output_iterator, + Char>)&&detail::is_exotic_char::value)> +auto vformat_into( + Output&& out, const S& format_str, + basic_format_args>> args) { auto&& buf = detail::get_buffer(std::forward(out)); detail::vformat_to(buf, detail::to_string_view(format_str), args); return detail::get_iterator(buf, out); } -template , - FMT_ENABLE_IF((std::ranges::output_range - || std::output_iterator, Char>) - && detail::is_exotic_char::value)> +template , + FMT_ENABLE_IF(( + std::ranges::output_range || + std::output_iterator, + Char>)&&detail::is_exotic_char::value)> inline auto format_to(Output&& out, const S& fmt, T&&... args) { return vformat_to(std::forward(out), detail::to_string_view(fmt), fmt::make_format_args>(args...)); } -template , - FMT_ENABLE_IF((std::ranges::output_range - || std::output_iterator, Char>) - && detail::is_exotic_char::value)> +template , + FMT_ENABLE_IF(( + std::ranges::output_range || + std::output_iterator, + Char>)&&detail::is_exotic_char::value)> inline auto format_into(Output&& out, const S& fmt, T&&... args) { return vformat_into(std::forward(out), detail::to_string_view(fmt), - fmt::make_format_args>(args...)); + fmt::make_format_args>(args...)); } template , - FMT_ENABLE_IF((std::ranges::output_range - || std::output_iterator, Char>) - && detail::is_locale::value - && detail::is_exotic_char::value)> + FMT_ENABLE_IF( + (std::ranges::output_range || + std::output_iterator, + Char>)&&detail::is_locale::value&& + detail::is_exotic_char::value)> inline auto vformat_to( Output&& out, const Locale& loc, const S& format_str, basic_format_args>> args) { @@ -200,10 +202,11 @@ inline auto vformat_to( template , - FMT_ENABLE_IF((std::ranges::output_range - || std::output_iterator, Char>) - && detail::is_locale::value - && detail::is_exotic_char::value)> + FMT_ENABLE_IF( + (std::ranges::output_range || + std::output_iterator, + Char>)&&detail::is_locale::value&& + detail::is_exotic_char::value)> inline auto vformat_into( Output&& out, const Locale& loc, const S& format_str, basic_format_args>> args) { @@ -216,29 +219,29 @@ inline auto vformat_into( template < typename Output, typename Locale, typename S, typename... T, typename Char = char_t, - bool enable = (std::ranges::output_range - || std::output_iterator, Char>) - && detail::is_locale::value - && detail::is_exotic_char::value, + bool enable = (std::ranges::output_range || + std::output_iterator, Char>)&&detail:: + is_locale::value&& detail::is_exotic_char::value, FMT_ENABLE_IF(enable)> inline auto format_to(Output&& out, const Locale& loc, const S& format_str, T&&... args) { - return vformat_to(std::forward(out), loc, detail::to_string_view(format_str), + return vformat_to(std::forward(out), loc, + detail::to_string_view(format_str), fmt::make_format_args>(args...)); } template < typename Output, typename Locale, typename S, typename... T, typename Char = char_t, - bool enable = (std::ranges::output_range - || std::output_iterator, Char>) - && detail::is_locale::value - && detail::is_exotic_char::value, + bool enable = (std::ranges::output_range || + std::output_iterator, Char>)&&detail:: + is_locale::value&& detail::is_exotic_char::value, FMT_ENABLE_IF(enable)> inline auto format_into(Output&& out, const Locale& loc, const S& format_str, - T&&... args) { - return vformat_into(std::forward(out), loc, detail::to_string_view(format_str), - fmt::make_format_args>(args...)); + T&&... args) { + return vformat_into(std::forward(out), loc, + detail::to_string_view(format_str), + fmt::make_format_args>(args...)); } #else template , @@ -275,11 +278,11 @@ inline auto vformat_to( return detail::get_iterator(buf, out); } -template , - bool enable = detail::is_output_iterator::value && - detail::is_locale::value && - detail::is_exotic_char::value> +template < + typename OutputIt, typename Locale, typename S, typename... T, + typename Char = char_t, + bool enable = detail::is_output_iterator::value&& + detail::is_locale::value&& detail::is_exotic_char::value> inline auto format_to(OutputIt out, const Locale& loc, const S& format_str, T&&... args) -> typename std::enable_if::type { diff --git a/test/output-range-test.cc b/test/output-range-test.cc index 3adcb6fd..5d79bdc4 100644 --- a/test/output-range-test.cc +++ b/test/output-range-test.cc @@ -9,15 +9,15 @@ #if FMT_OUTPUT_RANGES -#include "gmock/gmock.h" -#include "gtest-extra.h" -#include "util.h" +# include +# include +# include +# include +# include -#include -#include -#include -#include -#include +# include "gmock/gmock.h" +# include "gtest-extra.h" +# include "util.h" TEST(output_range_c_array_char_test, format_into) { char buffer[4]; @@ -166,12 +166,14 @@ TEST(output_range_list_char_test, format_to) { auto result = fmt::format_to(buffer, "{}", "abc"); EXPECT_EQ(buffer.end(), result.begin()); EXPECT_EQ(std::ranges::next(buffer.begin(), 3), result.begin()); - EXPECT_EQ(std::ranges::next(buffer.begin(), (std::ptrdiff_t)buffer.size()), result.begin()); + EXPECT_EQ(std::ranges::next(buffer.begin(), (std::ptrdiff_t)buffer.size()), + result.begin()); EXPECT_TRUE(std::ranges::equal(fmt::string_view("abc"), buffer)); result = fmt::format_to(buffer, "x{}y", "abc"); EXPECT_EQ(buffer.end(), result.begin()); EXPECT_EQ(std::ranges::next(buffer.begin(), 8), result.begin()); - EXPECT_EQ(std::ranges::next(buffer.begin(), (std::ptrdiff_t)buffer.size()), result.begin()); + EXPECT_EQ(std::ranges::next(buffer.begin(), (std::ptrdiff_t)buffer.size()), + result.begin()); EXPECT_TRUE(std::ranges::equal(fmt::string_view("abcxabcy"), buffer)); } @@ -180,12 +182,14 @@ TEST(output_range_deque_char_test, format_to) { auto result = fmt::format_to(buffer, "{}", "abc"); EXPECT_EQ(buffer.end(), result.begin()); EXPECT_EQ(std::ranges::next(buffer.begin(), 3), result.begin()); - EXPECT_EQ(std::ranges::next(buffer.begin(), (std::ptrdiff_t)buffer.size()), result.begin()); + EXPECT_EQ(std::ranges::next(buffer.begin(), (std::ptrdiff_t)buffer.size()), + result.begin()); EXPECT_TRUE(std::ranges::equal(fmt::string_view("abc"), buffer)); result = fmt::format_to(buffer, "x{}y", "abc"); EXPECT_EQ(buffer.end(), result.begin()); EXPECT_EQ(std::ranges::next(buffer.begin(), 8), result.begin()); - EXPECT_EQ(std::ranges::next(buffer.begin(), (std::ptrdiff_t)buffer.size()), result.begin()); + EXPECT_EQ(std::ranges::next(buffer.begin(), (std::ptrdiff_t)buffer.size()), + result.begin()); EXPECT_TRUE(std::ranges::equal(fmt::string_view("abcxabcy"), buffer)); }