diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 42d2e103..3129f6a5 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -74,7 +74,7 @@ FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) { if (F::is_signed && !T::is_signed) { // From may be negative, not allowed! - if (fmt::internal::is_negative(from)) { + if (fmt::detail::is_negative(from)) { ec = 1; return {}; } @@ -195,7 +195,7 @@ To safe_duration_cast(std::chrono::duration from, } // multiply with Factor::num without overflow or underflow if (Factor::num != 1) { - const auto max1 = internal::max_value() / Factor::num; + const auto max1 = detail::max_value() / Factor::num; if (count > max1) { ec = 1; return {}; @@ -269,7 +269,7 @@ To safe_duration_cast(std::chrono::duration from, // multiply with Factor::num without overflow or underflow if (Factor::num != 1) { - constexpr auto max1 = internal::max_value() / + constexpr auto max1 = detail::max_value() / static_cast(Factor::num); if (count > max1) { ec = 1; @@ -306,12 +306,12 @@ To safe_duration_cast(std::chrono::duration from, // Usage: f FMT_NOMACRO() #define FMT_NOMACRO -namespace internal { +namespace detail { inline null<> localtime_r FMT_NOMACRO(...) { return null<>(); } inline null<> localtime_s(...) { return null<>(); } inline null<> gmtime_r(...) { return null<>(); } inline null<> gmtime_s(...) { return null<>(); } -} // namespace internal +} // namespace detail // Thread-safe replacement for std::localtime inline std::tm localtime(std::time_t time) { @@ -322,22 +322,22 @@ inline std::tm localtime(std::time_t time) { dispatcher(std::time_t t) : time_(t) {} bool run() { - using namespace fmt::internal; + using namespace fmt::detail; return handle(localtime_r(&time_, &tm_)); } bool handle(std::tm* tm) { return tm != nullptr; } - bool handle(internal::null<>) { - using namespace fmt::internal; + bool handle(detail::null<>) { + using namespace fmt::detail; return fallback(localtime_s(&tm_, &time_)); } bool fallback(int res) { return res == 0; } #if !FMT_MSC_VER - bool fallback(internal::null<>) { - using namespace fmt::internal; + bool fallback(detail::null<>) { + using namespace fmt::detail; std::tm* tm = std::localtime(&time_); if (tm) tm_ = *tm; return tm != nullptr; @@ -359,21 +359,21 @@ inline std::tm gmtime(std::time_t time) { dispatcher(std::time_t t) : time_(t) {} bool run() { - using namespace fmt::internal; + using namespace fmt::detail; return handle(gmtime_r(&time_, &tm_)); } bool handle(std::tm* tm) { return tm != nullptr; } - bool handle(internal::null<>) { - using namespace fmt::internal; + bool handle(detail::null<>) { + using namespace fmt::detail; return fallback(gmtime_s(&tm_, &time_)); } bool fallback(int res) { return res == 0; } #if !FMT_MSC_VER - bool fallback(internal::null<>) { + bool fallback(detail::null<>) { std::tm* tm = std::gmtime(&time_); if (tm) tm_ = *tm; return tm != nullptr; @@ -386,7 +386,7 @@ inline std::tm gmtime(std::time_t time) { return gt.tm_; } -namespace internal { +namespace detail { inline size_t strftime(char* str, size_t count, const char* format, const std::tm* time) { return std::strftime(str, count, format, time); @@ -396,7 +396,7 @@ inline size_t strftime(wchar_t* str, size_t count, const wchar_t* format, const std::tm* time) { return std::wcsftime(str, count, format, time); } -} // namespace internal +} // namespace detail template struct formatter { template @@ -405,7 +405,7 @@ template struct formatter { if (it != ctx.end() && *it == ':') ++it; auto end = it; while (end != ctx.end() && *end != '}') ++end; - tm_format.reserve(internal::to_unsigned(end - it + 1)); + tm_format.reserve(detail::to_unsigned(end - it + 1)); tm_format.append(it, end); tm_format.push_back('\0'); return end; @@ -417,7 +417,7 @@ template struct formatter { size_t start = buf.size(); for (;;) { size_t size = buf.capacity() - start; - size_t count = internal::strftime(&buf[start], size, &tm_format[0], &tm); + size_t count = detail::strftime(&buf[start], size, &tm_format[0], &tm); if (count != 0) { buf.resize(start + count); break; @@ -438,7 +438,7 @@ template struct formatter { basic_memory_buffer tm_format; }; -namespace internal { +namespace detail { template FMT_CONSTEXPR const char* get_units() { return nullptr; } @@ -879,7 +879,7 @@ struct chrono_formatter { if (isnan(value)) return write_nan(); uint32_or_64_or_128_t n = to_unsigned(to_nonnegative_int(value, max_value())); - int num_digits = internal::count_digits(n); + int num_digits = detail::count_digits(n); if (width > num_digits) out = std::fill_n(out, width - num_digits, '0'); out = format_decimal(out, n, num_digits); } @@ -1009,14 +1009,14 @@ struct chrono_formatter { out = format_duration_unit(out); } }; -} // namespace internal +} // namespace detail template struct formatter, Char> { private: basic_format_specs specs; int precision; - using arg_ref_type = internal::arg_ref; + using arg_ref_type = detail::arg_ref; arg_ref_type width_ref; arg_ref_type precision_ref; mutable basic_string_view format_str; @@ -1037,7 +1037,7 @@ struct formatter, Char> { return arg_ref_type(arg_id); } - FMT_CONSTEXPR arg_ref_type make_arg_ref(internal::auto_id) { + FMT_CONSTEXPR arg_ref_type make_arg_ref(detail::auto_id) { return arg_ref_type(context.next_arg_id()); } @@ -1067,17 +1067,17 @@ struct formatter, Char> { auto begin = ctx.begin(), end = ctx.end(); if (begin == end || *begin == '}') return {begin, begin}; spec_handler handler{*this, ctx, format_str}; - begin = internal::parse_align(begin, end, handler); + begin = detail::parse_align(begin, end, handler); if (begin == end) return {begin, begin}; - begin = internal::parse_width(begin, end, handler); + begin = detail::parse_width(begin, end, handler); if (begin == end) return {begin, begin}; if (*begin == '.') { if (std::is_floating_point::value) - begin = internal::parse_precision(begin, end, handler); + begin = detail::parse_precision(begin, end, handler); else handler.on_error("precision not allowed for this argument type"); } - end = parse_chrono_format(begin, end, internal::chrono_format_checker()); + end = parse_chrono_format(begin, end, detail::chrono_format_checker()); return {begin, end}; } @@ -1088,7 +1088,7 @@ struct formatter, Char> { -> decltype(ctx.begin()) { auto range = do_parse(ctx); format_str = basic_string_view( - &*range.begin, internal::to_unsigned(range.end - range.begin)); + &*range.begin, detail::to_unsigned(range.end - range.begin)); return range.end; } @@ -1099,20 +1099,20 @@ struct formatter, Char> { // is not specified. basic_memory_buffer buf; auto out = std::back_inserter(buf); - internal::handle_dynamic_spec(specs.width, - width_ref, ctx); - internal::handle_dynamic_spec( - precision, precision_ref, ctx); + detail::handle_dynamic_spec(specs.width, width_ref, + ctx); + detail::handle_dynamic_spec(precision, + precision_ref, ctx); if (begin == end || *begin == '}') { - out = internal::format_duration_value(out, d.count(), precision); - internal::format_duration_unit(out); + out = detail::format_duration_value(out, d.count(), precision); + detail::format_duration_unit(out); } else { - internal::chrono_formatter f( + detail::chrono_formatter f( ctx, out, d); f.precision = precision; parse_chrono_format(begin, end, f); } - return internal::write( + return detail::write( ctx.out(), basic_string_view(buf.data(), buf.size()), specs); } }; diff --git a/include/fmt/color.h b/include/fmt/color.h index 9dfabdff..b65f892a 100644 --- a/include/fmt/color.h +++ b/include/fmt/color.h @@ -198,7 +198,7 @@ struct rgb { uint8_t b; }; -namespace internal { +namespace detail { // color is a struct of either a rgb color or a terminal color. struct color_type { @@ -221,7 +221,7 @@ struct color_type { uint32_t rgb_color; } value; }; -} // namespace internal +} // namespace detail // Experimental text formatting support. class text_style { @@ -298,11 +298,11 @@ class text_style { FMT_CONSTEXPR bool has_emphasis() const FMT_NOEXCEPT { return static_cast(ems) != 0; } - FMT_CONSTEXPR internal::color_type get_foreground() const FMT_NOEXCEPT { + FMT_CONSTEXPR detail::color_type get_foreground() const FMT_NOEXCEPT { FMT_ASSERT(has_foreground(), "no foreground specified for this style"); return foreground_color; } - FMT_CONSTEXPR internal::color_type get_background() const FMT_NOEXCEPT { + FMT_CONSTEXPR detail::color_type get_background() const FMT_NOEXCEPT { FMT_ASSERT(has_background(), "no background specified for this style"); return background_color; } @@ -313,7 +313,7 @@ class text_style { private: FMT_CONSTEXPR text_style(bool is_foreground, - internal::color_type text_color) FMT_NOEXCEPT + detail::color_type text_color) FMT_NOEXCEPT : set_foreground_color(), set_background_color(), ems() { @@ -326,23 +326,23 @@ class text_style { } } - friend FMT_CONSTEXPR_DECL text_style fg(internal::color_type foreground) + friend FMT_CONSTEXPR_DECL text_style fg(detail::color_type foreground) FMT_NOEXCEPT; - friend FMT_CONSTEXPR_DECL text_style bg(internal::color_type background) + friend FMT_CONSTEXPR_DECL text_style bg(detail::color_type background) FMT_NOEXCEPT; - internal::color_type foreground_color; - internal::color_type background_color; + detail::color_type foreground_color; + detail::color_type background_color; bool set_foreground_color; bool set_background_color; emphasis ems; }; -FMT_CONSTEXPR text_style fg(internal::color_type foreground) FMT_NOEXCEPT { +FMT_CONSTEXPR text_style fg(detail::color_type foreground) FMT_NOEXCEPT { return text_style(/*is_foreground=*/true, foreground); } -FMT_CONSTEXPR text_style bg(internal::color_type background) FMT_NOEXCEPT { +FMT_CONSTEXPR text_style bg(detail::color_type background) FMT_NOEXCEPT { return text_style(/*is_foreground=*/false, background); } @@ -350,15 +350,15 @@ FMT_CONSTEXPR text_style operator|(emphasis lhs, emphasis rhs) FMT_NOEXCEPT { return text_style(lhs) | rhs; } -namespace internal { +namespace detail { template struct ansi_color_escape { - FMT_CONSTEXPR ansi_color_escape(internal::color_type text_color, + FMT_CONSTEXPR ansi_color_escape(detail::color_type text_color, const char* esc) FMT_NOEXCEPT { // If we have a terminal color, we need to output another escape code // sequence. if (!text_color.is_rgb) { - bool is_background = esc == internal::data::background_color; + bool is_background = esc == detail::data::background_color; uint32_t value = text_color.value.term_color; // Background ASCII codes are the same as the foreground ones but with // 10 more. @@ -429,14 +429,14 @@ template struct ansi_color_escape { template FMT_CONSTEXPR ansi_color_escape make_foreground_color( - internal::color_type foreground) FMT_NOEXCEPT { - return ansi_color_escape(foreground, internal::data::foreground_color); + detail::color_type foreground) FMT_NOEXCEPT { + return ansi_color_escape(foreground, detail::data::foreground_color); } template FMT_CONSTEXPR ansi_color_escape make_background_color( - internal::color_type background) FMT_NOEXCEPT { - return ansi_color_escape(background, internal::data::background_color); + detail::color_type background) FMT_NOEXCEPT { + return ansi_color_escape(background, detail::data::background_color); } template @@ -455,11 +455,11 @@ inline void fputs(const wchar_t* chars, FILE* stream) FMT_NOEXCEPT { } template inline void reset_color(FILE* stream) FMT_NOEXCEPT { - fputs(internal::data::reset_color, stream); + fputs(detail::data::reset_color, stream); } template <> inline void reset_color(FILE* stream) FMT_NOEXCEPT { - fputs(internal::data::wreset_color, stream); + fputs(detail::data::wreset_color, stream); } template @@ -476,33 +476,31 @@ void vformat_to(basic_memory_buffer& buf, const text_style& ts, bool has_style = false; if (ts.has_emphasis()) { has_style = true; - auto emphasis = internal::make_emphasis(ts.get_emphasis()); + auto emphasis = detail::make_emphasis(ts.get_emphasis()); buf.append(emphasis.begin(), emphasis.end()); } if (ts.has_foreground()) { has_style = true; - auto foreground = - internal::make_foreground_color(ts.get_foreground()); + auto foreground = detail::make_foreground_color(ts.get_foreground()); buf.append(foreground.begin(), foreground.end()); } if (ts.has_background()) { has_style = true; - auto background = - internal::make_background_color(ts.get_background()); + auto background = detail::make_background_color(ts.get_background()); buf.append(background.begin(), background.end()); } - internal::vformat_to(buf, format_str, args); - if (has_style) internal::reset_color(buf); + detail::vformat_to(buf, format_str, args); + if (has_style) detail::reset_color(buf); } -} // namespace internal +} // namespace detail template > void vprint(std::FILE* f, const text_style& ts, const S& format, basic_format_args> args) { basic_memory_buffer buf; - internal::vformat_to(buf, ts, to_string_view(format), args); + detail::vformat_to(buf, ts, to_string_view(format), args); buf.push_back(Char(0)); - internal::fputs(buf.data(), f); + detail::fputs(buf.data(), f); } /** @@ -513,10 +511,10 @@ void vprint(std::FILE* f, const text_style& ts, const S& format, "Elapsed time: {0:.2f} seconds", 1.23); */ template ::value)> + FMT_ENABLE_IF(detail::is_string::value)> void print(std::FILE* f, const text_style& ts, const S& format_str, const Args&... args) { - internal::check_format_string(format_str); + detail::check_format_string(format_str); using context = buffer_context>; format_arg_store as{args...}; vprint(f, ts, format_str, basic_format_args(as)); @@ -530,7 +528,7 @@ void print(std::FILE* f, const text_style& ts, const S& format_str, "Elapsed time: {0:.2f} seconds", 1.23); */ template ::value)> + FMT_ENABLE_IF(detail::is_string::value)> void print(const text_style& ts, const S& format_str, const Args&... args) { return print(stdout, ts, format_str, args...); } @@ -540,7 +538,7 @@ inline std::basic_string vformat( const text_style& ts, const S& format_str, basic_format_args>> args) { basic_memory_buffer buf; - internal::vformat_to(buf, ts, to_string_view(format_str), args); + detail::vformat_to(buf, ts, to_string_view(format_str), args); return fmt::to_string(buf); } @@ -560,7 +558,7 @@ template > inline std::basic_string format(const text_style& ts, const S& format_str, const Args&... args) { return vformat(ts, to_string_view(format_str), - internal::make_args_checked(format_str, args...)); + detail::make_args_checked(format_str, args...)); } FMT_END_NAMESPACE diff --git a/include/fmt/compile.h b/include/fmt/compile.h index 0cc18b90..35fe63f8 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -13,7 +13,7 @@ #include "format.h" FMT_BEGIN_NAMESPACE -namespace internal { +namespace detail { // Part of a compiled format string. It can be either literal text or a // replacement field. @@ -197,12 +197,12 @@ auto vformat_to(Range out, CompiledFormat& cf, basic_format_args args) case format_part_t::kind::arg_index: advance_to(parse_ctx, part.arg_id_end); - internal::format_arg(parse_ctx, ctx, value.arg_index); + detail::format_arg(parse_ctx, ctx, value.arg_index); break; case format_part_t::kind::arg_name: advance_to(parse_ctx, part.arg_id_end); - internal::format_arg(parse_ctx, ctx, value.str); + detail::format_arg(parse_ctx, ctx, value.str); break; case format_part_t::kind::replacement: { @@ -240,7 +240,7 @@ struct basic_compiled_format {}; template struct compiled_format_base : basic_compiled_format { using char_type = char_t; - using parts_container = std::vector>; + using parts_container = std::vector>; parts_container compiled_parts; @@ -305,7 +305,7 @@ struct compiled_format_base::value>> const parts_container& parts() const { static FMT_CONSTEXPR_DECL const auto compiled_parts = compile_to_parts( - internal::to_string_view(S())); + detail::to_string_view(S())); return compiled_parts.data; } }; @@ -383,7 +383,7 @@ OutputIt format_default(OutputIt out, T value) { template OutputIt format_default(OutputIt out, double value) { - return internal::write(out, value); + return detail::write(out, value); } template @@ -493,7 +493,7 @@ constexpr auto compile_format_string(S format_str) { } } #endif // __cpp_if_constexpr -} // namespace internal +} // namespace detail #if FMT_USE_CONSTEXPR # ifdef __cpp_if_constexpr @@ -502,14 +502,14 @@ template str = format_str; if constexpr (str.size() == 0) { - return internal::make_text(str, 0, 0); + return detail::make_text(str, 0, 0); } else { constexpr auto result = - internal::compile_format_string, 0, 0>( + detail::compile_format_string, 0, 0>( format_str); if constexpr (std::is_same, - internal::unknown_format>()) { - return internal::compiled_format(to_string_view(format_str)); + detail::unknown_format>()) { + return detail::compiled_format(to_string_view(format_str)); } else { return result; } @@ -518,7 +518,7 @@ constexpr auto compile(S format_str) { template ::value)> + FMT_ENABLE_IF(detail::is_compiled_format::value)> std::basic_string format(const CompiledFormat& cf, const Args&... args) { basic_memory_buffer buffer; cf.format(std::back_inserter(buffer), args...); @@ -526,7 +526,7 @@ std::basic_string format(const CompiledFormat& cf, const Args&... args) { } template ::value)> + FMT_ENABLE_IF(detail::is_compiled_format::value)> OutputIt format_to(OutputIt out, const CompiledFormat& cf, const Args&... args) { return cf.format(out, args...); @@ -534,8 +534,8 @@ OutputIt format_to(OutputIt out, const CompiledFormat& cf, # else template ::value)> -constexpr auto compile(S format_str) -> internal::compiled_format { - return internal::compiled_format(to_string_view(format_str)); +constexpr auto compile(S format_str) -> detail::compiled_format { + return detail::compiled_format(to_string_view(format_str)); } # endif // __cpp_if_constexpr #endif // FMT_USE_CONSTEXPR @@ -543,51 +543,51 @@ constexpr auto compile(S format_str) -> internal::compiled_format { // Compiles the format string which must be a string literal. template auto compile(const Char (&format_str)[N]) - -> internal::compiled_format { - return internal::compiled_format( + -> detail::compiled_format { + return detail::compiled_format( basic_string_view(format_str, N - 1)); } template ::value)> std::basic_string format(const CompiledFormat& cf, const Args&... args) { basic_memory_buffer buffer; using range = buffer_range; using context = buffer_context; - internal::cf::vformat_to(range(buffer), cf, - make_format_args(args...)); + detail::cf::vformat_to(range(buffer), cf, + make_format_args(args...)); return to_string(buffer); } template ::value)> OutputIt format_to(OutputIt out, const CompiledFormat& cf, const Args&... args) { using char_type = typename CompiledFormat::char_type; - using range = internal::output_range; + using range = detail::output_range; using context = format_context_t; - return internal::cf::vformat_to(range(out), cf, - make_format_args(args...)); + return detail::cf::vformat_to(range(out), cf, + make_format_args(args...)); } -template ::value&& std::is_base_of< - internal::basic_compiled_format, CompiledFormat>::value)> +template < + typename OutputIt, typename CompiledFormat, typename... Args, + FMT_ENABLE_IF(detail::is_output_iterator::value&& std::is_base_of< + detail::basic_compiled_format, CompiledFormat>::value)> format_to_n_result format_to_n(OutputIt out, size_t n, const CompiledFormat& cf, const Args&... args) { auto it = - format_to(internal::truncating_iterator(out, n), cf, args...); + format_to(detail::truncating_iterator(out, n), cf, args...); return {it.base(), it.count()}; } template size_t formatted_size(const CompiledFormat& cf, const Args&... args) { - return format_to(internal::counting_iterator(), cf, args...).count(); + return format_to(detail::counting_iterator(), cf, args...).count(); } FMT_END_NAMESPACE diff --git a/include/fmt/core.h b/include/fmt/core.h index a892f75e..edaacd35 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -272,7 +272,7 @@ struct monostate {}; // to workaround a bug in MSVC 2019 (see #1140 and #1186). #define FMT_ENABLE_IF(...) enable_if_t<(__VA_ARGS__), int> = 0 -namespace internal { +namespace detail { // A helper function to suppress bogus "conditional expression is constant" // warnings. @@ -292,7 +292,7 @@ FMT_NORETURN FMT_API void assert_fail(const char* file, int line, # define FMT_ASSERT(condition, message) \ ((condition) /* void() fails with -Winvalid-constexpr on clang 4.0.1 */ \ ? (void)0 \ - : ::fmt::internal::assert_fail(__FILE__, __LINE__, (message))) + : ::fmt::detail::assert_fail(__FILE__, __LINE__, (message))) # endif #endif @@ -338,10 +338,12 @@ using char8_type = char8_t; #else enum char8_type : unsigned char {}; #endif -} // namespace internal +} // namespace detail + +namespace internal = detail; // DEPRECATED template -using void_t = typename internal::void_t_impl::type; +using void_t = typename detail::void_t_impl::type; /** An implementation of ``std::basic_string_view`` for pre-C++17. It provides a @@ -385,9 +387,8 @@ template class basic_string_view { : data_(s.data()), size_(s.size()) {} - template < - typename S, - FMT_ENABLE_IF(std::is_same>::value)> + template >::value)> FMT_CONSTEXPR basic_string_view(S s) FMT_NOEXCEPT : data_(s.data()), size_(s.size()) {} @@ -443,7 +444,7 @@ using wstring_view = basic_string_view; template struct is_char : std::false_type {}; template <> struct is_char : std::true_type {}; template <> struct is_char : std::true_type {}; -template <> struct is_char : std::true_type {}; +template <> struct is_char : std::true_type {}; template <> struct is_char : std::true_type {}; template <> struct is_char : std::true_type {}; @@ -480,9 +481,8 @@ inline basic_string_view to_string_view(basic_string_view s) { } template >::value)> -inline basic_string_view to_string_view( - internal::std_string_view s) { + FMT_ENABLE_IF(!std::is_empty>::value)> +inline basic_string_view to_string_view(detail::std_string_view s) { return s; } @@ -498,7 +498,7 @@ constexpr basic_string_view to_string_view(const S& s) { return s; } -namespace internal { +namespace detail { void to_string_view(...); using fmt::v6::to_string_view; @@ -522,10 +522,10 @@ struct error_handler { // This function is intentionally not constexpr to give a compile-time error. FMT_NORETURN FMT_API void on_error(const char* message); }; -} // namespace internal +} // namespace detail /** String's character type. */ -template using char_t = typename internal::char_t_impl::type; +template using char_t = typename detail::char_t_impl::type; /** \rst @@ -543,7 +543,7 @@ template using char_t = typename internal::char_t_impl::type; +-----------------------+-------------------------------------+ \endrst */ -template +template class basic_format_parse_context : private ErrorHandler { private: basic_string_view format_str_; @@ -570,7 +570,7 @@ class basic_format_parse_context : private ErrorHandler { /** Advances the begin iterator to ``it``. */ FMT_CONSTEXPR void advance_to(iterator it) { - format_str_.remove_prefix(internal::to_unsigned(it - begin())); + format_str_.remove_prefix(detail::to_unsigned(it - begin())); } /** @@ -625,7 +625,7 @@ template using has_formatter = std::is_constructible>; -namespace internal { +namespace detail { /** A contiguous memory buffer with an optional growing ability. */ template class buffer { @@ -749,8 +749,7 @@ using has_fallback_formatter = struct view {}; -template -struct named_arg : view { +template struct named_arg : view { const Char* name; const T& value; named_arg(const Char* n, const T& v) : name(n), value(v) {} @@ -1094,17 +1093,17 @@ enum { packed_arg_bits = 4 }; enum { max_packed_args = 62 / packed_arg_bits }; enum : unsigned long long { is_unpacked_bit = 1ULL << 63 }; enum : unsigned long long { has_named_args_bit = 1ULL << 62 }; -} // namespace internal +} // namespace detail // A formatting argument. It is a trivially copyable/constructible type to // allow storage in basic_memory_buffer. template class basic_format_arg { private: - internal::value value_; - internal::type type_; + detail::value value_; + detail::type type_; template - friend FMT_CONSTEXPR basic_format_arg internal::make_arg( + friend FMT_CONSTEXPR basic_format_arg detail::make_arg( const T& value); template @@ -1118,15 +1117,15 @@ template class basic_format_arg { using char_type = typename Context::char_type; template - friend struct internal::arg_data; + friend struct detail::arg_data; - basic_format_arg(const internal::named_arg_info* args, size_t size) + basic_format_arg(const detail::named_arg_info* args, size_t size) : value_(args, size) {} public: class handle { public: - explicit handle(internal::custom_value custom) : custom_(custom) {} + explicit handle(detail::custom_value custom) : custom_(custom) {} void format(typename Context::parse_context_type& parse_ctx, Context& ctx) const { @@ -1134,19 +1133,19 @@ template class basic_format_arg { } private: - internal::custom_value custom_; + detail::custom_value custom_; }; - constexpr basic_format_arg() : type_(internal::type::none_type) {} + constexpr basic_format_arg() : type_(detail::type::none_type) {} constexpr explicit operator bool() const FMT_NOEXCEPT { - return type_ != internal::type::none_type; + return type_ != detail::type::none_type; } - internal::type type() const { return type_; } + detail::type type() const { return type_; } - bool is_integral() const { return internal::is_integral_type(type_); } - bool is_arithmetic() const { return internal::is_arithmetic_type(type_); } + bool is_integral() const { return detail::is_integral_type(type_); } + bool is_arithmetic() const { return detail::is_arithmetic_type(type_); } }; /** @@ -1162,50 +1161,50 @@ FMT_CONSTEXPR auto visit_format_arg(Visitor&& vis, -> decltype(vis(0)) { using char_type = typename Context::char_type; switch (arg.type_) { - case internal::type::none_type: + case detail::type::none_type: break; - case internal::type::int_type: + case detail::type::int_type: return vis(arg.value_.int_value); - case internal::type::uint_type: + case detail::type::uint_type: return vis(arg.value_.uint_value); - case internal::type::long_long_type: + case detail::type::long_long_type: return vis(arg.value_.long_long_value); - case internal::type::ulong_long_type: + case detail::type::ulong_long_type: return vis(arg.value_.ulong_long_value); #if FMT_USE_INT128 - case internal::type::int128_type: + case detail::type::int128_type: return vis(arg.value_.int128_value); - case internal::type::uint128_type: + case detail::type::uint128_type: return vis(arg.value_.uint128_value); #else - case internal::type::int128_type: - case internal::type::uint128_type: + case detail::type::int128_type: + case detail::type::uint128_type: break; #endif - case internal::type::bool_type: + case detail::type::bool_type: return vis(arg.value_.bool_value); - case internal::type::char_type: + case detail::type::char_type: return vis(arg.value_.char_value); - case internal::type::float_type: + case detail::type::float_type: return vis(arg.value_.float_value); - case internal::type::double_type: + case detail::type::double_type: return vis(arg.value_.double_value); - case internal::type::long_double_type: + case detail::type::long_double_type: return vis(arg.value_.long_double_value); - case internal::type::cstring_type: + case detail::type::cstring_type: return vis(arg.value_.string.data); - case internal::type::string_type: + case detail::type::string_type: return vis(basic_string_view(arg.value_.string.data, arg.value_.string.size)); - case internal::type::pointer_type: + case detail::type::pointer_type: return vis(arg.value_.pointer); - case internal::type::custom_type: + case detail::type::custom_type: return vis(typename basic_format_arg::handle(arg.value_.custom)); } return vis(monostate()); } -namespace internal { +namespace detail { // A type-erased reference to an std::locale to avoid heavy include. class locale_ref { private: @@ -1291,7 +1290,7 @@ class dynamic_arg_list { return value; } }; -} // namespace internal +} // namespace detail // Formatting context. template class basic_format_context { @@ -1302,7 +1301,7 @@ template class basic_format_context { private: OutputIt out_; basic_format_args args_; - internal::locale_ref loc_; + detail::locale_ref loc_; public: using iterator = OutputIt; @@ -1318,7 +1317,7 @@ template class basic_format_context { */ basic_format_context(OutputIt out, basic_format_args ctx_args, - internal::locale_ref loc = internal::locale_ref()) + detail::locale_ref loc = detail::locale_ref()) : out_(out), args_(ctx_args), loc_(loc) {} format_arg arg(int id) const { return args_.get(id); } @@ -1327,7 +1326,7 @@ template class basic_format_context { // specified name. format_arg arg(basic_string_view name) { return args_.get(name); } - internal::error_handler error_handler() { return {}; } + detail::error_handler error_handler() { return {}; } void on_error(const char* message) { error_handler().on_error(message); } // Returns an iterator to the beginning of the output range. @@ -1336,13 +1335,12 @@ template class basic_format_context { // Advances the begin iterator to ``it``. void advance_to(iterator it) { out_ = it; } - internal::locale_ref locale() { return loc_; } + detail::locale_ref locale() { return loc_; } }; template using buffer_context = - basic_format_context>, - Char>; + basic_format_context>, Char>; using format_context = buffer_context; using wformat_context = buffer_context; @@ -1362,23 +1360,23 @@ class format_arg_store { private: static const size_t num_args = sizeof...(Args); - static const size_t num_named_args = internal::count_named_args(); - static const bool is_packed = num_args <= internal::max_packed_args; + static const size_t num_named_args = detail::count_named_args(); + static const bool is_packed = num_args <= detail::max_packed_args; - using value_type = conditional_t, + using value_type = conditional_t, basic_format_arg>; - internal::arg_data + detail::arg_data data_; friend class basic_format_args; static constexpr unsigned long long desc = - (is_packed ? internal::encode_types() - : internal::is_unpacked_bit | num_args) | + (is_packed ? detail::encode_types() + : detail::is_unpacked_bit | num_args) | (num_named_args != 0 - ? static_cast(internal::has_named_args_bit) + ? static_cast(detail::has_named_args_bit) : 0); public: @@ -1387,10 +1385,10 @@ class format_arg_store #if FMT_GCC_VERSION && FMT_GCC_VERSION < 409 basic_format_args(*this), #endif - data_{internal::make_arg< + data_{detail::make_arg< is_packed, Context, - internal::mapped_type_constant::value>(args)...} { - internal::init_named_args(data_.named_args(), 0, 0, args...); + detail::mapped_type_constant::value>(args)...} { + detail::init_named_args(data_.named_args(), 0, 0, args...); } }; @@ -1419,8 +1417,8 @@ inline format_arg_store make_format_args( \endrst */ template -inline internal::named_arg arg(const Char* name, const T& arg) { - static_assert(!internal::is_named_arg(), "nested named arguments"); +inline detail::named_arg arg(const Char* name, const T& arg) { + static_assert(!detail::is_named_arg(), "nested named arguments"); return {name, arg}; } @@ -1445,38 +1443,38 @@ class dynamic_format_arg_store using char_type = typename Context::char_type; template struct need_copy { - static constexpr internal::type mapped_type = - internal::mapped_type_constant::value; + static constexpr detail::type mapped_type = + detail::mapped_type_constant::value; enum { - value = !(internal::is_reference_wrapper::value || + value = !(detail::is_reference_wrapper::value || std::is_same>::value || - std::is_same>::value || - (mapped_type != internal::type::cstring_type && - mapped_type != internal::type::string_type && - mapped_type != internal::type::custom_type)) + std::is_same>::value || + (mapped_type != detail::type::cstring_type && + mapped_type != detail::type::string_type && + mapped_type != detail::type::custom_type)) }; }; template - using stored_type = conditional_t::value, + using stored_type = conditional_t::value, std::basic_string, T>; // Storage of basic_format_arg must be contiguous. std::vector> data_; - std::vector> named_info_; + std::vector> named_info_; // Storage of arguments not fitting into basic_format_arg must grow // without relocation because items in data_ refer to it. - internal::dynamic_arg_list dynamic_args_; + detail::dynamic_arg_list dynamic_args_; friend class basic_format_args; unsigned long long get_types() const { - return internal::is_unpacked_bit | data_.size() | - (named_info_.empty() ? 0ULL - : static_cast( - internal::has_named_args_bit)); + return detail::is_unpacked_bit | data_.size() | + (named_info_.empty() + ? 0ULL + : static_cast(detail::has_named_args_bit)); } const basic_format_arg* data() const { @@ -1484,17 +1482,16 @@ class dynamic_format_arg_store } template void emplace_arg(const T& arg) { - data_.emplace_back(internal::make_arg(arg)); + data_.emplace_back(detail::make_arg(arg)); } template - void emplace_arg(const internal::named_arg& arg) { + void emplace_arg(const detail::named_arg& arg) { if (named_info_.empty()) { - constexpr const internal::named_arg_info* zero_ptr{nullptr}; + constexpr const detail::named_arg_info* zero_ptr{nullptr}; data_.insert(data_.begin(), {zero_ptr, 0}); } - data_.emplace_back( - internal::make_arg(internal::unwrap(arg.value))); + data_.emplace_back(detail::make_arg(detail::unwrap(arg.value))); auto pop_one = [](std::vector>* data) { data->pop_back(); }; @@ -1524,10 +1521,10 @@ class dynamic_format_arg_store \endrst */ template void push_back(const T& arg) { - if (internal::const_check(need_copy::value)) + if (detail::const_check(need_copy::value)) emplace_arg(dynamic_args_.push>(arg)); else - emplace_arg(internal::unwrap(arg)); + emplace_arg(detail::unwrap(arg)); } /** @@ -1553,7 +1550,7 @@ class dynamic_format_arg_store */ template void push_back(std::reference_wrapper arg) { static_assert( - internal::is_named_arg::type>::value || + detail::is_named_arg::type>::value || need_copy::value, "objects of built-in types and string views are always copied"); emplace_arg(arg.get()); @@ -1565,10 +1562,10 @@ class dynamic_format_arg_store argument. */ template - void push_back(const internal::named_arg& arg) { + void push_back(const detail::named_arg& arg) { const char_type* arg_name = dynamic_args_.push>(arg.name).c_str(); - if (internal::const_check(need_copy::value)) { + if (detail::const_check(need_copy::value)) { emplace_arg( fmt::arg(arg_name, dynamic_args_.push>(arg.value))); } else { @@ -1604,23 +1601,23 @@ template class basic_format_args { // locality and reduce compiled code size since storing larger objects // may require more code (at least on x86-64) even if the same amount of // data is actually copied to stack. It saves ~10% on the bloat test. - const internal::value* values_; + const detail::value* values_; const format_arg* args_; }; - bool is_packed() const { return (desc_ & internal::is_unpacked_bit) == 0; } + bool is_packed() const { return (desc_ & detail::is_unpacked_bit) == 0; } bool has_named_args() const { - return (desc_ & internal::has_named_args_bit) != 0; + return (desc_ & detail::has_named_args_bit) != 0; } - internal::type type(int index) const { - int shift = index * internal::packed_arg_bits; - unsigned int mask = (1 << internal::packed_arg_bits) - 1; - return static_cast((desc_ >> shift) & mask); + detail::type type(int index) const { + int shift = index * detail::packed_arg_bits; + unsigned int mask = (1 << detail::packed_arg_bits) - 1; + return static_cast((desc_ >> shift) & mask); } basic_format_args(unsigned long long desc, - const internal::value* values) + const detail::value* values) : desc_(desc), values_(values) {} basic_format_args(unsigned long long desc, const format_arg* args) : desc_(desc), args_(args) {} @@ -1652,8 +1649,8 @@ template class basic_format_args { \endrst */ basic_format_args(const format_arg* args, int count) - : basic_format_args( - internal::is_unpacked_bit | internal::to_unsigned(count), args) {} + : basic_format_args(detail::is_unpacked_bit | detail::to_unsigned(count), + args) {} /** Returns the argument with the specified id. */ format_arg get(int id) const { @@ -1662,9 +1659,9 @@ template class basic_format_args { if (id < max_size()) arg = args_[id]; return arg; } - if (id >= internal::max_packed_args) return arg; + if (id >= detail::max_packed_args) return arg; arg.type_ = type(id); - if (arg.type_ == internal::type::none_type) return arg; + if (arg.type_ == detail::type::none_type) return arg; arg.value_ = values_[id]; return arg; } @@ -1680,9 +1677,9 @@ template class basic_format_args { } int max_size() const { - unsigned long long max_packed = internal::max_packed_args; + unsigned long long max_packed = detail::max_packed_args; return static_cast(is_packed() ? max_packed - : desc_ & ~internal::is_unpacked_bit); + : desc_ & ~detail::is_unpacked_bit); } }; @@ -1702,9 +1699,9 @@ template struct is_contiguous> : std::true_type {}; template -struct is_contiguous> : std::true_type {}; +struct is_contiguous> : std::true_type {}; -namespace internal { +namespace detail { template struct is_contiguous_back_insert_iterator : std::false_type {}; @@ -1753,38 +1750,38 @@ FMT_API void vprint_mojibake(std::FILE*, string_view, format_args); #ifndef _WIN32 inline void vprint_mojibake(std::FILE*, string_view, format_args) {} #endif -} // namespace internal +} // namespace detail /** Formats a string and writes the output to ``out``. */ // GCC 8 and earlier cannot handle std::back_insert_iterator with // vformat_to(...) overload, so SFINAE on iterator type instead. -template , - FMT_ENABLE_IF( - internal::is_contiguous_back_insert_iterator::value)> +template < + typename OutputIt, typename S, typename Char = char_t, + FMT_ENABLE_IF(detail::is_contiguous_back_insert_iterator::value)> OutputIt vformat_to( OutputIt out, const S& format_str, basic_format_args>> args) { - auto& c = internal::get_container(out); - internal::container_buffer> buf(c); - internal::vformat_to(buf, to_string_view(format_str), args); + auto& c = detail::get_container(out); + detail::container_buffer> buf(c); + detail::vformat_to(buf, to_string_view(format_str), args); return out; } template ::value&& internal::is_string::value)> + is_contiguous::value&& detail::is_string::value)> inline std::back_insert_iterator format_to( std::back_insert_iterator out, const S& format_str, Args&&... args) { return vformat_to(out, to_string_view(format_str), - internal::make_args_checked(format_str, args...)); + detail::make_args_checked(format_str, args...)); } template > FMT_INLINE std::basic_string vformat( const S& format_str, basic_format_args>> args) { - return internal::vformat(to_string_view(format_str), args); + return detail::vformat(to_string_view(format_str), args); } /** @@ -1801,8 +1798,8 @@ FMT_INLINE std::basic_string vformat( // std::basic_string> to reduce the symbol size. template > FMT_INLINE std::basic_string format(const S& format_str, Args&&... args) { - const auto& vargs = internal::make_args_checked(format_str, args...); - return internal::vformat(to_string_view(format_str), vargs); + const auto& vargs = detail::make_args_checked(format_str, args...); + return detail::vformat(to_string_view(format_str), vargs); } FMT_API void vprint(string_view, format_args); @@ -1821,10 +1818,10 @@ FMT_API void vprint(std::FILE*, string_view, format_args); */ template > inline void print(std::FILE* f, const S& format_str, Args&&... args) { - const auto& vargs = internal::make_args_checked(format_str, args...); - return internal::is_unicode() + const auto& vargs = detail::make_args_checked(format_str, args...); + return detail::is_unicode() ? vprint(f, to_string_view(format_str), vargs) - : internal::vprint_mojibake(f, to_string_view(format_str), vargs); + : detail::vprint_mojibake(f, to_string_view(format_str), vargs); } /** @@ -1840,11 +1837,11 @@ inline void print(std::FILE* f, const S& format_str, Args&&... args) { */ template > inline void print(const S& format_str, Args&&... args) { - const auto& vargs = internal::make_args_checked(format_str, args...); - return internal::is_unicode() + const auto& vargs = detail::make_args_checked(format_str, args...); + return detail::is_unicode() ? vprint(to_string_view(format_str), vargs) - : internal::vprint_mojibake(stdout, to_string_view(format_str), - vargs); + : detail::vprint_mojibake(stdout, to_string_view(format_str), + vargs); } FMT_END_NAMESPACE diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index e78bf067..f25b3767 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -40,11 +40,11 @@ // Dummy implementations of strerror_r and strerror_s called if corresponding // system functions are not available. -inline fmt::internal::null<> strerror_r(int, char*, ...) { return {}; } -inline fmt::internal::null<> strerror_s(char*, size_t, ...) { return {}; } +inline fmt::detail::null<> strerror_r(int, char*, ...) { return {}; } +inline fmt::detail::null<> strerror_s(char*, size_t, ...) { return {}; } FMT_BEGIN_NAMESPACE -namespace internal { +namespace detail { FMT_FUNC void assert_fail(const char* file, int line, const char* message) { print(stderr, "{}:{}: assertion failed: {}", file, line, message); @@ -106,7 +106,7 @@ FMT_FUNC int safe_strerror(int error_code, char*& buffer, // Handle the case when strerror_r is not available. FMT_MAYBE_UNUSED - int handle(internal::null<>) { + int handle(detail::null<>) { return fallback(strerror_s(buffer_, buffer_size_, error_code_)); } @@ -120,7 +120,7 @@ FMT_FUNC int safe_strerror(int error_code, char*& buffer, #if !FMT_MSC_VER // Fallback to strerror if strerror_r and strerror_s are not available. - int fallback(internal::null<>) { + int fallback(detail::null<>) { errno = 0; buffer_ = strerror(error_code_); return errno; @@ -136,7 +136,7 @@ FMT_FUNC int safe_strerror(int error_code, char*& buffer, return dispatcher(error_code, buffer, buffer_size).run(); } -FMT_FUNC void format_error_code(internal::buffer& out, int error_code, +FMT_FUNC void format_error_code(detail::buffer& out, int error_code, string_view message) FMT_NOEXCEPT { // Report error code making sure that the output fits into // inline_buffer_size to avoid dynamic memory allocation and potential @@ -147,11 +147,11 @@ FMT_FUNC void format_error_code(internal::buffer& out, int error_code, // Subtract 2 to account for terminating null characters in SEP and ERROR_STR. size_t error_code_size = sizeof(SEP) + sizeof(ERROR_STR) - 2; auto abs_value = static_cast>(error_code); - if (internal::is_negative(error_code)) { + if (detail::is_negative(error_code)) { abs_value = 0 - abs_value; ++error_code_size; } - error_code_size += internal::to_unsigned(internal::count_digits(abs_value)); + error_code_size += detail::to_unsigned(detail::count_digits(abs_value)); auto it = std::back_inserter(out); if (message.size() <= inline_buffer_size - error_code_size) format_to(it, "{}{}", message, SEP); @@ -174,10 +174,10 @@ FMT_FUNC void fwrite_fully(const void* ptr, size_t size, size_t count, size_t written = std::fwrite(ptr, size, count, stream); if (written < count) FMT_THROW(system_error(errno, "cannot write to file")); } -} // namespace internal +} // namespace detail #if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) -namespace internal { +namespace detail { template locale_ref::locale_ref(const Locale& loc) : locale_(&loc) { @@ -200,18 +200,16 @@ template FMT_FUNC Char decimal_point_impl(locale_ref loc) { return std::use_facet>(loc.get()) .decimal_point(); } -} // namespace internal +} // namespace detail #else template -FMT_FUNC std::string internal::grouping_impl(locale_ref) { +FMT_FUNC std::string detail::grouping_impl(locale_ref) { return "\03"; } -template -FMT_FUNC Char internal::thousands_sep_impl(locale_ref) { +template FMT_FUNC Char detail::thousands_sep_impl(locale_ref) { return FMT_STATIC_THOUSANDS_SEPARATOR; } -template -FMT_FUNC Char internal::decimal_point_impl(locale_ref) { +template FMT_FUNC Char detail::decimal_point_impl(locale_ref) { return '.'; } #endif @@ -228,9 +226,9 @@ FMT_FUNC void system_error::init(int err_code, string_view format_str, base = std::runtime_error(to_string(buffer)); } -namespace internal { +namespace detail { -template <> FMT_FUNC int count_digits<4>(internal::fallback_uintptr n) { +template <> FMT_FUNC int count_digits<4>(detail::fallback_uintptr n) { // fallback_uintptr is always stored in little endian. int i = static_cast(sizeof(void*)) - 1; while (i > 0 && n.value[i] == 0) --i; @@ -1278,14 +1276,14 @@ FMT_FUNC const char* utf8_decode(const char* buf, uint32_t* c, int* e) { return next; } -} // namespace internal +} // namespace detail -template <> struct formatter { +template <> struct formatter { format_parse_context::iterator parse(format_parse_context& ctx) { return ctx.begin(); } - format_context::iterator format(const internal::bigint& n, + format_context::iterator format(const detail::bigint& n, format_context& ctx) { auto out = ctx.out(); bool first = true; @@ -1299,12 +1297,12 @@ template <> struct formatter { out = format_to(out, "{:08x}", value); } if (n.exp_ > 0) - out = format_to(out, "p{}", n.exp_ * internal::bigint::bigit_bits); + out = format_to(out, "p{}", n.exp_ * detail::bigint::bigit_bits); return out; } }; -FMT_FUNC internal::utf8_to_utf16::utf8_to_utf16(string_view s) { +FMT_FUNC detail::utf8_to_utf16::utf8_to_utf16(string_view s) { auto transcode = [this](const char* p) { auto cp = uint32_t(); auto error = 0; @@ -1335,7 +1333,7 @@ FMT_FUNC internal::utf8_to_utf16::utf8_to_utf16(string_view s) { buffer_.push_back(0); } -FMT_FUNC void format_system_error(internal::buffer& out, int error_code, +FMT_FUNC void format_system_error(detail::buffer& out, int error_code, string_view message) FMT_NOEXCEPT { FMT_TRY { memory_buffer buf; @@ -1343,7 +1341,7 @@ FMT_FUNC void format_system_error(internal::buffer& out, int error_code, for (;;) { char* system_message = &buf[0]; int result = - internal::safe_strerror(error_code, system_message, buf.size()); + detail::safe_strerror(error_code, system_message, buf.size()); if (result == 0) { format_to(std::back_inserter(out), "{}: {}", message, system_message); return; @@ -1357,7 +1355,7 @@ FMT_FUNC void format_system_error(internal::buffer& out, int error_code, format_error_code(out, error_code, message); } -FMT_FUNC void internal::error_handler::on_error(const char* message) { +FMT_FUNC void detail::error_handler::on_error(const char* message) { FMT_THROW(format_error(message)); } @@ -1368,12 +1366,12 @@ FMT_FUNC void report_system_error(int error_code, FMT_FUNC void vprint(std::FILE* f, string_view format_str, format_args args) { memory_buffer buffer; - internal::vformat_to(buffer, format_str, - basic_format_args>(args)); + detail::vformat_to(buffer, format_str, + basic_format_args>(args)); #ifdef _WIN32 auto fd = _fileno(f); if (_isatty(fd)) { - internal::utf8_to_utf16 u16(string_view(buffer.data(), buffer.size())); + detail::utf8_to_utf16 u16(string_view(buffer.data(), buffer.size())); auto written = DWORD(); if (!WriteConsoleW(reinterpret_cast(_get_osfhandle(fd)), u16.c_str(), static_cast(u16.size()), &written, @@ -1383,16 +1381,16 @@ FMT_FUNC void vprint(std::FILE* f, string_view format_str, format_args args) { return; } #endif - internal::fwrite_fully(buffer.data(), 1, buffer.size(), f); + detail::fwrite_fully(buffer.data(), 1, buffer.size(), f); } #ifdef _WIN32 // Print assuming legacy (non-Unicode) encoding. -FMT_FUNC void internal::vprint_mojibake(std::FILE* f, string_view format_str, - format_args args) { +FMT_FUNC void detail::vprint_mojibake(std::FILE* f, string_view format_str, + format_args args) { memory_buffer buffer; - internal::vformat_to(buffer, format_str, - basic_format_args>(args)); + detail::vformat_to(buffer, format_str, + basic_format_args>(args)); fwrite_fully(buffer.data(), 1, buffer.size(), f); } #endif diff --git a/include/fmt/format.h b/include/fmt/format.h index b2d1c02c..873e98bd 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -96,16 +96,16 @@ # if FMT_EXCEPTIONS # if FMT_MSC_VER || FMT_NVCC FMT_BEGIN_NAMESPACE -namespace internal { +namespace detail { template inline void do_throw(const Exception& x) { // Silence unreachable code warnings in MSVC and NVCC because these // are nearly impossible to fix in a generic code. volatile bool b = true; if (b) throw x; } -} // namespace internal +} // namespace detail FMT_END_NAMESPACE -# define FMT_THROW(x) internal::do_throw(x) +# define FMT_THROW(x) detail::do_throw(x) # else # define FMT_THROW(x) throw x # endif @@ -179,7 +179,7 @@ FMT_END_NAMESPACE # include // _BitScanReverse, _BitScanReverse64 FMT_BEGIN_NAMESPACE -namespace internal { +namespace detail { // Avoid Clang with Microsoft CodeGen's -Wunknown-pragmas warning. # ifndef __clang__ # pragma intrinsic(_BitScanReverse) @@ -195,7 +195,7 @@ inline uint32_t clz(uint32_t x) { FMT_SUPPRESS_MSC_WARNING(6102) return 31 - r; } -# define FMT_BUILTIN_CLZ(n) internal::clz(n) +# define FMT_BUILTIN_CLZ(n) detail::clz(n) # if defined(_WIN64) && !defined(__clang__) # pragma intrinsic(_BitScanReverse64) @@ -220,8 +220,8 @@ inline uint32_t clzll(uint64_t x) { FMT_SUPPRESS_MSC_WARNING(6102) return 63 - r; } -# define FMT_BUILTIN_CLZLL(n) internal::clzll(n) -} // namespace internal +# define FMT_BUILTIN_CLZLL(n) detail::clzll(n) +} // namespace detail FMT_END_NAMESPACE #endif @@ -231,7 +231,7 @@ FMT_END_NAMESPACE #endif FMT_BEGIN_NAMESPACE -namespace internal { +namespace detail { // An equivalent of `*reinterpret_cast(&source)` that doesn't have // undefined behavior (e.g. due to type aliasing). @@ -572,17 +572,18 @@ void buffer::append(const U* begin, const U* end) { std::uninitialized_copy(begin, end, make_checked(ptr_, capacity_) + size_); size_ = new_size; } -} // namespace internal +} // namespace detail // A range with an iterator appending to a buffer. template -class buffer_range : public internal::output_range< - std::back_insert_iterator>, T> { +class buffer_range + : public detail::output_range>, + T> { public: - using iterator = std::back_insert_iterator>; - using internal::output_range::output_range; - buffer_range(internal::buffer& buf) - : internal::output_range(std::back_inserter(buf)) {} + using iterator = std::back_insert_iterator>; + using detail::output_range::output_range; + buffer_range(detail::buffer& buf) + : detail::output_range(std::back_inserter(buf)) {} }; // The number of characters to store in the basic_memory_buffer object itself @@ -620,7 +621,7 @@ enum { inline_buffer_size = 500 }; */ template > -class basic_memory_buffer : public internal::buffer { +class basic_memory_buffer : public detail::buffer { private: T store_[SIZE]; @@ -655,7 +656,7 @@ class basic_memory_buffer : public internal::buffer { if (data == other.store_) { this->set(store_, capacity); std::uninitialized_copy(other.store_, other.store_ + size, - internal::make_checked(store_, capacity)); + detail::make_checked(store_, capacity)); } else { this->set(data, capacity); // Set pointer to the inline array so that delete is not called @@ -703,7 +704,7 @@ void basic_memory_buffer::grow(size_t size) { std::allocator_traits::allocate(alloc_, new_capacity); // The following code doesn't throw, so the raw pointer above doesn't leak. std::uninitialized_copy(old_data, old_data + this->size(), - internal::make_checked(new_data, new_capacity)); + detail::make_checked(new_data, new_capacity)); this->set(new_data, new_capacity); // deallocate must not throw according to the standard, but even if it does, // the buffer already uses the new storage and will deallocate it in @@ -728,7 +729,7 @@ class FMT_API format_error : public std::runtime_error { ~format_error() FMT_NOEXCEPT FMT_OVERRIDE; }; -namespace internal { +namespace detail { // Returns true if value is negative, false otherwise. // Same as `value < 0` but doesn't produce warnings if T is an unsigned type. @@ -831,7 +832,7 @@ template inline int count_digits(UInt n) { return num_digits; } -template <> int count_digits<4>(internal::fallback_uintptr n); +template <> int count_digits<4>(detail::fallback_uintptr n); #if FMT_GCC_VERSION || FMT_CLANG_VERSION # define FMT_ALWAYS_INLINE inline __attribute__((always_inline)) @@ -916,7 +917,7 @@ inline Iterator format_decimal(Iterator out, UInt value, int num_digits, enum { max_size = digits10() + 1 }; Char buffer[2 * max_size]; auto end = format_decimal(buffer, value, num_digits, add_thousands_sep); - return internal::copy_str(buffer, end, out); + return detail::copy_str(buffer, end, out); } template @@ -939,7 +940,7 @@ inline Char* format_uint(Char* buffer, UInt value, int num_digits, } template -Char* format_uint(Char* buffer, internal::fallback_uintptr n, int num_digits, +Char* format_uint(Char* buffer, detail::fallback_uintptr n, int num_digits, bool = false) { auto char_digits = std::numeric_limits::digits / 4; int start = (num_digits + char_digits - 1) / char_digits - 1; @@ -965,7 +966,7 @@ inline It format_uint(It out, UInt value, int num_digits, bool upper = false) { // Buffer should be large enough to hold all digits (digits / BASE_BITS + 1). char buffer[num_bits() / BASE_BITS + 1]; format_uint(buffer, value, num_digits, upper); - return internal::copy_str(buffer, buffer + num_digits, out); + return detail::copy_str(buffer, buffer + num_digits, out); } // A converter from UTF-8 to UTF-16. @@ -1016,7 +1017,7 @@ template struct fill_t { return fill; } }; -} // namespace internal +} // namespace detail // We cannot use enum classes as bit fields because of a gcc bug // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61414. @@ -1038,7 +1039,7 @@ template struct basic_format_specs { align_t align : 4; sign_t sign : 3; bool alt : 1; // Alternate form ('#'). - internal::fill_t fill; + detail::fill_t fill; constexpr basic_format_specs() : width(0), @@ -1047,12 +1048,12 @@ template struct basic_format_specs { align(align::none), sign(sign::none), alt(false), - fill(internal::fill_t::make()) {} + fill(detail::fill_t::make()) {} }; using format_specs = basic_format_specs; -namespace internal { +namespace detail { // A floating-point presentation format. enum class float_format : unsigned char { @@ -1675,7 +1676,7 @@ template struct is_integral : std::is_integral {}; template <> struct is_integral : std::true_type {}; template <> struct is_integral : std::true_type {}; -template +template class arg_formatter_base { public: using char_type = typename Range::value_type; @@ -1689,12 +1690,12 @@ class arg_formatter_base { // Attempts to reserve space for n extra characters in the output range. // Returns a pointer to the reserved range or a reference to out_. - auto reserve(size_t n) -> decltype(internal::reserve(out_, n)) { - return internal::reserve(out_, n); + auto reserve(size_t n) -> decltype(detail::reserve(out_, n)) { + return detail::reserve(out_, n); } using reserve_iterator = remove_reference_t(), 0))>; + detail::reserve(std::declval(), 0))>; struct char_writer { char_type value; @@ -1779,11 +1780,11 @@ class arg_formatter_base { template void write(basic_string_view s, const format_specs& specs = {}) { - out_ = internal::write(out_, s, specs); + out_ = detail::write(out_, s, specs); } void write_pointer(const void* p) { - out_ = write_ptr(out_, internal::to_uintptr(p), specs_); + out_ = write_ptr(out_, detail::to_uintptr(p), specs_); } protected: @@ -1824,7 +1825,7 @@ class arg_formatter_base { } iterator operator()(char_type value) { - internal::handle_char_specs( + detail::handle_char_specs( specs_, char_spec_handler(*this, static_cast(value))); return out(); } @@ -1839,7 +1840,7 @@ class arg_formatter_base { iterator operator()(T value) { auto specs = specs_ ? *specs_ : format_specs(); if (const_check(is_supported_floating_point(value))) - out_ = internal::write(out_, value, specs, locale_); + out_ = detail::write(out_, value, specs, locale_); else FMT_ASSERT(false, "unsupported float argument type"); return out(); @@ -1861,7 +1862,7 @@ class arg_formatter_base { void on_char() { formatter.write_char(value); } }; - struct cstring_spec_handler : internal::error_handler { + struct cstring_spec_handler : detail::error_handler { arg_formatter_base& formatter; const char_type* value; @@ -1874,14 +1875,14 @@ class arg_formatter_base { iterator operator()(const char_type* value) { if (!specs_) return write(value), out(); - internal::handle_cstring_type_spec(specs_->type, - cstring_spec_handler(*this, value)); + detail::handle_cstring_type_spec(specs_->type, + cstring_spec_handler(*this, value)); return out(); } iterator operator()(basic_string_view value) { if (specs_) { - internal::check_string_type_spec(specs_->type, internal::error_handler()); + detail::check_string_type_spec(specs_->type, detail::error_handler()); write(value, *specs_); } else { write(value); @@ -1890,8 +1891,7 @@ class arg_formatter_base { } iterator operator()(const void* value) { - if (specs_) - check_pointer_type_spec(specs_->type, internal::error_handler()); + if (specs_) check_pointer_type_spec(specs_->type, detail::error_handler()); write_pointer(value); return out(); } @@ -2029,7 +2029,7 @@ template class specs_setter { template class numeric_specs_checker { public: - FMT_CONSTEXPR numeric_specs_checker(ErrorHandler& eh, internal::type arg_type) + FMT_CONSTEXPR numeric_specs_checker(ErrorHandler& eh, detail::type arg_type) : error_handler_(eh), arg_type_(arg_type) {} FMT_CONSTEXPR void require_numeric_argument() { @@ -2052,7 +2052,7 @@ template class numeric_specs_checker { private: ErrorHandler& error_handler_; - internal::type arg_type_; + detail::type arg_type_; }; // A format specifier handler that checks if specifiers are consistent with the @@ -2065,7 +2065,7 @@ template class specs_checker : public Handler { FMT_CONSTEXPR Handler& error_handler() { return *this; } public: - FMT_CONSTEXPR specs_checker(const Handler& handler, internal::type arg_type) + FMT_CONSTEXPR specs_checker(const Handler& handler, detail::type arg_type) : Handler(handler), checker_(error_handler(), arg_type) {} FMT_CONSTEXPR specs_checker(const specs_checker& other) @@ -2150,17 +2150,17 @@ class specs_handler : public specs_setter { using format_arg = typename Context::format_arg; FMT_CONSTEXPR format_arg get_arg(auto_id) { - return internal::get_arg(context_, parse_context_.next_arg_id()); + return detail::get_arg(context_, parse_context_.next_arg_id()); } FMT_CONSTEXPR format_arg get_arg(int arg_id) { parse_context_.check_arg_id(arg_id); - return internal::get_arg(context_, arg_id); + return detail::get_arg(context_, arg_id); } FMT_CONSTEXPR format_arg get_arg(basic_string_view arg_id) { parse_context_.check_arg_id(arg_id); - return internal::get_arg(context_, arg_id); + return detail::get_arg(context_, arg_id); } ParseContext& parse_context_; @@ -2478,7 +2478,7 @@ template <> inline bool find(const char* first, const char* last, char value, const char*& out) { out = static_cast( - std::memchr(first, value, internal::to_unsigned(last - first))); + std::memchr(first, value, detail::to_unsigned(last - first))); return out != nullptr; } @@ -2552,12 +2552,12 @@ FMT_CONSTEXPR const typename ParseContext::char_type* parse_format_specs( using char_type = typename ParseContext::char_type; using context = buffer_context; using mapped_type = - conditional_t::value != + conditional_t::value != type::custom_type, decltype(arg_mapper().map(std::declval())), T>; auto f = conditional_t::value, formatter, - internal::fallback_formatter>(); + detail::fallback_formatter>(); return f.parse(ctx); } @@ -2651,17 +2651,17 @@ FMT_CONSTEXPR basic_string_view compile_string_to_view( return {s.data(), s.size()}; } -#define FMT_STRING_IMPL(s, ...) \ - [] { \ - /* Use a macro-like name to avoid shadowing warnings. */ \ - struct FMT_COMPILE_STRING : fmt::compile_string { \ - using char_type = fmt::remove_cvref_t; \ - FMT_MAYBE_UNUSED __VA_ARGS__ FMT_CONSTEXPR \ - operator fmt::basic_string_view() const { \ - return fmt::internal::compile_string_to_view(s); \ - } \ - }; \ - return FMT_COMPILE_STRING(); \ +#define FMT_STRING_IMPL(s, ...) \ + [] { \ + /* Use a macro-like name to avoid shadowing warnings. */ \ + struct FMT_COMPILE_STRING : fmt::compile_string { \ + using char_type = fmt::remove_cvref_t; \ + FMT_MAYBE_UNUSED __VA_ARGS__ FMT_CONSTEXPR \ + operator fmt::basic_string_view() const { \ + return fmt::detail::compile_string_to_view(s); \ + } \ + }; \ + return FMT_COMPILE_STRING(); \ }() /** @@ -2694,31 +2694,31 @@ void handle_dynamic_spec(int& value, arg_ref ref, case arg_id_kind::none: break; case arg_id_kind::index: - value = internal::get_dynamic_spec(ctx.arg(ref.val.index), - ctx.error_handler()); + value = detail::get_dynamic_spec(ctx.arg(ref.val.index), + ctx.error_handler()); break; case arg_id_kind::name: - value = internal::get_dynamic_spec(ctx.arg(ref.val.name), - ctx.error_handler()); + value = detail::get_dynamic_spec(ctx.arg(ref.val.name), + ctx.error_handler()); break; } } -using format_func = void (*)(internal::buffer&, int, string_view); +using format_func = void (*)(detail::buffer&, int, string_view); FMT_API void format_error_code(buffer& out, int error_code, string_view message) FMT_NOEXCEPT; FMT_API void report_error(format_func func, int error_code, string_view message) FMT_NOEXCEPT; -} // namespace internal +} // namespace detail /** The default argument formatter. */ template -class arg_formatter : public internal::arg_formatter_base { +class arg_formatter : public detail::arg_formatter_base { private: using char_type = typename Range::value_type; - using base = internal::arg_formatter_base; + using base = detail::arg_formatter_base; using context_type = basic_format_context; context_type& ctx_; @@ -2816,7 +2816,7 @@ class FMT_API system_error : public std::runtime_error { may look like "Unknown error -1" and is platform-dependent. \endrst */ -FMT_API void format_system_error(internal::buffer& out, int error_code, +FMT_API void format_system_error(detail::buffer& out, int error_code, string_view message) FMT_NOEXCEPT; // Reports a system error without throwing an exception. @@ -2842,16 +2842,16 @@ class format_int { // "Three Optimization Tips for C++". See speed-test for a comparison. auto index = static_cast((value % 100) * 2); value /= 100; - *--ptr = internal::data::digits[index + 1]; - *--ptr = internal::data::digits[index]; + *--ptr = detail::data::digits[index + 1]; + *--ptr = detail::data::digits[index]; } if (value < 10) { *--ptr = static_cast('0' + value); return ptr; } auto index = static_cast(value * 2); - *--ptr = internal::data::digits[index + 1]; - *--ptr = internal::data::digits[index]; + *--ptr = detail::data::digits[index + 1]; + *--ptr = detail::data::digits[index]; return ptr; } @@ -2873,7 +2873,7 @@ class format_int { /** Returns the number of characters written to the output buffer. */ size_t size() const { - return internal::to_unsigned(buffer_ - str_ + buffer_size - 1); + return detail::to_unsigned(buffer_ - str_ + buffer_size - 1); } /** @@ -2899,71 +2899,71 @@ class format_int { std::string str() const { return std::string(str_, size()); } }; -// A formatter specialization for the core types corresponding to internal::type +// A formatter specialization for the core types corresponding to detail::type // constants. template struct formatter::value != - internal::type::custom_type>> { + enable_if_t::value != + detail::type::custom_type>> { FMT_CONSTEXPR formatter() = default; // Parses format specifiers stopping either at the end of the range or at the // terminating '}'. template FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { - using handler_type = internal::dynamic_specs_handler; - auto type = internal::type_constant::value; - internal::specs_checker handler(handler_type(specs_, ctx), - type); + using handler_type = detail::dynamic_specs_handler; + auto type = detail::type_constant::value; + detail::specs_checker handler(handler_type(specs_, ctx), + type); auto it = parse_format_specs(ctx.begin(), ctx.end(), handler); auto eh = ctx.error_handler(); switch (type) { - case internal::type::none_type: + case detail::type::none_type: FMT_ASSERT(false, "invalid argument type"); break; - case internal::type::int_type: - case internal::type::uint_type: - case internal::type::long_long_type: - case internal::type::ulong_long_type: - case internal::type::int128_type: - case internal::type::uint128_type: - case internal::type::bool_type: + case detail::type::int_type: + case detail::type::uint_type: + case detail::type::long_long_type: + case detail::type::ulong_long_type: + case detail::type::int128_type: + case detail::type::uint128_type: + case detail::type::bool_type: handle_int_type_spec(specs_.type, - internal::int_type_checker(eh)); + detail::int_type_checker(eh)); break; - case internal::type::char_type: + case detail::type::char_type: handle_char_specs( - &specs_, internal::char_specs_checker(specs_.type, eh)); + &specs_, detail::char_specs_checker(specs_.type, eh)); break; - case internal::type::float_type: - if (internal::const_check(FMT_USE_FLOAT)) - internal::parse_float_type_spec(specs_, eh); + case detail::type::float_type: + if (detail::const_check(FMT_USE_FLOAT)) + detail::parse_float_type_spec(specs_, eh); else FMT_ASSERT(false, "float support disabled"); break; - case internal::type::double_type: - if (internal::const_check(FMT_USE_DOUBLE)) - internal::parse_float_type_spec(specs_, eh); + case detail::type::double_type: + if (detail::const_check(FMT_USE_DOUBLE)) + detail::parse_float_type_spec(specs_, eh); else FMT_ASSERT(false, "double support disabled"); break; - case internal::type::long_double_type: - if (internal::const_check(FMT_USE_LONG_DOUBLE)) - internal::parse_float_type_spec(specs_, eh); + case detail::type::long_double_type: + if (detail::const_check(FMT_USE_LONG_DOUBLE)) + detail::parse_float_type_spec(specs_, eh); else FMT_ASSERT(false, "long double support disabled"); break; - case internal::type::cstring_type: - internal::handle_cstring_type_spec( - specs_.type, internal::cstring_type_checker(eh)); + case detail::type::cstring_type: + detail::handle_cstring_type_spec( + specs_.type, detail::cstring_type_checker(eh)); break; - case internal::type::string_type: - internal::check_string_type_spec(specs_.type, eh); + case detail::type::string_type: + detail::check_string_type_spec(specs_.type, eh); break; - case internal::type::pointer_type: - internal::check_pointer_type_spec(specs_.type, eh); + case detail::type::pointer_type: + detail::check_pointer_type_spec(specs_.type, eh); break; - case internal::type::custom_type: + case detail::type::custom_type: // Custom format specifiers should be checked in parse functions of // formatter specializations. break; @@ -2973,19 +2973,18 @@ struct formatter auto format(const T& val, FormatContext& ctx) -> decltype(ctx.out()) { - internal::handle_dynamic_spec( - specs_.width, specs_.width_ref, ctx); - internal::handle_dynamic_spec( + detail::handle_dynamic_spec(specs_.width, + specs_.width_ref, ctx); + detail::handle_dynamic_spec( specs_.precision, specs_.precision_ref, ctx); - using range_type = - internal::output_range; + using range_type = detail::output_range; return visit_format_arg(arg_formatter(ctx, nullptr, &specs_), - internal::make_arg(val)); + detail::make_arg(val)); } private: - internal::dynamic_format_specs specs_; + detail::dynamic_format_specs specs_; }; #define FMT_FORMAT_AS(Type, Base) \ @@ -3006,7 +3005,7 @@ FMT_FORMAT_AS(unsigned long, unsigned long long); FMT_FORMAT_AS(Char*, const Char*); FMT_FORMAT_AS(std::basic_string, basic_string_view); FMT_FORMAT_AS(std::nullptr_t, const void*); -FMT_FORMAT_AS(internal::std_string_view, basic_string_view); +FMT_FORMAT_AS(detail::std_string_view, basic_string_view); template struct formatter : formatter { @@ -3036,7 +3035,7 @@ struct formatter : formatter, Char> { // }; template class dynamic_formatter { private: - struct null_handler : internal::error_handler { + struct null_handler : detail::error_handler { void on_align(align_t) {} void on_plus() {} void on_minus() {} @@ -3049,16 +3048,15 @@ template class dynamic_formatter { auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { format_str_ = ctx.begin(); // Checks are deferred to formatting time when the argument type is known. - internal::dynamic_specs_handler handler(specs_, ctx); + detail::dynamic_specs_handler handler(specs_, ctx); return parse_format_specs(ctx.begin(), ctx.end(), handler); } template auto format(const T& val, FormatContext& ctx) -> decltype(ctx.out()) { handle_specs(ctx); - internal::specs_checker checker( - null_handler(), - internal::mapped_type_constant::value); + detail::specs_checker checker( + null_handler(), detail::mapped_type_constant::value); checker.on_align(specs_.align); switch (specs_.sign) { case sign::none: @@ -3075,22 +3073,22 @@ template class dynamic_formatter { } if (specs_.alt) checker.on_hash(); if (specs_.precision >= 0) checker.end_precision(); - using range = internal::output_range; + using range = detail::output_range; visit_format_arg(arg_formatter(ctx, nullptr, &specs_), - internal::make_arg(val)); + detail::make_arg(val)); return ctx.out(); } private: template void handle_specs(Context& ctx) { - internal::handle_dynamic_spec( - specs_.width, specs_.width_ref, ctx); - internal::handle_dynamic_spec( + detail::handle_dynamic_spec(specs_.width, + specs_.width_ref, ctx); + detail::handle_dynamic_spec( specs_.precision, specs_.precision_ref, ctx); } - internal::dynamic_format_specs specs_; + detail::dynamic_format_specs specs_; const Char* format_str_; }; @@ -3101,24 +3099,23 @@ FMT_CONSTEXPR void advance_to( } template -struct format_handler : internal::error_handler { +struct format_handler : detail::error_handler { using range = typename ArgFormatter::range; format_handler(range r, basic_string_view str, - basic_format_args format_args, - internal::locale_ref loc) + basic_format_args format_args, detail::locale_ref loc) : parse_context(str), context(r.begin(), format_args, loc) {} void on_text(const Char* begin, const Char* end) { - auto size = internal::to_unsigned(end - begin); + auto size = detail::to_unsigned(end - begin); auto out = context.out(); - auto&& it = internal::reserve(out, size); + auto&& it = detail::reserve(out, size); it = std::copy_n(begin, size, it); context.advance_to(out); } template void get_arg(ID id) { - arg = internal::get_arg(context, id); + arg = detail::get_arg(context, id); } void on_arg_id() { get_arg(parse_context.next_arg_id()); } @@ -3136,12 +3133,12 @@ struct format_handler : internal::error_handler { const Char* on_format_specs(const Char* begin, const Char* end) { advance_to(parse_context, begin); - internal::custom_formatter f(parse_context, context); + detail::custom_formatter f(parse_context, context); if (visit_format_arg(f, arg)) return parse_context.begin(); basic_format_specs specs; - using internal::specs_handler; + using detail::specs_handler; using parse_context_t = basic_format_parse_context; - internal::specs_checker> handler( + detail::specs_checker> handler( specs_handler(specs, parse_context, context), arg.type()); begin = parse_format_specs(begin, end, handler); @@ -3162,9 +3159,9 @@ template typename Context::iterator vformat_to( typename ArgFormatter::range out, basic_string_view format_str, basic_format_args args, - internal::locale_ref loc = internal::locale_ref()) { + detail::locale_ref loc = detail::locale_ref()) { format_handler h(out, format_str, args, loc); - internal::parse_format_string(format_str, h); + detail::parse_format_string(format_str, h); return h.context.out(); } @@ -3191,28 +3188,28 @@ class bytes { template <> struct formatter { template FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { - using handler_type = internal::dynamic_specs_handler; - internal::specs_checker handler(handler_type(specs_, ctx), - internal::type::string_type); + using handler_type = detail::dynamic_specs_handler; + detail::specs_checker handler(handler_type(specs_, ctx), + detail::type::string_type); auto it = parse_format_specs(ctx.begin(), ctx.end(), handler); - internal::check_string_type_spec(specs_.type, ctx.error_handler()); + detail::check_string_type_spec(specs_.type, ctx.error_handler()); return it; } template auto format(bytes b, FormatContext& ctx) -> decltype(ctx.out()) { - internal::handle_dynamic_spec( - specs_.width, specs_.width_ref, ctx); - internal::handle_dynamic_spec( + detail::handle_dynamic_spec(specs_.width, + specs_.width_ref, ctx); + detail::handle_dynamic_spec( specs_.precision, specs_.precision_ref, ctx); - return internal::write_bytes(ctx.out(), b.data_, specs_); + return detail::write_bytes(ctx.out(), b.data_, specs_); } private: - internal::dynamic_format_specs specs_; + detail::dynamic_format_specs specs_; }; -template struct arg_join : internal::view { +template struct arg_join : detail::view { It begin; It end; basic_string_view sep; @@ -3272,14 +3269,14 @@ arg_join join(It begin, It end, wstring_view sep) { \endrst */ template -arg_join, char> join(const Range& range, - string_view sep) { +arg_join, char> join(const Range& range, + string_view sep) { return join(std::begin(range), std::end(range), sep); } template -arg_join, wchar_t> join(const Range& range, - wstring_view sep) { +arg_join, wchar_t> join(const Range& range, + wstring_view sep) { return join(std::begin(range), std::end(range), sep); } @@ -3311,8 +3308,8 @@ std::basic_string to_string(const basic_memory_buffer& buf) { } template -typename buffer_context::iterator internal::vformat_to( - internal::buffer& buf, basic_string_view format_str, +typename buffer_context::iterator detail::vformat_to( + detail::buffer& buf, basic_string_view format_str, basic_format_args>> args) { using range = buffer_range; return vformat_to>(buf, to_string_view(format_str), @@ -3320,9 +3317,9 @@ typename buffer_context::iterator internal::vformat_to( } #ifndef FMT_HEADER_ONLY -extern template format_context::iterator internal::vformat_to( - internal::buffer&, string_view, basic_format_args); -namespace internal { +extern template format_context::iterator detail::vformat_to( + detail::buffer&, string_view, basic_format_args); +namespace detail { extern template FMT_API std::string grouping_impl(locale_ref loc); extern template FMT_API std::string grouping_impl(locale_ref loc); extern template FMT_API char thousands_sep_impl(locale_ref loc); @@ -3343,25 +3340,25 @@ extern template int snprintf_float(long double value, int precision, float_specs specs, buffer& buf); -} // namespace internal +} // namespace detail #endif template , - FMT_ENABLE_IF(internal::is_string::value)> + FMT_ENABLE_IF(detail::is_string::value)> inline typename buffer_context::iterator vformat_to( - internal::buffer& buf, const S& format_str, + detail::buffer& buf, const S& format_str, basic_format_args>> args) { - return internal::vformat_to(buf, to_string_view(format_str), args); + return detail::vformat_to(buf, to_string_view(format_str), args); } template ::value, char_t>> + typename Char = enable_if_t::value, char_t>> inline typename buffer_context::iterator format_to( basic_memory_buffer& buf, const S& format_str, Args&&... args) { - internal::check_format_string(format_str); + detail::check_format_string(format_str); using context = buffer_context; - return internal::vformat_to(buf, to_string_view(format_str), - make_format_args(args...)); + return detail::vformat_to(buf, to_string_view(format_str), + make_format_args(args...)); } template @@ -3370,14 +3367,14 @@ using format_context_t = basic_format_context; template using format_args_t = basic_format_args>; -template ::value && - !internal::is_contiguous_back_insert_iterator::value)> +template < + typename S, typename OutputIt, typename... Args, + FMT_ENABLE_IF(detail::is_output_iterator::value && + !detail::is_contiguous_back_insert_iterator::value)> inline OutputIt vformat_to( OutputIt out, const S& format_str, format_args_t, char_t> args) { - using range = internal::output_range>; + using range = detail::output_range>; return vformat_to>(range(out), to_string_view(format_str), args); } @@ -3395,11 +3392,11 @@ inline OutputIt vformat_to( */ template ::value && - !internal::is_contiguous_back_insert_iterator::value && - internal::is_string::value)> + detail::is_output_iterator::value && + !detail::is_contiguous_back_insert_iterator::value && + detail::is_string::value)> inline OutputIt format_to(OutputIt out, const S& format_str, Args&&... args) { - internal::check_format_string(format_str); + detail::check_format_string(format_str); using context = format_context_t>; return vformat_to(out, to_string_view(format_str), make_format_args(args...)); @@ -3414,7 +3411,7 @@ template struct format_to_n_result { template using format_to_n_context = - format_context_t, Char>; + format_context_t, Char>; template using format_to_n_args = basic_format_args>; @@ -3427,11 +3424,11 @@ make_format_to_n_args(const Args&... args) { } template ::value)> + FMT_ENABLE_IF(detail::is_output_iterator::value)> inline format_to_n_result vformat_to_n( OutputIt out, size_t n, basic_string_view format_str, format_to_n_args, type_identity_t> args) { - auto it = vformat_to(internal::truncating_iterator(out, n), + auto it = vformat_to(detail::truncating_iterator(out, n), format_str, args); return {it.base(), it.count()}; } @@ -3444,23 +3441,23 @@ inline format_to_n_result vformat_to_n( \endrst */ template ::value&& - internal::is_output_iterator::value)> + FMT_ENABLE_IF(detail::is_string::value&& + detail::is_output_iterator::value)> inline format_to_n_result format_to_n(OutputIt out, size_t n, const S& format_str, const Args&... args) { - internal::check_format_string(format_str); + detail::check_format_string(format_str); using context = format_to_n_context>; return vformat_to_n(out, n, to_string_view(format_str), make_format_args(args...)); } template -std::basic_string internal::vformat( +std::basic_string detail::vformat( basic_string_view format_str, basic_format_args>> args) { basic_memory_buffer buffer; - internal::vformat_to(buffer, format_str, args); + detail::vformat_to(buffer, format_str, args); return to_string(buffer); } @@ -3470,14 +3467,14 @@ std::basic_string internal::vformat( */ template inline size_t formatted_size(string_view format_str, const Args&... args) { - return format_to(internal::counting_iterator(), format_str, args...).count(); + return format_to(detail::counting_iterator(), format_str, args...).count(); } template ::value)> void vprint(std::FILE* f, basic_string_view format_str, wformat_args args) { wmemory_buffer buffer; - internal::vformat_to(buffer, format_str, args); + detail::vformat_to(buffer, format_str, args); buffer.push_back(L'\0'); if (std::fputws(buffer.data(), f) == -1) FMT_THROW(system_error(errno, "cannot write to file")); @@ -3489,7 +3486,7 @@ void vprint(basic_string_view format_str, wformat_args args) { } #if FMT_USE_USER_DEFINED_LITERALS -namespace internal { +namespace detail { # if FMT_USE_UDL_TEMPLATE template class udl_formatter { @@ -3519,7 +3516,7 @@ template struct udl_arg { return {str, std::forward(value)}; } }; -} // namespace internal +} // namespace detail inline namespace literals { # if FMT_USE_UDL_TEMPLATE @@ -3529,7 +3526,7 @@ inline namespace literals { # pragma GCC diagnostic ignored "-Wgnu-string-literal-operator-template" # endif template -FMT_CONSTEXPR internal::udl_formatter operator""_format() { +FMT_CONSTEXPR detail::udl_formatter operator""_format() { return {}; } # pragma GCC diagnostic pop @@ -3544,11 +3541,11 @@ FMT_CONSTEXPR internal::udl_formatter operator""_format() { std::string message = "The answer is {}"_format(42); \endrst */ -FMT_CONSTEXPR internal::udl_formatter operator"" _format(const char* s, - size_t n) { +FMT_CONSTEXPR detail::udl_formatter operator"" _format(const char* s, + size_t n) { return {{s, n}}; } -FMT_CONSTEXPR internal::udl_formatter operator"" _format( +FMT_CONSTEXPR detail::udl_formatter operator"" _format( const wchar_t* s, size_t n) { return {{s, n}}; } @@ -3564,11 +3561,10 @@ FMT_CONSTEXPR internal::udl_formatter operator"" _format( fmt::print("Elapsed time: {s:.2f} seconds", "s"_a=1.23); \endrst */ -FMT_CONSTEXPR internal::udl_arg operator"" _a(const char* s, size_t) { +FMT_CONSTEXPR detail::udl_arg operator"" _a(const char* s, size_t) { return {s}; } -FMT_CONSTEXPR internal::udl_arg operator"" _a(const wchar_t* s, - size_t) { +FMT_CONSTEXPR detail::udl_arg operator"" _a(const wchar_t* s, size_t) { return {s}; } } // namespace literals diff --git a/include/fmt/locale.h b/include/fmt/locale.h index 70bc1935..34b5c890 100644 --- a/include/fmt/locale.h +++ b/include/fmt/locale.h @@ -14,7 +14,7 @@ FMT_BEGIN_NAMESPACE -namespace internal { +namespace detail { template typename buffer_context::iterator vformat_to( const std::locale& loc, buffer& buf, @@ -22,7 +22,7 @@ typename buffer_context::iterator vformat_to( basic_format_args>> args) { using range = buffer_range; return vformat_to>(buf, to_string_view(format_str), args, - internal::locale_ref(loc)); + detail::locale_ref(loc)); } template @@ -30,43 +30,43 @@ std::basic_string vformat( const std::locale& loc, basic_string_view format_str, basic_format_args>> args) { basic_memory_buffer buffer; - internal::vformat_to(loc, buffer, format_str, args); + detail::vformat_to(loc, buffer, format_str, args); return fmt::to_string(buffer); } -} // namespace internal +} // namespace detail template > inline std::basic_string vformat( const std::locale& loc, const S& format_str, basic_format_args>> args) { - return internal::vformat(loc, to_string_view(format_str), args); + return detail::vformat(loc, to_string_view(format_str), args); } template > inline std::basic_string format(const std::locale& loc, const S& format_str, Args&&... args) { - return internal::vformat( + return detail::vformat( loc, to_string_view(format_str), - internal::make_args_checked(format_str, args...)); + detail::make_args_checked(format_str, args...)); } template ::value, char_t>> + detail::is_output_iterator::value, char_t>> inline OutputIt vformat_to( OutputIt out, const std::locale& loc, const S& format_str, format_args_t, Char> args) { - using range = internal::output_range; + using range = detail::output_range; return vformat_to>( - range(out), to_string_view(format_str), args, internal::locale_ref(loc)); + range(out), to_string_view(format_str), args, detail::locale_ref(loc)); } template ::value&& - internal::is_string::value)> + FMT_ENABLE_IF(detail::is_output_iterator::value&& + detail::is_string::value)> inline OutputIt format_to(OutputIt out, const std::locale& loc, const S& format_str, Args&&... args) { - internal::check_format_string(format_str); + detail::check_format_string(format_str); using context = format_context_t>; format_arg_store as{args...}; return vformat_to(out, loc, to_string_view(format_str), diff --git a/include/fmt/os.h b/include/fmt/os.h index a9c1b7d8..8aa474a6 100644 --- a/include/fmt/os.h +++ b/include/fmt/os.h @@ -133,7 +133,7 @@ class error_code { }; #ifdef _WIN32 -namespace internal { +namespace detail { // A converter from UTF-16 to UTF-8. // It is only provided for Windows since other systems support UTF-8 natively. class utf16_to_utf8 { @@ -156,7 +156,7 @@ class utf16_to_utf8 { FMT_API void format_windows_error(buffer& out, int error_code, string_view message) FMT_NOEXCEPT; -} // namespace internal +} // namespace detail /** A Windows error. */ class windows_error : public system_error { diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index 6c7d69b6..597316d8 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -17,7 +17,7 @@ FMT_BEGIN_NAMESPACE template class basic_printf_parse_context; template class basic_printf_context; -namespace internal { +namespace detail { template class formatbuf : public std::basic_streambuf { private: @@ -136,14 +136,14 @@ struct fallback_formatter::value>> return std::copy(buffer.begin(), buffer.end(), ctx.out()); } }; -} // namespace internal +} // namespace detail template void vprint(std::basic_ostream& os, basic_string_view format_str, basic_format_args>> args) { basic_memory_buffer buffer; - internal::vformat_to(buffer, format_str, args); - internal::write(os, buffer); + detail::vformat_to(buffer, format_str, args); + detail::write(os, buffer); } /** @@ -156,10 +156,10 @@ void vprint(std::basic_ostream& os, basic_string_view format_str, \endrst */ template ::value, char_t>> + typename Char = enable_if_t::value, char_t>> void print(std::basic_ostream& os, const S& format_str, Args&&... args) { vprint(os, to_string_view(format_str), - internal::make_args_checked(format_str, args...)); + detail::make_args_checked(format_str, args...)); } FMT_END_NAMESPACE diff --git a/include/fmt/printf.h b/include/fmt/printf.h index 3d80e90c..6d014fcd 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -14,7 +14,7 @@ #include "ostream.h" FMT_BEGIN_NAMESPACE -namespace internal { +namespace detail { // Checks if a value fits in int - used to avoid warnings about comparing // signed and unsigned integers. @@ -90,11 +90,11 @@ template class arg_converter { if (const_check(sizeof(target_type) <= sizeof(int))) { // Extra casts are used to silence warnings. if (is_signed) { - arg_ = internal::make_arg( + arg_ = detail::make_arg( static_cast(static_cast(value))); } else { using unsigned_type = typename make_unsigned_or_bool::type; - arg_ = internal::make_arg( + arg_ = detail::make_arg( static_cast(static_cast(value))); } } else { @@ -102,9 +102,9 @@ template class arg_converter { // glibc's printf doesn't sign extend arguments of smaller types: // std::printf("%lld", -42); // prints "4294967254" // but we don't have to do the same because it's a UB. - arg_ = internal::make_arg(static_cast(value)); + arg_ = detail::make_arg(static_cast(value)); } else { - arg_ = internal::make_arg( + arg_ = detail::make_arg( static_cast::type>(value)); } } @@ -133,7 +133,7 @@ template class char_converter { template ::value)> void operator()(T value) { - arg_ = internal::make_arg( + arg_ = detail::make_arg( static_cast(value)); } @@ -162,7 +162,7 @@ template class printf_width_handler { template ::value)> unsigned operator()(T value) { auto width = static_cast>(value); - if (internal::is_negative(value)) { + if (detail::is_negative(value)) { specs_.align = align::left; width = 0 - width; } @@ -183,16 +183,16 @@ void vprintf(buffer& buf, basic_string_view format, basic_format_args args) { Context(std::back_inserter(buf), format, args).format(); } -} // namespace internal +} // namespace detail // For printing into memory_buffer. template -FMT_DEPRECATED void printf(internal::buffer& buf, +FMT_DEPRECATED void printf(detail::buffer& buf, basic_string_view format, basic_format_args args) { - return internal::vprintf(buf, format, args); + return detail::vprintf(buf, format, args); } -using internal::vprintf; +using detail::vprintf; template class printf_arg_formatter; @@ -208,13 +208,13 @@ template class basic_printf_context; \endrst */ template -class printf_arg_formatter : public internal::arg_formatter_base { +class printf_arg_formatter : public detail::arg_formatter_base { public: using iterator = typename Range::iterator; private: using char_type = typename Range::value_type; - using base = internal::arg_formatter_base; + using base = detail::arg_formatter_base; using context_type = basic_printf_context; context_type& context_; @@ -240,9 +240,9 @@ class printf_arg_formatter : public internal::arg_formatter_base { \endrst */ printf_arg_formatter(iterator iter, format_specs& specs, context_type& ctx) - : base(Range(iter), &specs, internal::locale_ref()), context_(ctx) {} + : base(Range(iter), &specs, detail::locale_ref()), context_(ctx) {} - template ::value)> + template ::value)> iterator operator()(T value) { // MSVC2013 fails to compile separate overloads for bool and char_type so // use std::is_same instead. @@ -323,7 +323,7 @@ template struct printf_formatter { template auto format(const T& value, FormatContext& ctx) -> decltype(ctx.out()) { - internal::format_value(internal::get_container(ctx.out()), value); + detail::format_value(detail::get_container(ctx.out()), value); return ctx.out(); } }; @@ -371,7 +371,7 @@ template class basic_printf_context { OutputIt out() { return out_; } void advance_to(OutputIt it) { out_ = it; } - internal::locale_ref locale() { return {}; } + detail::locale_ref locale() { return {}; } format_arg arg(int id) const { return args_.get(id); } @@ -420,7 +420,7 @@ basic_printf_context::get_arg(int arg_index) { arg_index = parse_ctx_.next_arg_id(); else parse_ctx_.check_arg_id(--arg_index); - return internal::get_arg(*this, arg_index); + return detail::get_arg(*this, arg_index); } template @@ -432,7 +432,7 @@ int basic_printf_context::parse_header(const Char*& it, if (c >= '0' && c <= '9') { // Parse an argument index (if followed by '$') or a width possibly // preceded with '0' flag(s). - internal::error_handler eh; + detail::error_handler eh; int value = parse_nonnegative_int(it, end, eh); if (it != end && *it == '$') { // value is an argument index ++it; @@ -451,12 +451,12 @@ int basic_printf_context::parse_header(const Char*& it, // Parse width. if (it != end) { if (*it >= '0' && *it <= '9') { - internal::error_handler eh; + detail::error_handler eh; specs.width = parse_nonnegative_int(it, end, eh); } else if (*it == '*') { ++it; specs.width = static_cast(visit_format_arg( - internal::printf_width_handler(specs), get_arg())); + detail::printf_width_handler(specs), get_arg())); } } return arg_index; @@ -491,27 +491,27 @@ OutputIt basic_printf_context::format() { ++it; c = it != end ? *it : 0; if ('0' <= c && c <= '9') { - internal::error_handler eh; + detail::error_handler eh; specs.precision = parse_nonnegative_int(it, end, eh); } else if (c == '*') { ++it; specs.precision = static_cast( - visit_format_arg(internal::printf_precision_handler(), get_arg())); + visit_format_arg(detail::printf_precision_handler(), get_arg())); } else { specs.precision = 0; } } format_arg arg = get_arg(arg_index); - if (specs.precision >= 0 && arg.type() == internal::type::cstring_type) { - auto str = visit_format_arg(internal::get_cstring(), arg); + if (specs.precision >= 0 && arg.type() == detail::type::cstring_type) { + auto str = visit_format_arg(detail::get_cstring(), arg); auto str_end = str + specs.precision; auto nul = std::find(str, str_end, Char()); - arg = internal::make_arg(basic_string_view( + arg = detail::make_arg(basic_string_view( str, - internal::to_unsigned(nul != str_end ? nul - str : specs.precision))); + detail::to_unsigned(nul != str_end ? nul - str : specs.precision))); } - if (specs.alt && visit_format_arg(internal::is_zero_int(), arg)) + if (specs.alt && visit_format_arg(detail::is_zero_int(), arg)) specs.alt = false; if (specs.fill[0] == '0') { if (arg.is_arithmetic()) @@ -523,7 +523,7 @@ OutputIt basic_printf_context::format() { // Parse length and convert the argument to the required type. c = it != end ? *it++ : 0; char_type t = it != end ? *it : 0; - using internal::convert_arg; + using detail::convert_arg; switch (c) { case 'h': if (t == 'h') { @@ -572,7 +572,7 @@ OutputIt basic_printf_context::format() { specs.type = 'd'; break; case 'c': - visit_format_arg(internal::char_converter(arg), + visit_format_arg(detail::char_converter(arg), arg); break; } @@ -588,8 +588,7 @@ OutputIt basic_printf_context::format() { template using basic_printf_context_t = - basic_printf_context>, - Char>; + basic_printf_context>, Char>; using printf_context = basic_printf_context_t; using wprintf_context = basic_printf_context_t; @@ -640,7 +639,7 @@ inline std::basic_string vsprintf( \endrst */ template ::value, char_t>> + typename Char = enable_if_t::value, char_t>> inline std::basic_string sprintf(const S& format, const Args&... args) { using context = basic_printf_context_t; return vsprintf(to_string_view(format), make_format_args(args...)); @@ -668,7 +667,7 @@ inline int vfprintf( \endrst */ template ::value, char_t>> + typename Char = enable_if_t::value, char_t>> inline int fprintf(std::FILE* f, const S& format, const Args&... args) { using context = basic_printf_context_t; return vfprintf(f, to_string_view(format), @@ -692,7 +691,7 @@ inline int vprintf( \endrst */ template ::value)> + FMT_ENABLE_IF(detail::is_string::value)> inline int printf(const S& format_str, const Args&... args) { using context = basic_printf_context_t>; return vprintf(to_string_view(format_str), @@ -705,7 +704,7 @@ inline int vfprintf( basic_format_args>> args) { basic_memory_buffer buffer; vprintf(buffer, to_string_view(format), args); - internal::write(os, buffer); + detail::write(os, buffer); return static_cast(buffer.size()); } @@ -714,7 +713,7 @@ template > typename ArgFormatter::iterator vprintf( - internal::buffer& out, basic_string_view format_str, + detail::buffer& out, basic_string_view format_str, basic_format_args> args) { typename ArgFormatter::iterator iter(out); Context(iter, format_str, args).template format(); diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index 2faf3b26..c58b97a1 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -54,7 +54,7 @@ struct formatting_tuple : formatting_base { static FMT_CONSTEXPR_DECL const bool add_prepostfix_space = false; }; -namespace internal { +namespace detail { template OutputIterator copy(const RangeT& range, OutputIterator out) { @@ -183,11 +183,11 @@ FMT_CONSTEXPR const wchar_t* format_str_quoted(bool add_space, const wchar_t) { return add_space ? L" '{}'" : L"'{}'"; } -} // namespace internal +} // namespace detail template struct is_tuple_like { static FMT_CONSTEXPR_DECL const bool value = - internal::is_tuple_like_::value && !internal::is_range_::value; + detail::is_tuple_like_::value && !detail::is_range_::value; }; template @@ -200,10 +200,10 @@ struct formatter::value>> { if (formatting.add_prepostfix_space) { *out++ = ' '; } - out = internal::copy(formatting.delimiter, out); + out = detail::copy(formatting.delimiter, out); } out = format_to(out, - internal::format_str_quoted( + detail::format_str_quoted( (formatting.add_delimiter_spaces && i > 0), v), v); ++i; @@ -227,13 +227,13 @@ struct formatter::value>> { auto format(const TupleT& values, FormatContext& ctx) -> decltype(ctx.out()) { auto out = ctx.out(); size_t i = 0; - internal::copy(formatting.prefix, out); + detail::copy(formatting.prefix, out); - internal::for_each(values, format_each{formatting, i, out}); + detail::for_each(values, format_each{formatting, i, out}); if (formatting.add_prepostfix_space) { *out++ = ' '; } - internal::copy(formatting.postfix, out); + detail::copy(formatting.postfix, out); return ctx.out(); } @@ -241,10 +241,9 @@ struct formatter::value>> { template struct is_range { static FMT_CONSTEXPR_DECL const bool value = - internal::is_range_::value && - !internal::is_like_std_string::value && + detail::is_range_::value && !detail::is_like_std_string::value && !std::is_convertible>::value && - !std::is_constructible, T>::value; + !std::is_constructible, T>::value; }; template @@ -260,15 +259,15 @@ struct formatter typename FormatContext::iterator format(const RangeT& values, FormatContext& ctx) { - auto out = internal::copy(formatting.prefix, ctx.out()); + auto out = detail::copy(formatting.prefix, ctx.out()); size_t i = 0; for (auto it = values.begin(), end = values.end(); it != end; ++it) { if (i > 0) { if (formatting.add_prepostfix_space) *out++ = ' '; - out = internal::copy(formatting.delimiter, out); + out = detail::copy(formatting.delimiter, out); } out = format_to(out, - internal::format_str_quoted( + detail::format_str_quoted( (formatting.add_delimiter_spaces && i > 0), *it), *it); if (++i > formatting.range_length_limit) { @@ -277,11 +276,11 @@ struct formatter struct tuple_arg_join : internal::view { +template struct tuple_arg_join : detail::view { const std::tuple& tuple; basic_string_view sep; @@ -299,14 +298,14 @@ struct formatter, Char> { template typename FormatContext::iterator format( const tuple_arg_join& value, FormatContext& ctx) { - return format(value, ctx, internal::make_index_sequence{}); + return format(value, ctx, detail::make_index_sequence{}); } private: template typename FormatContext::iterator format( const tuple_arg_join& value, FormatContext& ctx, - internal::index_sequence) { + detail::index_sequence) { return format_args(value, ctx, std::get(value.tuple)...); } @@ -369,13 +368,13 @@ FMT_CONSTEXPR tuple_arg_join join(const std::tuple& tuple, \endrst */ template -arg_join>, char> join( +arg_join>, char> join( std::initializer_list list, string_view sep) { return join(std::begin(list), std::end(list), sep); } template -arg_join>, wchar_t> join( +arg_join>, wchar_t> join( std::initializer_list list, wstring_view sep) { return join(std::begin(list), std::end(list), sep); } diff --git a/src/format.cc b/src/format.cc index d928cfed..fd1e1c15 100644 --- a/src/format.cc +++ b/src/format.cc @@ -8,7 +8,7 @@ #include "fmt/format-inl.h" FMT_BEGIN_NAMESPACE -namespace internal { +namespace detail { template int format_float(char* buf, std::size_t size, const char* format, int precision, @@ -23,52 +23,49 @@ int format_float(char* buf, std::size_t size, const char* format, int precision, return precision < 0 ? snprintf_ptr(buf, size, format, value) : snprintf_ptr(buf, size, format, precision, value); } -} // namespace internal +} // namespace detail -template struct FMT_INSTANTIATION_DEF_API internal::basic_data; +template struct FMT_INSTANTIATION_DEF_API detail::basic_data; // Workaround a bug in MSVC2013 that prevents instantiation of format_float. -int (*instantiate_format_float)(double, int, internal::float_specs, - internal::buffer&) = - internal::format_float; +int (*instantiate_format_float)(double, int, detail::float_specs, + detail::buffer&) = detail::format_float; #ifndef FMT_STATIC_THOUSANDS_SEPARATOR -template FMT_API internal::locale_ref::locale_ref(const std::locale& loc); -template FMT_API std::locale internal::locale_ref::get() const; +template FMT_API detail::locale_ref::locale_ref(const std::locale& loc); +template FMT_API std::locale detail::locale_ref::get() const; #endif // Explicit instantiations for char. -template FMT_API std::string internal::grouping_impl(locale_ref); -template FMT_API char internal::thousands_sep_impl(locale_ref); -template FMT_API char internal::decimal_point_impl(locale_ref); +template FMT_API std::string detail::grouping_impl(locale_ref); +template FMT_API char detail::thousands_sep_impl(locale_ref); +template FMT_API char detail::decimal_point_impl(locale_ref); -template FMT_API void internal::buffer::append(const char*, const char*); +template FMT_API void detail::buffer::append(const char*, const char*); -template FMT_API std::string internal::vformat( +template FMT_API std::string detail::vformat( string_view, basic_format_args); -template FMT_API format_context::iterator internal::vformat_to( - internal::buffer&, string_view, basic_format_args); +template FMT_API format_context::iterator detail::vformat_to( + detail::buffer&, string_view, basic_format_args); -template FMT_API int internal::snprintf_float(double, int, - internal::float_specs, - internal::buffer&); -template FMT_API int internal::snprintf_float(long double, int, - internal::float_specs, - internal::buffer&); -template FMT_API int internal::format_float(double, int, internal::float_specs, - internal::buffer&); -template FMT_API int internal::format_float(long double, int, - internal::float_specs, - internal::buffer&); +template FMT_API int detail::snprintf_float(double, int, detail::float_specs, + detail::buffer&); +template FMT_API int detail::snprintf_float(long double, int, + detail::float_specs, + detail::buffer&); +template FMT_API int detail::format_float(double, int, detail::float_specs, + detail::buffer&); +template FMT_API int detail::format_float(long double, int, detail::float_specs, + detail::buffer&); // Explicit instantiations for wchar_t. -template FMT_API std::string internal::grouping_impl(locale_ref); -template FMT_API wchar_t internal::thousands_sep_impl(locale_ref); -template FMT_API wchar_t internal::decimal_point_impl(locale_ref); +template FMT_API std::string detail::grouping_impl(locale_ref); +template FMT_API wchar_t detail::thousands_sep_impl(locale_ref); +template FMT_API wchar_t detail::decimal_point_impl(locale_ref); -template FMT_API void internal::buffer::append(const wchar_t*, - const wchar_t*); +template FMT_API void detail::buffer::append(const wchar_t*, + const wchar_t*); FMT_END_NAMESPACE diff --git a/src/os.cc b/src/os.cc index 328abcee..abf6a380 100644 --- a/src/os.cc +++ b/src/os.cc @@ -73,14 +73,14 @@ inline std::size_t convert_rwcount(std::size_t count) { return count; } FMT_BEGIN_NAMESPACE #ifdef _WIN32 -internal::utf16_to_utf8::utf16_to_utf8(wstring_view s) { +detail::utf16_to_utf8::utf16_to_utf8(wstring_view s) { if (int error_code = convert(s)) { FMT_THROW(windows_error(error_code, "cannot convert string from UTF-16 to UTF-8")); } } -int internal::utf16_to_utf8::convert(wstring_view s) { +int detail::utf16_to_utf8::convert(wstring_view s) { if (s.size() > INT_MAX) return ERROR_INVALID_PARAMETER; int s_size = static_cast(s.size()); if (s_size == 0) { @@ -105,13 +105,13 @@ void windows_error::init(int err_code, string_view format_str, format_args args) { error_code_ = err_code; memory_buffer buffer; - internal::format_windows_error(buffer, err_code, vformat(format_str, args)); + detail::format_windows_error(buffer, err_code, vformat(format_str, args)); std::runtime_error& base = *this; base = std::runtime_error(to_string(buffer)); } -void internal::format_windows_error(internal::buffer& out, int error_code, - string_view message) FMT_NOEXCEPT { +void detail::format_windows_error(detail::buffer& out, int error_code, + string_view message) FMT_NOEXCEPT { FMT_TRY { wmemory_buffer buf; buf.resize(inline_buffer_size); @@ -140,7 +140,7 @@ void internal::format_windows_error(internal::buffer& out, int error_code, void report_windows_error(int error_code, fmt::string_view message) FMT_NOEXCEPT { - report_error(internal::format_windows_error, error_code, message); + report_error(detail::format_windows_error, error_code, message); } #endif // _WIN32 @@ -231,14 +231,14 @@ std::size_t file::read(void* buffer, std::size_t count) { RWResult result = 0; FMT_RETRY(result, FMT_POSIX_CALL(read(fd_, buffer, convert_rwcount(count)))); if (result < 0) FMT_THROW(system_error(errno, "cannot read from file")); - return internal::to_unsigned(result); + return detail::to_unsigned(result); } std::size_t file::write(const void* buffer, std::size_t count) { RWResult result = 0; FMT_RETRY(result, FMT_POSIX_CALL(write(fd_, buffer, convert_rwcount(count)))); if (result < 0) FMT_THROW(system_error(errno, "cannot write to file")); - return internal::to_unsigned(result); + return detail::to_unsigned(result); } file file::dup(int fd) { diff --git a/test/compile-test.cc b/test/compile-test.cc index 047d5ff8..c93a2467 100644 --- a/test/compile-test.cc +++ b/test/compile-test.cc @@ -40,8 +40,8 @@ using testing::StrictMock; #if FMT_USE_CONSTEXPR template void check_prepared_parts_type(Format format) { - typedef fmt::internal::compiled_format_base provider; - typedef fmt::internal::format_part + typedef fmt::detail::compiled_format_base provider; + typedef fmt::detail::format_part expected_parts_type[EXPECTED_PARTS_COUNT]; static_assert(std::is_same::value, @@ -85,11 +85,11 @@ TEST(CompileTest, PassCompileString) { TEST(CompileTest, FormatToArrayOfChars) { char buffer[32] = {0}; const auto prepared = fmt::compile("4{}"); - fmt::format_to(fmt::internal::make_checked(buffer, 32), prepared, 2); + fmt::format_to(fmt::detail::make_checked(buffer, 32), prepared, 2); EXPECT_EQ(std::string("42"), buffer); wchar_t wbuffer[32] = {0}; const auto wprepared = fmt::compile(L"4{}"); - fmt::format_to(fmt::internal::make_checked(wbuffer, 32), wprepared, 2); + fmt::format_to(fmt::detail::make_checked(wbuffer, 32), wprepared, 2); EXPECT_EQ(std::wstring(L"42"), wbuffer); } diff --git a/test/core-test.cc b/test/core-test.cc index bb48db0b..a20d2449 100644 --- a/test/core-test.cc +++ b/test/core-test.cc @@ -30,8 +30,8 @@ using fmt::basic_format_arg; using fmt::string_view; -using fmt::internal::buffer; -using fmt::internal::value; +using fmt::detail::buffer; +using fmt::detail::value; using testing::_; using testing::StrictMock; @@ -42,7 +42,7 @@ struct test_struct {}; template basic_format_arg make_arg(const T& value) { - return fmt::internal::make_arg(value); + return fmt::detail::make_arg(value); } } // namespace @@ -148,7 +148,7 @@ TEST(BufferTest, Access) { EXPECT_EQ(11, buffer[0]); buffer[3] = 42; EXPECT_EQ(42, *(&buffer[0] + 3)); - const fmt::internal::buffer& const_buffer = buffer; + const fmt::detail::buffer& const_buffer = buffer; EXPECT_EQ(42, const_buffer[3]); } @@ -234,20 +234,20 @@ struct custom_context { TEST(ArgTest, MakeValueWithCustomContext) { test_struct t; - fmt::internal::value arg( - fmt::internal::arg_mapper().map(t)); + fmt::detail::value arg( + fmt::detail::arg_mapper().map(t)); custom_context ctx = {false, fmt::format_parse_context("")}; arg.custom.format(&t, ctx.parse_context(), ctx); EXPECT_TRUE(ctx.called); } FMT_BEGIN_NAMESPACE -namespace internal { +namespace detail { template bool operator==(custom_value lhs, custom_value rhs) { return lhs.value == rhs.value; } -} // namespace internal +} // namespace detail FMT_END_NAMESPACE // Use a unique result type to make sure that there are no undesirable @@ -372,12 +372,12 @@ TEST(ArgTest, PointerArg) { struct check_custom { test_result operator()( fmt::basic_format_arg::handle h) const { - struct test_buffer : fmt::internal::buffer { + struct test_buffer : fmt::detail::buffer { char data[10]; - test_buffer() : fmt::internal::buffer(data, 0, 10) {} + test_buffer() : fmt::detail::buffer(data, 0, 10) {} void grow(size_t) {} } buffer; - fmt::internal::buffer& base = buffer; + fmt::detail::buffer& base = buffer; fmt::format_parse_context parse_ctx(""); fmt::format_context ctx(std::back_inserter(base), fmt::format_args()); h.format(parse_ctx, ctx); @@ -470,9 +470,7 @@ TEST(FormatDynArgsTest, NamedStrings) { store.push_back(fmt::arg("a2", std::cref(str))); str[0] = 'X'; - std::string result = fmt::vformat( - "{a1} and {a2}", - store); + std::string result = fmt::vformat("{a1} and {a2}", store); EXPECT_EQ("1234567890 and X234567890", result); } @@ -495,9 +493,7 @@ TEST(FormatDynArgsTest, NamedArgByRef) { store.push_back(1.5f); store.push_back(std::cref(a1)); - std::string result = fmt::vformat( - "{a1_} and {} and {} and {}", - store); + std::string result = fmt::vformat("{a1_} and {} and {} and {}", store); EXPECT_EQ("42 and abc and 1.5 and 42", result); } @@ -671,20 +667,19 @@ struct derived_from_string_view : fmt::basic_string_view {}; } // namespace TYPED_TEST(IsStringTest, IsString) { - EXPECT_TRUE(fmt::internal::is_string::value); - EXPECT_TRUE(fmt::internal::is_string::value); - EXPECT_TRUE(fmt::internal::is_string::value); - EXPECT_TRUE(fmt::internal::is_string::value); - EXPECT_TRUE(fmt::internal::is_string>::value); + EXPECT_TRUE(fmt::detail::is_string::value); + EXPECT_TRUE(fmt::detail::is_string::value); + EXPECT_TRUE(fmt::detail::is_string::value); + EXPECT_TRUE(fmt::detail::is_string::value); + EXPECT_TRUE(fmt::detail::is_string>::value); + EXPECT_TRUE(fmt::detail::is_string>::value); EXPECT_TRUE( - fmt::internal::is_string>::value); - EXPECT_TRUE( - fmt::internal::is_string>::value); - using string_view = fmt::internal::std_string_view; + fmt::detail::is_string>::value); + using string_view = fmt::detail::std_string_view; EXPECT_TRUE(std::is_empty::value != - fmt::internal::is_string::value); - EXPECT_TRUE(fmt::internal::is_string>::value); - EXPECT_FALSE(fmt::internal::is_string::value); + fmt::detail::is_string::value); + EXPECT_TRUE(fmt::detail::is_string>::value); + EXPECT_FALSE(fmt::detail::is_string::value); } TEST(CoreTest, Format) { @@ -708,10 +703,10 @@ TEST(CoreTest, FormatTo) { TEST(CoreTest, ToStringViewForeignStrings) { using namespace my_ns; EXPECT_EQ(to_string_view(my_string("42")), "42"); - fmt::internal::type type = - fmt::internal::mapped_type_constant, - fmt::format_context>::value; - EXPECT_EQ(type, fmt::internal::type::string_type); + fmt::detail::type type = + fmt::detail::mapped_type_constant, + fmt::format_context>::value; + EXPECT_EQ(type, fmt::detail::type::string_type); } TEST(CoreTest, FormatForeignStrings) { diff --git a/test/format-impl-test.cc b/test/format-impl-test.cc index 140c134a..10e7a7ae 100644 --- a/test/format-impl-test.cc +++ b/test/format-impl-test.cc @@ -21,9 +21,9 @@ #undef max -using fmt::internal::bigint; -using fmt::internal::fp; -using fmt::internal::max_value; +using fmt::detail::bigint; +using fmt::detail::fp; +using fmt::detail::max_value; static_assert(!std::is_copy_constructible::value, ""); static_assert(!std::is_copy_assignable::value, ""); @@ -102,7 +102,7 @@ TEST(BigIntTest, Multiply) { } TEST(BigIntTest, Accumulator) { - fmt::internal::accumulator acc; + fmt::detail::accumulator acc; EXPECT_EQ(acc.lower, 0); EXPECT_EQ(acc.upper, 0); acc.upper = 12; @@ -110,7 +110,7 @@ TEST(BigIntTest, Accumulator) { EXPECT_EQ(static_cast(acc), 34); acc += 56; EXPECT_EQ(acc.lower, 90); - acc += fmt::internal::max_value(); + acc += fmt::detail::max_value(); EXPECT_EQ(acc.upper, 13); EXPECT_EQ(acc.lower, 89); acc >>= 32; @@ -262,7 +262,7 @@ TEST(FPTest, GetCachedPower) { typedef std::numeric_limits limits; for (auto exp = limits::min_exponent; exp <= limits::max_exponent; ++exp) { int dec_exp = 0; - auto fp = fmt::internal::get_cached_power(exp, dec_exp); + auto fp = fmt::detail::get_cached_power(exp, dec_exp); EXPECT_LE(exp, fp.e); int dec_exp_step = 8; EXPECT_LE(fp.e, exp + dec_exp_step * log2(10)); @@ -271,8 +271,8 @@ TEST(FPTest, GetCachedPower) { } TEST(FPTest, GetRoundDirection) { - using fmt::internal::get_round_direction; - using fmt::internal::round_direction; + using fmt::detail::get_round_direction; + using fmt::detail::round_direction; EXPECT_EQ(round_direction::down, get_round_direction(100, 50, 0)); EXPECT_EQ(round_direction::up, get_round_direction(100, 51, 0)); EXPECT_EQ(round_direction::down, get_round_direction(100, 40, 10)); @@ -295,9 +295,9 @@ TEST(FPTest, GetRoundDirection) { } TEST(FPTest, FixedHandler) { - struct handler : fmt::internal::fixed_handler { + struct handler : fmt::detail::fixed_handler { char buffer[10]; - handler(int prec = 0) : fmt::internal::fixed_handler() { + handler(int prec = 0) : fmt::detail::fixed_handler() { buf = buffer; precision = prec; } @@ -306,7 +306,7 @@ TEST(FPTest, FixedHandler) { handler().on_digit('0', 100, 99, 0, exp, false); EXPECT_THROW(handler().on_digit('0', 100, 100, 0, exp, false), assertion_failure); - namespace digits = fmt::internal::digits; + namespace digits = fmt::detail::digits; EXPECT_EQ(handler(1).on_digit('0', 100, 10, 10, exp, false), digits::done); // Check that divisor - error doesn't overflow. EXPECT_EQ(handler(1).on_digit('0', 100, 10, 101, exp, false), digits::error); @@ -318,7 +318,7 @@ TEST(FPTest, FixedHandler) { TEST(FPTest, GrisuFormatCompilesWithNonIEEEDouble) { fmt::memory_buffer buf; - format_float(0.42, -1, fmt::internal::float_specs(), buf); + format_float(0.42, -1, fmt::detail::float_specs(), buf); } template struct value_extractor { @@ -330,11 +330,11 @@ template struct value_extractor { #if FMT_USE_INT128 // Apple Clang does not define typeid for __int128_t and __uint128_t. - FMT_NORETURN T operator()(fmt::internal::int128_t) { + FMT_NORETURN T operator()(fmt::detail::int128_t) { throw std::runtime_error("invalid type __int128_t"); } - FMT_NORETURN T operator()(fmt::internal::uint128_t) { + FMT_NORETURN T operator()(fmt::detail::uint128_t) { throw std::runtime_error("invalid type __uint128_t"); } #endif @@ -342,9 +342,9 @@ template struct value_extractor { TEST(FormatTest, ArgConverter) { long long value = max_value(); - auto arg = fmt::internal::make_arg(value); + auto arg = fmt::detail::make_arg(value); fmt::visit_format_arg( - fmt::internal::arg_converter(arg, 'd'), + fmt::detail::arg_converter(arg, 'd'), arg); EXPECT_EQ(value, fmt::visit_format_arg(value_extractor(), arg)); } @@ -360,9 +360,9 @@ TEST(FormatTest, FormatNegativeNaN) { TEST(FormatTest, StrError) { char* message = nullptr; char buffer[BUFFER_SIZE]; - EXPECT_ASSERT(fmt::internal::safe_strerror(EDOM, message = nullptr, 0), + EXPECT_ASSERT(fmt::detail::safe_strerror(EDOM, message = nullptr, 0), "invalid buffer"); - EXPECT_ASSERT(fmt::internal::safe_strerror(EDOM, message = buffer, 0), + EXPECT_ASSERT(fmt::detail::safe_strerror(EDOM, message = buffer, 0), "invalid buffer"); buffer[0] = 'x'; #if defined(_GNU_SOURCE) && !defined(__COVERITY__) @@ -374,7 +374,7 @@ TEST(FormatTest, StrError) { #endif int result = - fmt::internal::safe_strerror(error_code, message = buffer, BUFFER_SIZE); + fmt::detail::safe_strerror(error_code, message = buffer, BUFFER_SIZE); EXPECT_EQ(result, 0); size_t message_size = std::strlen(message); EXPECT_GE(BUFFER_SIZE - 1u, message_size); @@ -383,9 +383,9 @@ TEST(FormatTest, StrError) { // safe_strerror never uses buffer on MinGW. #if !defined(__MINGW32__) && !defined(__sun) result = - fmt::internal::safe_strerror(error_code, message = buffer, message_size); + fmt::detail::safe_strerror(error_code, message = buffer, message_size); EXPECT_EQ(ERANGE, result); - result = fmt::internal::safe_strerror(error_code, message = buffer, 1); + result = fmt::detail::safe_strerror(error_code, message = buffer, 1); EXPECT_EQ(buffer, message); // Message should point to buffer. EXPECT_EQ(ERANGE, result); EXPECT_STREQ("", message); @@ -397,14 +397,14 @@ TEST(FormatTest, FormatErrorCode) { { fmt::memory_buffer buffer; format_to(buffer, "garbage"); - fmt::internal::format_error_code(buffer, 42, "test"); + fmt::detail::format_error_code(buffer, 42, "test"); EXPECT_EQ("test: " + msg, to_string(buffer)); } { fmt::memory_buffer buffer; std::string prefix(fmt::inline_buffer_size - msg.size() - sep.size() + 1, 'x'); - fmt::internal::format_error_code(buffer, 42, prefix); + fmt::detail::format_error_code(buffer, 42, prefix); EXPECT_EQ(msg, to_string(buffer)); } int codes[] = {42, -1}; @@ -413,32 +413,32 @@ TEST(FormatTest, FormatErrorCode) { msg = fmt::format("error {}", codes[i]); fmt::memory_buffer buffer; std::string prefix(fmt::inline_buffer_size - msg.size() - sep.size(), 'x'); - fmt::internal::format_error_code(buffer, codes[i], prefix); + fmt::detail::format_error_code(buffer, codes[i], prefix); EXPECT_EQ(prefix + sep + msg, to_string(buffer)); size_t size = fmt::inline_buffer_size; EXPECT_EQ(size, buffer.size()); buffer.resize(0); // Test with a message that doesn't fit into the buffer. prefix += 'x'; - fmt::internal::format_error_code(buffer, codes[i], prefix); + fmt::detail::format_error_code(buffer, codes[i], prefix); EXPECT_EQ(msg, to_string(buffer)); } } TEST(FormatTest, CountCodePoints) { - EXPECT_EQ( - 4, fmt::internal::count_code_points( - fmt::basic_string_view( - reinterpret_cast("ёжик")))); + EXPECT_EQ(4, + fmt::detail::count_code_points( + fmt::basic_string_view( + reinterpret_cast("ёжик")))); } -// Tests fmt::internal::count_digits for integer type Int. +// Tests fmt::detail::count_digits for integer type Int. template void test_count_digits() { - for (Int i = 0; i < 10; ++i) EXPECT_EQ(1u, fmt::internal::count_digits(i)); + for (Int i = 0; i < 10; ++i) EXPECT_EQ(1u, fmt::detail::count_digits(i)); for (Int i = 1, n = 1, end = max_value() / 10; n <= end; ++i) { n *= 10; - EXPECT_EQ(i, fmt::internal::count_digits(n - 1)); - EXPECT_EQ(i + 1, fmt::internal::count_digits(n)); + EXPECT_EQ(i, fmt::detail::count_digits(n - 1)); + EXPECT_EQ(i + 1, fmt::detail::count_digits(n)); } } @@ -449,9 +449,8 @@ TEST(UtilTest, CountDigits) { TEST(UtilTest, WriteFallbackUIntPtr) { std::string s; - fmt::internal::write_ptr( + fmt::detail::write_ptr( std::back_inserter(s), - fmt::internal::fallback_uintptr(reinterpret_cast(0xface)), - nullptr); + fmt::detail::fallback_uintptr(reinterpret_cast(0xface)), nullptr); EXPECT_EQ(s, "0xface"); } diff --git a/test/format-test.cc b/test/format-test.cc index 080618dd..dc49f3a8 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -43,7 +43,7 @@ using fmt::memory_buffer; using fmt::string_view; using fmt::wmemory_buffer; using fmt::wstring_view; -using fmt::internal::max_value; +using fmt::detail::max_value; using testing::Return; using testing::StrictMock; @@ -104,10 +104,10 @@ struct uint32_pair { }; TEST(UtilTest, BitCast) { - auto s = fmt::internal::bit_cast(uint64_t{42}); - EXPECT_EQ(fmt::internal::bit_cast(s), 42ull); - s = fmt::internal::bit_cast(uint64_t(~0ull)); - EXPECT_EQ(fmt::internal::bit_cast(s), ~0ull); + auto s = fmt::detail::bit_cast(uint64_t{42}); + EXPECT_EQ(fmt::detail::bit_cast(s), 42ull); + s = fmt::detail::bit_cast(uint64_t(~0ull)); + EXPECT_EQ(fmt::detail::bit_cast(s), ~0ull); } TEST(UtilTest, Increment) { @@ -132,18 +132,18 @@ TEST(UtilTest, ParseNonnegativeInt) { fmt::string_view s = "10000000000"; auto begin = s.begin(), end = s.end(); EXPECT_THROW_MSG( - parse_nonnegative_int(begin, end, fmt::internal::error_handler()), + parse_nonnegative_int(begin, end, fmt::detail::error_handler()), fmt::format_error, "number is too big"); s = "2147483649"; begin = s.begin(); end = s.end(); EXPECT_THROW_MSG( - parse_nonnegative_int(begin, end, fmt::internal::error_handler()), + parse_nonnegative_int(begin, end, fmt::detail::error_handler()), fmt::format_error, "number is too big"); } TEST(IteratorTest, CountingIterator) { - fmt::internal::counting_iterator it; + fmt::detail::counting_iterator it; auto prev = it++; EXPECT_EQ(prev.count(), 0); EXPECT_EQ(it.count(), 1); @@ -151,7 +151,7 @@ TEST(IteratorTest, CountingIterator) { TEST(IteratorTest, TruncatingIterator) { char* p = nullptr; - fmt::internal::truncating_iterator it(p, 3); + fmt::detail::truncating_iterator it(p, 3); auto prev = it++; EXPECT_EQ(prev.base(), p); EXPECT_EQ(it.base(), p + 1); @@ -160,7 +160,7 @@ TEST(IteratorTest, TruncatingIterator) { TEST(IteratorTest, TruncatingBackInserter) { std::string buffer; auto bi = std::back_inserter(buffer); - fmt::internal::truncating_iterator it(bi, 2); + fmt::detail::truncating_iterator it(bi, 2); *it++ = '4'; *it++ = '2'; *it++ = '1'; @@ -169,20 +169,20 @@ TEST(IteratorTest, TruncatingBackInserter) { } TEST(IteratorTest, IsOutputIterator) { - EXPECT_TRUE(fmt::internal::is_output_iterator::value); - EXPECT_FALSE(fmt::internal::is_output_iterator::value); - EXPECT_FALSE(fmt::internal::is_output_iterator::value); - EXPECT_TRUE(fmt::internal::is_output_iterator< + EXPECT_TRUE(fmt::detail::is_output_iterator::value); + EXPECT_FALSE(fmt::detail::is_output_iterator::value); + EXPECT_FALSE(fmt::detail::is_output_iterator::value); + EXPECT_TRUE(fmt::detail::is_output_iterator< std::back_insert_iterator>::value); - EXPECT_TRUE(fmt::internal::is_output_iterator::value); + EXPECT_TRUE(fmt::detail::is_output_iterator::value); EXPECT_FALSE( - fmt::internal::is_output_iterator::value); - EXPECT_FALSE(fmt::internal::is_output_iterator>::value); + fmt::detail::is_output_iterator::value); + EXPECT_FALSE(fmt::detail::is_output_iterator>::value); EXPECT_TRUE( - fmt::internal::is_output_iterator::iterator>::value); - EXPECT_FALSE(fmt::internal::is_output_iterator< - std::list::const_iterator>::value); - EXPECT_FALSE(fmt::internal::is_output_iterator::value); + fmt::detail::is_output_iterator::iterator>::value); + EXPECT_FALSE( + fmt::detail::is_output_iterator::const_iterator>::value); + EXPECT_FALSE(fmt::detail::is_output_iterator::value); } TEST(MemoryBufferTest, Ctor) { @@ -300,7 +300,7 @@ TEST(MemoryBufferTest, Grow) { void grow(size_t size) { Base::grow(size); } } buffer((Allocator(&alloc))); buffer.resize(7); - using fmt::internal::to_unsigned; + using fmt::detail::to_unsigned; for (int i = 0; i < 7; ++i) buffer[to_unsigned(i)] = i * i; EXPECT_EQ(10u, buffer.capacity()); int mem[20]; @@ -357,21 +357,21 @@ TEST(MemoryBufferTest, ExceptionInDeallocate) { } TEST(UtilTest, UTF8ToUTF16) { - fmt::internal::utf8_to_utf16 u("лошадка"); + fmt::detail::utf8_to_utf16 u("лошадка"); EXPECT_EQ(L"\x043B\x043E\x0448\x0430\x0434\x043A\x0430", u.str()); EXPECT_EQ(7, u.size()); // U+10437 { DESERET SMALL LETTER YEE } - EXPECT_EQ(L"\xD801\xDC37", fmt::internal::utf8_to_utf16("𐐷").str()); - EXPECT_THROW_MSG(fmt::internal::utf8_to_utf16("\xc3\x28"), std::runtime_error, + EXPECT_EQ(L"\xD801\xDC37", fmt::detail::utf8_to_utf16("𐐷").str()); + EXPECT_THROW_MSG(fmt::detail::utf8_to_utf16("\xc3\x28"), std::runtime_error, "invalid utf8"); - EXPECT_THROW_MSG(fmt::internal::utf8_to_utf16(fmt::string_view("л", 1)), + EXPECT_THROW_MSG(fmt::detail::utf8_to_utf16(fmt::string_view("л", 1)), std::runtime_error, "invalid utf8"); - EXPECT_EQ(L"123456", fmt::internal::utf8_to_utf16("123456").str()); + EXPECT_EQ(L"123456", fmt::detail::utf8_to_utf16("123456").str()); } TEST(UtilTest, UTF8ToUTF16EmptyString) { std::string s = ""; - fmt::internal::utf8_to_utf16 u(s.c_str()); + fmt::detail::utf8_to_utf16 u(s.c_str()); EXPECT_EQ(L"", u.str()); EXPECT_EQ(s.size(), u.size()); } @@ -534,7 +534,7 @@ TEST(FormatterTest, ManyArgs) { "argument not found"); EXPECT_THROW_MSG(TestFormat<21>::format("{21}"), format_error, "argument not found"); - enum { max_packed_args = fmt::internal::max_packed_args }; + enum { max_packed_args = fmt::detail::max_packed_args }; std::string format_str = fmt::format("{{{}}}", max_packed_args + 1); EXPECT_THROW_MSG(TestFormat::format(format_str), format_error, "argument not found"); @@ -961,7 +961,7 @@ TEST(FormatterTest, Precision) { EXPECT_THROW_MSG(format("{0:.2f}", reinterpret_cast(0xcafe)), format_error, "precision not allowed for this argument type"); - EXPECT_THROW_MSG(format("{:.{}e}", 42.0, fmt::internal::max_value()), + EXPECT_THROW_MSG(format("{:.{}e}", 42.0, fmt::detail::max_value()), format_error, "number is too big"); EXPECT_EQ("st", format("{0:.2}", "str")); @@ -1510,7 +1510,7 @@ TEST(FormatterTest, CustomFormat) { TEST(FormatterTest, CustomFormatTo) { char buf[10] = {}; auto end = - &*fmt::format_to(fmt::internal::make_checked(buf, 10), "{}", Answer()); + &*fmt::format_to(fmt::detail::make_checked(buf, 10), "{}", Answer()); EXPECT_EQ(end, buf + 2); EXPECT_STREQ(buf, "42"); } @@ -1620,7 +1620,7 @@ TEST(FormatTest, Print) { "Don't panic!"); #endif // Check that the wide print overload compiles. - if (fmt::internal::const_check(false)) fmt::print(L"test"); + if (fmt::detail::const_check(false)) fmt::print(L"test"); } TEST(FormatTest, Variadic) { @@ -1631,9 +1631,9 @@ TEST(FormatTest, Variadic) { TEST(FormatTest, Dynamic) { typedef fmt::format_context ctx; std::vector> args; - args.emplace_back(fmt::internal::make_arg(42)); - args.emplace_back(fmt::internal::make_arg("abc1")); - args.emplace_back(fmt::internal::make_arg(1.5f)); + args.emplace_back(fmt::detail::make_arg(42)); + args.emplace_back(fmt::detail::make_arg("abc1")); + args.emplace_back(fmt::detail::make_arg(1.5f)); std::string result = fmt::vformat( "{} and {} and {}", @@ -1808,7 +1808,7 @@ TEST(FormatTest, StrongEnum) { using buffer_range = fmt::buffer_range; class mock_arg_formatter - : public fmt::internal::arg_formatter_base { + : public fmt::detail::arg_formatter_base { private: #if FMT_USE_INT128 MOCK_METHOD1(call, void(__int128_t value)); @@ -1817,24 +1817,24 @@ class mock_arg_formatter #endif public: - typedef fmt::internal::arg_formatter_base base; + typedef fmt::detail::arg_formatter_base base; typedef buffer_range range; mock_arg_formatter(fmt::format_context& ctx, fmt::format_parse_context*, fmt::format_specs* s = nullptr) - : base(fmt::internal::get_container(ctx.out()), s, ctx.locale()) { + : base(fmt::detail::get_container(ctx.out()), s, ctx.locale()) { EXPECT_CALL(*this, call(42)); } template - typename std::enable_if::value, iterator>::type + typename std::enable_if::value, iterator>::type operator()(T value) { call(value); return base::operator()(value); } template - typename std::enable_if::value, iterator>::type + typename std::enable_if::value, iterator>::type operator()(T value) { return base::operator()(value); } @@ -2020,7 +2020,7 @@ struct test_arg_id_handler { template FMT_CONSTEXPR test_arg_id_handler parse_arg_id(const char (&s)[N]) { test_arg_id_handler h; - fmt::internal::parse_arg_id(s, s + N, h); + fmt::detail::parse_arg_id(s, s + N, h); return h; } @@ -2041,9 +2041,9 @@ struct test_format_specs_handler { fmt::align_t align = fmt::align::none; char fill = 0; int width = 0; - fmt::internal::arg_ref width_ref; + fmt::detail::arg_ref width_ref; int precision = 0; - fmt::internal::arg_ref precision_ref; + fmt::detail::arg_ref precision_ref; char type = 0; // Workaround for MSVC2017 bug that results in "expression did not evaluate @@ -2069,12 +2069,12 @@ struct test_format_specs_handler { FMT_CONSTEXPR void on_zero() { res = ZERO; } FMT_CONSTEXPR void on_width(int w) { width = w; } - FMT_CONSTEXPR void on_dynamic_width(fmt::internal::auto_id) {} + FMT_CONSTEXPR void on_dynamic_width(fmt::detail::auto_id) {} FMT_CONSTEXPR void on_dynamic_width(int index) { width_ref = index; } FMT_CONSTEXPR void on_dynamic_width(string_view) {} FMT_CONSTEXPR void on_precision(int p) { precision = p; } - FMT_CONSTEXPR void on_dynamic_precision(fmt::internal::auto_id) {} + FMT_CONSTEXPR void on_dynamic_precision(fmt::detail::auto_id) {} FMT_CONSTEXPR void on_dynamic_precision(int index) { precision_ref = index; } FMT_CONSTEXPR void on_dynamic_precision(string_view) {} @@ -2086,7 +2086,7 @@ struct test_format_specs_handler { template FMT_CONSTEXPR test_format_specs_handler parse_test_specs(const char (&s)[N]) { test_format_specs_handler h; - fmt::internal::parse_format_specs(s, s + N, h); + fmt::detail::parse_format_specs(s, s + N, h); return h; } @@ -2130,7 +2130,7 @@ struct test_context { template FMT_CONSTEXPR fmt::basic_format_arg arg(Id id) { - return fmt::internal::make_arg(id); + return fmt::detail::make_arg(id); } void on_error(const char*) {} @@ -2143,7 +2143,7 @@ FMT_CONSTEXPR fmt::format_specs parse_specs(const char (&s)[N]) { auto specs = fmt::format_specs(); auto parse_ctx = test_parse_context(); auto ctx = test_context(); - fmt::internal::specs_handler h( + fmt::detail::specs_handler h( specs, parse_ctx, ctx); parse_format_specs(s, s + N, h); return specs; @@ -2167,11 +2167,11 @@ TEST(FormatTest, ConstexprSpecsHandler) { } template -FMT_CONSTEXPR fmt::internal::dynamic_format_specs parse_dynamic_specs( +FMT_CONSTEXPR fmt::detail::dynamic_format_specs parse_dynamic_specs( const char (&s)[N]) { - fmt::internal::dynamic_format_specs specs; + fmt::detail::dynamic_format_specs specs; test_parse_context ctx{}; - fmt::internal::dynamic_specs_handler h(specs, ctx); + fmt::detail::dynamic_specs_handler h(specs, ctx); parse_format_specs(s, s + N, h); return specs; } @@ -2195,8 +2195,8 @@ TEST(FormatTest, ConstexprDynamicSpecsHandler) { template FMT_CONSTEXPR test_format_specs_handler check_specs(const char (&s)[N]) { - fmt::internal::specs_checker checker( - test_format_specs_handler(), fmt::internal::type::double_type); + fmt::detail::specs_checker checker( + test_format_specs_handler(), fmt::detail::type::double_type); parse_format_specs(s, s + N, checker); return checker; } @@ -2238,7 +2238,7 @@ struct test_format_string_handler { template FMT_CONSTEXPR bool parse_string(const char (&s)[N]) { test_format_string_handler h; - fmt::internal::parse_format_string(fmt::string_view(s, N - 1), h); + fmt::detail::parse_format_string(fmt::string_view(s, N - 1), h); return !h.error; } @@ -2283,9 +2283,9 @@ template FMT_CONSTEXPR bool test_error(const char* fmt, const char* expected_error) { const char* actual_error = nullptr; string_view s(fmt, len(fmt)); - fmt::internal::format_string_checker - checker(s, test_error_handler(actual_error)); - fmt::internal::parse_format_string(s, checker); + fmt::detail::format_string_checker checker( + s, test_error_handler(actual_error)); + fmt::detail::parse_format_string(s, checker); return equal(actual_error, expected_error); } @@ -2299,7 +2299,7 @@ TEST(FormatTest, FormatStringErrors) { EXPECT_ERROR_NOARGS("}", "unmatched '}' in format string"); EXPECT_ERROR("{0:s", "unknown format specifier", Date); # if !FMT_MSC_VER || FMT_MSC_VER >= 1916 - // This causes an internal compiler error in MSVC2017. + // This causes an detail compiler error in MSVC2017. EXPECT_ERROR("{:{<}", "invalid fill character '{'", int); EXPECT_ERROR("{:10000000000}", "number is too big", int); EXPECT_ERROR("{:.10000000000}", "number is too big", int); @@ -2358,7 +2358,7 @@ TEST(FormatTest, FormatStringErrors) { TEST(FormatTest, VFormatTo) { typedef fmt::format_context context; - fmt::basic_format_arg arg = fmt::internal::make_arg(42); + fmt::basic_format_arg arg = fmt::detail::make_arg(42); fmt::basic_format_args args(&arg, 1); std::string s; fmt::vformat_to(std::back_inserter(s), "{}", args); @@ -2368,7 +2368,7 @@ TEST(FormatTest, VFormatTo) { EXPECT_EQ("42", s); typedef fmt::wformat_context wcontext; - fmt::basic_format_arg warg = fmt::internal::make_arg(42); + fmt::basic_format_arg warg = fmt::detail::make_arg(42); fmt::basic_format_args wargs(&warg, 1); std::wstring w; fmt::vformat_to(std::back_inserter(w), L"{}", wargs); @@ -2396,7 +2396,7 @@ TEST(FormatTest, EmphasisNonHeaderOnly) { } TEST(FormatTest, CharTraitsIsNotAmbiguous) { - // Test that we don't inject internal names into the std namespace. + // Test that we don't inject detail names into the std namespace. using namespace std; char_traits::char_type c; (void)c; @@ -2434,13 +2434,12 @@ template std::string from_u8str(const S& str) { } TEST(FormatTest, FormatUTF8Precision) { - using str_type = std::basic_string; - str_type format( - reinterpret_cast(u8"{:.4}")); - str_type str(reinterpret_cast( + using str_type = std::basic_string; + str_type format(reinterpret_cast(u8"{:.4}")); + str_type str(reinterpret_cast( u8"caf\u00e9s")); // cafés auto result = fmt::format(format, str); - EXPECT_EQ(fmt::internal::count_code_points(result), 4); + EXPECT_EQ(fmt::detail::count_code_points(result), 4); EXPECT_EQ(result.size(), 5); EXPECT_EQ(from_u8str(result), from_u8str(str.substr(0, 5))); } diff --git a/test/locale-test.cc b/test/locale-test.cc index a17ca004..a2209a75 100644 --- a/test/locale-test.cc +++ b/test/locale-test.cc @@ -9,7 +9,7 @@ #include "gmock.h" -using fmt::internal::max_value; +using fmt::detail::max_value; #ifndef FMT_STATIC_THOUSANDS_SEPARATOR template struct numpunct : std::numpunct { diff --git a/test/os-test.cc b/test/os-test.cc index 009d9775..d1530e5a 100644 --- a/test/os-test.cc +++ b/test/os-test.cc @@ -27,14 +27,14 @@ using fmt::error_code; TEST(UtilTest, UTF16ToUTF8) { std::string s = "ёжик"; - fmt::internal::utf16_to_utf8 u(L"\x0451\x0436\x0438\x043A"); + fmt::detail::utf16_to_utf8 u(L"\x0451\x0436\x0438\x043A"); EXPECT_EQ(s, u.str()); EXPECT_EQ(s.size(), u.size()); } TEST(UtilTest, UTF16ToUTF8EmptyString) { std::string s = ""; - fmt::internal::utf16_to_utf8 u(L""); + fmt::detail::utf16_to_utf8 u(L""); EXPECT_EQ(s, u.str()); EXPECT_EQ(s.size(), u.size()); } @@ -44,7 +44,7 @@ void check_utf_conversion_error( const char* message, fmt::basic_string_view str = fmt::basic_string_view(0, 1)) { fmt::memory_buffer out; - fmt::internal::format_windows_error(out, ERROR_INVALID_PARAMETER, message); + fmt::detail::format_windows_error(out, ERROR_INVALID_PARAMETER, message); fmt::system_error error(0, ""); try { (Converter)(str); @@ -56,12 +56,12 @@ void check_utf_conversion_error( } TEST(UtilTest, UTF16ToUTF8Error) { - check_utf_conversion_error( + check_utf_conversion_error( "cannot convert string from UTF-16 to UTF-8"); } TEST(UtilTest, UTF16ToUTF8Convert) { - fmt::internal::utf16_to_utf8 u; + fmt::detail::utf16_to_utf8 u; EXPECT_EQ(ERROR_INVALID_PARAMETER, u.convert(fmt::wstring_view(0, 1))); EXPECT_EQ(ERROR_INVALID_PARAMETER, u.convert(fmt::wstring_view(L"foo", INT_MAX + 1u))); @@ -74,17 +74,16 @@ TEST(UtilTest, FormatWindowsError) { 0, ERROR_FILE_EXISTS, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast(&message), 0, 0); - fmt::internal::utf16_to_utf8 utf8_message(message); + fmt::detail::utf16_to_utf8 utf8_message(message); LocalFree(message); fmt::memory_buffer actual_message; - fmt::internal::format_windows_error(actual_message, ERROR_FILE_EXISTS, - "test"); + fmt::detail::format_windows_error(actual_message, ERROR_FILE_EXISTS, "test"); EXPECT_EQ(fmt::format("test: {}", utf8_message.str()), fmt::to_string(actual_message)); actual_message.resize(0); - auto max_size = fmt::internal::max_value(); - fmt::internal::format_windows_error(actual_message, ERROR_FILE_EXISTS, - fmt::string_view(0, max_size)); + auto max_size = fmt::detail::max_value(); + fmt::detail::format_windows_error(actual_message, ERROR_FILE_EXISTS, + fmt::string_view(0, max_size)); EXPECT_EQ(fmt::format("error {}", ERROR_FILE_EXISTS), fmt::to_string(actual_message)); } @@ -104,11 +103,11 @@ TEST(UtilTest, FormatLongWindowsError) { reinterpret_cast(&message), 0, 0) == 0) { return; } - fmt::internal::utf16_to_utf8 utf8_message(message); + fmt::detail::utf16_to_utf8 utf8_message(message); LocalFree(message); fmt::memory_buffer actual_message; - fmt::internal::format_windows_error(actual_message, provisioning_not_allowed, - "test"); + fmt::detail::format_windows_error(actual_message, provisioning_not_allowed, + "test"); EXPECT_EQ(fmt::format("test: {}", utf8_message.str()), fmt::to_string(actual_message)); } @@ -121,14 +120,14 @@ TEST(UtilTest, WindowsError) { error = e; } fmt::memory_buffer message; - fmt::internal::format_windows_error(message, ERROR_FILE_EXISTS, "test error"); + fmt::detail::format_windows_error(message, ERROR_FILE_EXISTS, "test error"); EXPECT_EQ(to_string(message), error.what()); EXPECT_EQ(ERROR_FILE_EXISTS, error.error_code()); } TEST(UtilTest, ReportWindowsError) { fmt::memory_buffer out; - fmt::internal::format_windows_error(out, ERROR_FILE_EXISTS, "test error"); + fmt::detail::format_windows_error(out, ERROR_FILE_EXISTS, "test error"); out.push_back('\n'); EXPECT_WRITE(stderr, fmt::report_windows_error(ERROR_FILE_EXISTS, "test error"), diff --git a/test/ostream-test.cc b/test/ostream-test.cc index 1b777ab4..a6cb07f5 100644 --- a/test/ostream-test.cc +++ b/test/ostream-test.cc @@ -74,12 +74,12 @@ struct test_arg_formatter : fmt::arg_formatter { TEST(OStreamTest, CustomArg) { fmt::memory_buffer buffer; - fmt::internal::buffer& base = buffer; + fmt::detail::buffer& base = buffer; fmt::format_context ctx(std::back_inserter(base), fmt::format_args()); fmt::format_specs spec; test_arg_formatter af(ctx, spec); fmt::visit_format_arg( - af, fmt::internal::make_arg(streamable_enum())); + af, fmt::detail::make_arg(streamable_enum())); EXPECT_EQ("streamable_enum", std::string(buffer.data(), buffer.size())); } @@ -140,16 +140,16 @@ TEST(OStreamTest, WriteToOStream) { fmt::memory_buffer buffer; const char* foo = "foo"; buffer.append(foo, foo + std::strlen(foo)); - fmt::internal::write(os, buffer); + fmt::detail::write(os, buffer); EXPECT_EQ("foo", os.str()); } TEST(OStreamTest, WriteToOStreamMaxSize) { - size_t max_size = fmt::internal::max_value(); - std::streamsize max_streamsize = fmt::internal::max_value(); - if (max_size <= fmt::internal::to_unsigned(max_streamsize)) return; + size_t max_size = fmt::detail::max_value(); + std::streamsize max_streamsize = fmt::detail::max_value(); + if (max_size <= fmt::detail::to_unsigned(max_streamsize)) return; - struct test_buffer : fmt::internal::buffer { + struct test_buffer : fmt::detail::buffer { explicit test_buffer(size_t size) { resize(size); } void grow(size_t) {} } buffer(max_size); @@ -171,13 +171,13 @@ TEST(OStreamTest, WriteToOStreamMaxSize) { typedef std::make_unsigned::type ustreamsize; ustreamsize size = max_size; do { - auto n = std::min(size, fmt::internal::to_unsigned(max_streamsize)); + auto n = std::min(size, fmt::detail::to_unsigned(max_streamsize)); EXPECT_CALL(streambuf, xsputn(data, static_cast(n))) .WillOnce(testing::Return(max_streamsize)); data += n; size -= n; } while (size != 0); - fmt::internal::write(os, buffer); + fmt::detail::write(os, buffer); } TEST(OStreamTest, Join) { @@ -275,7 +275,7 @@ TEST(OStreamTest, FormatExplicitlyConvertibleToStringLike) { #ifdef FMT_USE_STRING_VIEW struct explicitly_convertible_to_std_string_view { - explicit operator fmt::internal::std_string_view() const { + explicit operator fmt::detail::std_string_view() const { return {"foo", 3u}; } }; diff --git a/test/posix-mock-test.cc b/test/posix-mock-test.cc index c8c04d41..eb85756d 100644 --- a/test/posix-mock-test.cc +++ b/test/posix-mock-test.cc @@ -261,8 +261,8 @@ TEST(FileTest, Size) { EXPECT_EQ(content.size(), static_cast(f.size())); # ifdef _WIN32 fmt::memory_buffer message; - fmt::internal::format_windows_error(message, ERROR_ACCESS_DENIED, - "cannot get file size"); + fmt::detail::format_windows_error(message, ERROR_ACCESS_DENIED, + "cannot get file size"); fstat_sim = ERROR; EXPECT_THROW_MSG(f.size(), fmt::windows_error, fmt::to_string(message)); fstat_sim = NONE; diff --git a/test/printf-test.cc b/test/printf-test.cc index b6a4acd5..5a586797 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -17,7 +17,7 @@ using fmt::format; using fmt::format_error; -using fmt::internal::max_value; +using fmt::detail::max_value; const unsigned BIG_NUM = INT_MAX + 1u; @@ -300,7 +300,7 @@ void TestLength(const char* length_spec, U value) { unsigned long long unsigned_value = 0; // Apply integer promotion to the argument. unsigned long long max = max_value(); - using fmt::internal::const_check; + using fmt::detail::const_check; if (const_check(max <= static_cast(max_value()))) { signed_value = static_cast(value); unsigned_value = static_cast(value); diff --git a/test/scan-test.cc b/test/scan-test.cc index 67f2fdd8..962de54c 100644 --- a/test/scan-test.cc +++ b/test/scan-test.cc @@ -75,7 +75,7 @@ template <> struct scanner { if (it != ctx.end() && *it == ':') ++it; auto end = it; while (end != ctx.end() && *end != '}') ++end; - format.reserve(internal::to_unsigned(end - it + 1)); + format.reserve(detail::to_unsigned(end - it + 1)); format.append(it, end); format.push_back('\0'); return end; diff --git a/test/scan.h b/test/scan.h index af421bce..83f7bfd5 100644 --- a/test/scan.h +++ b/test/scan.h @@ -31,7 +31,7 @@ class scan_parse_context { FMT_CONSTEXPR iterator end() const { return format_.end(); } void advance_to(iterator it) { - format_.remove_prefix(internal::to_unsigned(it - begin())); + format_.remove_prefix(detail::to_unsigned(it - begin())); } }; @@ -48,11 +48,11 @@ struct scan_context { iterator end() const { return begin() + input_.size(); } void advance_to(iterator it) { - input_.remove_prefix(internal::to_unsigned(it - begin())); + input_.remove_prefix(detail::to_unsigned(it - begin())); } }; -namespace internal { +namespace detail { enum class scan_type { none_type, int_type, @@ -107,20 +107,20 @@ class scan_arg { ctx.advance_to(s.scan(*static_cast(arg), ctx)); } }; -} // namespace internal +} // namespace detail struct scan_args { int size; - const internal::scan_arg* data; + const detail::scan_arg* data; template - scan_args(const std::array& store) + scan_args(const std::array& store) : size(N), data(store.data()) { static_assert(N < INT_MAX, "too many arguments"); } }; -namespace internal { +namespace detail { struct scan_handler : error_handler { private: @@ -215,17 +215,17 @@ struct scan_handler : error_handler { return parse_ctx_.begin(); } }; -} // namespace internal +} // namespace detail template -std::array make_scan_args(Args&... args) { +std::array make_scan_args(Args&... args) { return {{args...}}; } string_view::iterator vscan(string_view input, string_view format_str, scan_args args) { - internal::scan_handler h(format_str, input, args); - internal::parse_format_string(format_str, h); + detail::scan_handler h(format_str, input, args); + detail::parse_format_string(format_str, h); return input.begin() + (h.pos() - &*input.begin()); } diff --git a/test/std-format-test.cc b/test/std-format-test.cc index 69ee4262..c4fb5a27 100644 --- a/test/std-format-test.cc +++ b/test/std-format-test.cc @@ -124,7 +124,7 @@ template <> struct std::formatter { if constexpr (!is_integral_v || is_same_v) throw format_error("width is not integral"); // else if (value < 0 || value > numeric_limits::max()) - else if (fmt::internal::is_negative(value) || + else if (fmt::detail::is_negative(value) || value > numeric_limits::max()) throw format_error("invalid width"); else