diff --git a/.gitignore b/.gitignore index 2635026a69db..d858abad2d34 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ build/ cmake_install.cmake fmt-*.cmake fmt.pc +.gradle/ diff --git a/include/fmt/base.h b/include/fmt/base.h index f91f8e825354..e1f8f5122cc0 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -448,8 +448,8 @@ template constexpr const char* narrow(const T*) { return nullptr; } constexpr FMT_ALWAYS_INLINE const char* narrow(const char* s) { return s; } template -FMT_CONSTEXPR auto compare(const Char* s1, const Char* s2, std::size_t n) - -> int { +FMT_CONSTEXPR auto compare(const Char* s1, const Char* s2, + std::size_t n) -> int { if (!is_constant_evaluated() && sizeof(Char) == 1) return memcmp(s1, s2, n); for (; n != 0; ++s1, ++s2, --n) { if (*s1 < *s2) return -1; @@ -1088,16 +1088,16 @@ struct use_format_as_member< T, bool_constant>::value>> : std::true_type {}; -template > +template > using use_formatter = bool_constant<(std::is_class::value || std::is_enum::value || std::is_union::value || std::is_array::value) && !has_to_string_view::value && !is_named_arg::value && !use_format_as::value && !use_format_as_member::value>; -template > +template > auto has_formatter_impl(T* p, buffered_context* ctx = nullptr) - -> decltype(formatter().format(*p, *ctx), std::true_type()); + -> decltype(formatter().format(*p, *ctx), std::true_type()); template auto has_formatter_impl(...) -> std::false_type; // T can be const-qualified to check if it is const-formattable. @@ -1129,8 +1129,9 @@ template struct type_mapper { -> conditional_t; template ::value)> - static auto map(T) -> conditional_t< - std::is_same::value || std::is_same::value, Char, void>; + static auto map(T) -> conditional_t::value || + std::is_same::value, + Char, void>; static auto map(float) -> float; static auto map(double) -> double; @@ -1336,10 +1337,9 @@ template struct parse_dynamic_spec_result { // Parses integer | "{" [arg_id] "}". template -FMT_CONSTEXPR auto parse_dynamic_spec(const Char* begin, const Char* end, - int& value, arg_ref& ref, - parse_context& ctx) - -> parse_dynamic_spec_result { +FMT_CONSTEXPR auto parse_dynamic_spec( + const Char* begin, const Char* end, int& value, arg_ref& ref, + parse_context& ctx) -> parse_dynamic_spec_result { FMT_ASSERT(begin != end, ""); auto kind = arg_id_kind::none; if ('0' <= *begin && *begin <= '9') { @@ -1399,8 +1399,8 @@ enum class state { start, align, sign, hash, zero, width, precision, locale }; template FMT_CONSTEXPR auto parse_format_specs(const Char* begin, const Char* end, dynamic_format_specs& specs, - parse_context& ctx, type arg_type) - -> const Char* { + parse_context& ctx, + type arg_type) -> const Char* { auto c = '\0'; if (end - begin > 1) { auto next = to_ascii(begin[1]); @@ -1535,10 +1535,8 @@ FMT_CONSTEXPR auto parse_format_specs(const Char* begin, const Char* end, } template -FMT_CONSTEXPR FMT_INLINE auto parse_replacement_field(const Char* begin, - const Char* end, - Handler&& handler) - -> const Char* { +FMT_CONSTEXPR FMT_INLINE auto parse_replacement_field( + const Char* begin, const Char* end, Handler&& handler) -> const Char* { ++begin; if (begin == end) { handler.on_error("invalid format string"); @@ -1674,8 +1672,8 @@ class format_string_checker { on_format_specs(id, begin, begin); // Call parse() on empty specs. } - FMT_CONSTEXPR auto on_format_specs(int id, const Char* begin, const Char* end) - -> const Char* { + FMT_CONSTEXPR auto on_format_specs(int id, const Char* begin, + const Char* end) -> const Char* { context_.advance_to(begin); if (id >= 0 && id < NUM_ARGS) return parse_funcs_[id](context_); while (begin != end && *begin != '}') ++begin; @@ -1764,14 +1762,14 @@ template class buffer { } /// Appends data to the end of the buffer. - template + template // Workaround for MSVC2019 to fix error C2893: Failed to specialize function // template 'void fmt::v11::detail::buffer::append(const U *,const U *)'. #if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1940 FMT_CONSTEXPR20 #endif void - append(const U* begin, const U* end) { + append(const UT* begin, const UT* end) { while (begin != end) { auto count = to_unsigned(end - begin); try_reserve(size_ + count); @@ -1972,8 +1970,8 @@ struct is_back_insert_iterator> : std::true_type {}; // An optimized version of std::copy with the output value type (T). template ::value)> -FMT_CONSTEXPR20 auto copy(InputIt begin, InputIt end, OutputIt out) - -> OutputIt { +FMT_CONSTEXPR20 auto copy(InputIt begin, InputIt end, + OutputIt out) -> OutputIt { get_container(out).append(begin, end); return out; } @@ -2325,8 +2323,8 @@ template struct native_formatter { FMT_PRAGMA_CLANG(diagnostic ignored "-Wundefined-inline") template - FMT_CONSTEXPR auto format(const T& val, FormatContext& ctx) const - -> decltype(ctx.out()); + FMT_CONSTEXPR auto format(const T& val, + FormatContext& ctx) const -> decltype(ctx.out()); }; template @@ -2466,8 +2464,8 @@ template class basic_format_arg { } auto format_custom(const char_type* parse_begin, - parse_context& parse_ctx, Context& ctx) - -> bool { + parse_context& parse_ctx, + Context& ctx) -> bool { if (type_ != detail::type::custom_type) return false; parse_ctx.advance_to(parse_begin); value_.custom.format(value_.custom.value, parse_ctx, ctx); @@ -2755,8 +2753,8 @@ inline auto arg(const Char* name, const T& arg) -> detail::named_arg { template , char>::value)> -auto vformat_to(OutputIt&& out, string_view fmt, format_args args) - -> remove_cvref_t { +auto vformat_to(OutputIt&& out, string_view fmt, + format_args args) -> remove_cvref_t { auto&& buf = detail::get_buffer(out); detail::vformat_to(buf, fmt, args, {}); return detail::get_iterator(buf, out); @@ -2775,8 +2773,8 @@ auto vformat_to(OutputIt&& out, string_view fmt, format_args args) template , char>::value)> -FMT_INLINE auto format_to(OutputIt&& out, format_string fmt, T&&... args) - -> remove_cvref_t { +FMT_INLINE auto format_to(OutputIt&& out, format_string fmt, + T&&... args) -> remove_cvref_t { return vformat_to(out, fmt.str, vargs{{args...}}); } @@ -2789,8 +2787,8 @@ template struct format_to_n_result { template ::value)> -auto vformat_to_n(OutputIt out, size_t n, string_view fmt, format_args args) - -> format_to_n_result { +auto vformat_to_n(OutputIt out, size_t n, string_view fmt, + format_args args) -> format_to_n_result { using traits = detail::fixed_buffer_traits; auto buf = detail::iterator_buffer(out, n); detail::vformat_to(buf, fmt, args, {}); @@ -2824,15 +2822,15 @@ struct format_to_result { }; template -auto vformat_to(char (&out)[N], string_view fmt, format_args args) - -> format_to_result { +auto vformat_to(char (&out)[N], string_view fmt, + format_args args) -> format_to_result { auto result = vformat_to_n(out, N, fmt, args); return {result.out, result.size > N}; } template -FMT_INLINE auto format_to(char (&out)[N], format_string fmt, T&&... args) - -> format_to_result { +FMT_INLINE auto format_to(char (&out)[N], format_string fmt, + T&&... args) -> format_to_result { auto result = vformat_to_n(out, N, fmt.str, vargs{{args...}}); return {result.out, result.size > N}; } diff --git a/include/fmt/printf.h b/include/fmt/printf.h index e72684018546..ac13fc0e9c82 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -139,10 +139,10 @@ template class arg_converter { if (type_ != 's') operator()(value); } - template ::value)> - void operator()(U value) { + template ::value)> + void operator()(UT value) { bool is_signed = type_ == 'd' || type_ == 'i'; - using target_type = conditional_t::value, U, T>; + using target_type = conditional_t::value, UT, T>; if (const_check(sizeof(target_type) <= sizeof(int))) { // Extra casts are used to silence warnings. using unsigned_type = typename make_unsigned_or_bool::type; @@ -157,12 +157,12 @@ template class arg_converter { if (is_signed) arg_ = static_cast(value); else - arg_ = static_cast::type>(value); + arg_ = static_cast::type>(value); } } - template ::value)> - void operator()(U) {} // No conversion needed for non-integral types. + template ::value)> + void operator()(UT) {} // No conversion needed for non-integral types. }; // Converts an integer argument to T for printf, if T is an integral type. @@ -229,8 +229,8 @@ class printf_width_handler { // Workaround for a bug with the XL compiler when initializing // printf_arg_formatter's base class. template -auto make_arg_formatter(basic_appender iter, format_specs& s) - -> arg_formatter { +auto make_arg_formatter(basic_appender iter, + format_specs& s) -> arg_formatter { return {iter, s, locale_ref()}; } @@ -371,8 +371,8 @@ auto parse_header(const Char*& it, const Char* end, format_specs& specs, return arg_index; } -inline auto parse_printf_presentation_type(char c, type t, bool& upper) - -> presentation_type { +inline auto parse_printf_presentation_type(char c, type t, + bool& upper) -> presentation_type { using pt = presentation_type; constexpr auto integral_set = sint_set | uint_set | bool_set | char_set; switch (c) { diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index c6020abee61a..dd74918c97df 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -27,7 +27,7 @@ enum class range_format { disabled, map, set, sequence, string, debug_string }; namespace detail { template class is_map { - template static auto check(U*) -> typename U::mapped_type; + template static auto check(UT*) -> typename UT::mapped_type; template static void check(...); public: @@ -36,7 +36,7 @@ template class is_map { }; template class is_set { - template static auto check(U*) -> typename U::key_type; + template static auto check(UT*) -> typename UT::key_type; template static void check(...); public: @@ -115,8 +115,8 @@ struct is_range_ // tuple_size and tuple_element check. template class is_tuple_like_ { - template ::type> - static auto check(U* p) -> decltype(std::tuple_size::value, 0); + template ::type> + static auto check(UT* p) -> decltype(std::tuple_size::value, 0); template static void check(...); public: @@ -163,11 +163,12 @@ template class is_tuple_formattable_ { static auto all_true(...) -> std::false_type; template - static auto check(index_sequence) -> decltype(all_true( - index_sequence{}, - integer_sequence::type, - C>::value)...>{})); + static auto check(index_sequence) + -> decltype(all_true( + index_sequence{}, + integer_sequence< + bool, (is_formattable::type, + C>::value)...>{})); public: static constexpr const bool value = @@ -333,8 +334,8 @@ struct formatter - auto format(const Tuple& value, FormatContext& ctx) const - -> decltype(ctx.out()) { + auto format(const Tuple& value, + FormatContext& ctx) const -> decltype(ctx.out()) { ctx.advance_to(detail::copy(opening_bracket_, ctx.out())); detail::for_each2( formatters_, value, @@ -388,8 +389,8 @@ struct range_formatter< detail::string_literal{}; bool is_debug = false; - template ::value)> + template ::value)> auto write_debug_string(Output& out, It it, Sentinel end) const -> Output { auto buf = basic_memory_buffer(); for (; it != end; ++it) buf.push_back(*it); @@ -399,8 +400,8 @@ struct range_formatter< out, basic_string_view(buf.data(), buf.size()), specs); } - template ::value)> + template ::value)> auto write_debug_string(Output& out, It, Sentinel) const -> Output { return out; } @@ -525,8 +526,8 @@ struct formatter< } template - auto format(range_type& range, FormatContext& ctx) const - -> decltype(ctx.out()) { + auto format(range_type& range, + FormatContext& ctx) const -> decltype(ctx.out()) { return range_formatter_.format(range, ctx); } }; @@ -610,8 +611,8 @@ struct formatter< } template - auto format(range_type& range, FormatContext& ctx) const - -> decltype(ctx.out()) { + auto format(range_type& range, + FormatContext& ctx) const -> decltype(ctx.out()) { auto out = ctx.out(); if (detail::const_check(range_format_kind::value == range_format::debug_string)) @@ -658,8 +659,8 @@ struct formatter, Char> { } template - auto format(view_ref& value, FormatContext& ctx) const - -> decltype(ctx.out()) { + auto format(view_ref& value, + FormatContext& ctx) const -> decltype(ctx.out()) { auto it = std::forward(value).begin; auto out = ctx.out(); if (it == value.end) return out; @@ -697,9 +698,9 @@ auto join(It begin, Sentinel end, string_view sep) -> join_view { * // Output: 01, 02, 03 */ template -auto join(Range&& r, string_view sep) - -> join_view { +auto join(Range&& r, + string_view sep) -> join_view { return {detail::range_begin(r), detail::range_end(r), sep}; } @@ -780,7 +781,8 @@ namespace detail { // Check if T has an interface like a container adaptor (e.g. std::stack, // std::queue, std::priority_queue). template class is_container_adaptor_like { - template static auto check(U* p) -> typename U::container_type; + template + static auto check(UT* p) -> typename UT::container_type; template static void check(...); public: @@ -826,8 +828,8 @@ FMT_BEGIN_EXPORT * // Output: 1, a */ template -FMT_CONSTEXPR auto join(const std::tuple& tuple, string_view sep) - -> tuple_join_view { +FMT_CONSTEXPR auto join(const std::tuple& tuple, + string_view sep) -> tuple_join_view { return {tuple, sep}; } @@ -841,8 +843,8 @@ FMT_CONSTEXPR auto join(const std::tuple& tuple, string_view sep) * // Output: "1, 2, 3" */ template -auto join(std::initializer_list list, string_view sep) - -> join_view { +auto join(std::initializer_list list, + string_view sep) -> join_view { return join(std::begin(list), std::end(list), sep); }