internal -> detail (#1538)
This commit is contained in:
parent
963ee08310
commit
8069265373
@ -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<FromRep, FromPeriod> from,
|
||||
}
|
||||
// multiply with Factor::num without overflow or underflow
|
||||
if (Factor::num != 1) {
|
||||
const auto max1 = internal::max_value<IntermediateRep>() / Factor::num;
|
||||
const auto max1 = detail::max_value<IntermediateRep>() / Factor::num;
|
||||
if (count > max1) {
|
||||
ec = 1;
|
||||
return {};
|
||||
@ -269,7 +269,7 @@ To safe_duration_cast(std::chrono::duration<FromRep, FromPeriod> from,
|
||||
|
||||
// multiply with Factor::num without overflow or underflow
|
||||
if (Factor::num != 1) {
|
||||
constexpr auto max1 = internal::max_value<IntermediateRep>() /
|
||||
constexpr auto max1 = detail::max_value<IntermediateRep>() /
|
||||
static_cast<IntermediateRep>(Factor::num);
|
||||
if (count > max1) {
|
||||
ec = 1;
|
||||
@ -306,12 +306,12 @@ To safe_duration_cast(std::chrono::duration<FromRep, FromPeriod> 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 <typename Char> struct formatter<std::tm, Char> {
|
||||
template <typename ParseContext>
|
||||
@ -405,7 +405,7 @@ template <typename Char> struct formatter<std::tm, Char> {
|
||||
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 <typename Char> struct formatter<std::tm, Char> {
|
||||
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 <typename Char> struct formatter<std::tm, Char> {
|
||||
basic_memory_buffer<Char> tm_format;
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
namespace detail {
|
||||
template <typename Period> 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<int> n =
|
||||
to_unsigned(to_nonnegative_int(value, max_value<int>()));
|
||||
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<char_type>(out, n, num_digits);
|
||||
}
|
||||
@ -1009,14 +1009,14 @@ struct chrono_formatter {
|
||||
out = format_duration_unit<char_type, Period>(out);
|
||||
}
|
||||
};
|
||||
} // namespace internal
|
||||
} // namespace detail
|
||||
|
||||
template <typename Rep, typename Period, typename Char>
|
||||
struct formatter<std::chrono::duration<Rep, Period>, Char> {
|
||||
private:
|
||||
basic_format_specs<Char> specs;
|
||||
int precision;
|
||||
using arg_ref_type = internal::arg_ref<Char>;
|
||||
using arg_ref_type = detail::arg_ref<Char>;
|
||||
arg_ref_type width_ref;
|
||||
arg_ref_type precision_ref;
|
||||
mutable basic_string_view<Char> format_str;
|
||||
@ -1037,7 +1037,7 @@ struct formatter<std::chrono::duration<Rep, Period>, 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<std::chrono::duration<Rep, Period>, 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<Rep>::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<std::chrono::duration<Rep, Period>, Char> {
|
||||
-> decltype(ctx.begin()) {
|
||||
auto range = do_parse(ctx);
|
||||
format_str = basic_string_view<Char>(
|
||||
&*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<std::chrono::duration<Rep, Period>, Char> {
|
||||
// is not specified.
|
||||
basic_memory_buffer<Char> buf;
|
||||
auto out = std::back_inserter(buf);
|
||||
internal::handle_dynamic_spec<internal::width_checker>(specs.width,
|
||||
width_ref, ctx);
|
||||
internal::handle_dynamic_spec<internal::precision_checker>(
|
||||
precision, precision_ref, ctx);
|
||||
detail::handle_dynamic_spec<detail::width_checker>(specs.width, width_ref,
|
||||
ctx);
|
||||
detail::handle_dynamic_spec<detail::precision_checker>(precision,
|
||||
precision_ref, ctx);
|
||||
if (begin == end || *begin == '}') {
|
||||
out = internal::format_duration_value<Char>(out, d.count(), precision);
|
||||
internal::format_duration_unit<Char, Period>(out);
|
||||
out = detail::format_duration_value<Char>(out, d.count(), precision);
|
||||
detail::format_duration_unit<Char, Period>(out);
|
||||
} else {
|
||||
internal::chrono_formatter<FormatContext, decltype(out), Rep, Period> f(
|
||||
detail::chrono_formatter<FormatContext, decltype(out), Rep, Period> f(
|
||||
ctx, out, d);
|
||||
f.precision = precision;
|
||||
parse_chrono_format(begin, end, f);
|
||||
}
|
||||
return internal::write(
|
||||
return detail::write(
|
||||
ctx.out(), basic_string_view<Char>(buf.data(), buf.size()), specs);
|
||||
}
|
||||
};
|
||||
|
@ -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<uint8_t>(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 <typename Char> 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 <typename Char> struct ansi_color_escape {
|
||||
|
||||
template <typename Char>
|
||||
FMT_CONSTEXPR ansi_color_escape<Char> make_foreground_color(
|
||||
internal::color_type foreground) FMT_NOEXCEPT {
|
||||
return ansi_color_escape<Char>(foreground, internal::data::foreground_color);
|
||||
detail::color_type foreground) FMT_NOEXCEPT {
|
||||
return ansi_color_escape<Char>(foreground, detail::data::foreground_color);
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
FMT_CONSTEXPR ansi_color_escape<Char> make_background_color(
|
||||
internal::color_type background) FMT_NOEXCEPT {
|
||||
return ansi_color_escape<Char>(background, internal::data::background_color);
|
||||
detail::color_type background) FMT_NOEXCEPT {
|
||||
return ansi_color_escape<Char>(background, detail::data::background_color);
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
@ -455,11 +455,11 @@ inline void fputs<wchar_t>(const wchar_t* chars, FILE* stream) FMT_NOEXCEPT {
|
||||
}
|
||||
|
||||
template <typename Char> 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<wchar_t>(FILE* stream) FMT_NOEXCEPT {
|
||||
fputs(internal::data::wreset_color, stream);
|
||||
fputs(detail::data::wreset_color, stream);
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
@ -476,33 +476,31 @@ void vformat_to(basic_memory_buffer<Char>& buf, const text_style& ts,
|
||||
bool has_style = false;
|
||||
if (ts.has_emphasis()) {
|
||||
has_style = true;
|
||||
auto emphasis = internal::make_emphasis<Char>(ts.get_emphasis());
|
||||
auto emphasis = detail::make_emphasis<Char>(ts.get_emphasis());
|
||||
buf.append(emphasis.begin(), emphasis.end());
|
||||
}
|
||||
if (ts.has_foreground()) {
|
||||
has_style = true;
|
||||
auto foreground =
|
||||
internal::make_foreground_color<Char>(ts.get_foreground());
|
||||
auto foreground = detail::make_foreground_color<Char>(ts.get_foreground());
|
||||
buf.append(foreground.begin(), foreground.end());
|
||||
}
|
||||
if (ts.has_background()) {
|
||||
has_style = true;
|
||||
auto background =
|
||||
internal::make_background_color<Char>(ts.get_background());
|
||||
auto background = detail::make_background_color<Char>(ts.get_background());
|
||||
buf.append(background.begin(), background.end());
|
||||
}
|
||||
internal::vformat_to(buf, format_str, args);
|
||||
if (has_style) internal::reset_color<Char>(buf);
|
||||
detail::vformat_to(buf, format_str, args);
|
||||
if (has_style) detail::reset_color<Char>(buf);
|
||||
}
|
||||
} // namespace internal
|
||||
} // namespace detail
|
||||
|
||||
template <typename S, typename Char = char_t<S>>
|
||||
void vprint(std::FILE* f, const text_style& ts, const S& format,
|
||||
basic_format_args<buffer_context<Char>> args) {
|
||||
basic_memory_buffer<Char> 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 <typename S, typename... Args,
|
||||
FMT_ENABLE_IF(internal::is_string<S>::value)>
|
||||
FMT_ENABLE_IF(detail::is_string<S>::value)>
|
||||
void print(std::FILE* f, const text_style& ts, const S& format_str,
|
||||
const Args&... args) {
|
||||
internal::check_format_string<Args...>(format_str);
|
||||
detail::check_format_string<Args...>(format_str);
|
||||
using context = buffer_context<char_t<S>>;
|
||||
format_arg_store<context, Args...> as{args...};
|
||||
vprint(f, ts, format_str, basic_format_args<context>(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 <typename S, typename... Args,
|
||||
FMT_ENABLE_IF(internal::is_string<S>::value)>
|
||||
FMT_ENABLE_IF(detail::is_string<S>::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<Char> vformat(
|
||||
const text_style& ts, const S& format_str,
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
||||
basic_memory_buffer<Char> 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 <typename S, typename... Args, typename Char = char_t<S>>
|
||||
inline std::basic_string<Char> format(const text_style& ts, const S& format_str,
|
||||
const Args&... args) {
|
||||
return vformat(ts, to_string_view(format_str),
|
||||
internal::make_args_checked<Args...>(format_str, args...));
|
||||
detail::make_args_checked<Args...>(format_str, args...));
|
||||
}
|
||||
|
||||
FMT_END_NAMESPACE
|
||||
|
@ -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<Context> args)
|
||||
|
||||
case format_part_t::kind::arg_index:
|
||||
advance_to(parse_ctx, part.arg_id_end);
|
||||
internal::format_arg<Range>(parse_ctx, ctx, value.arg_index);
|
||||
detail::format_arg<Range>(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<Range>(parse_ctx, ctx, value.str);
|
||||
detail::format_arg<Range>(parse_ctx, ctx, value.str);
|
||||
break;
|
||||
|
||||
case format_part_t::kind::replacement: {
|
||||
@ -240,7 +240,7 @@ struct basic_compiled_format {};
|
||||
template <typename S, typename = void>
|
||||
struct compiled_format_base : basic_compiled_format {
|
||||
using char_type = char_t<S>;
|
||||
using parts_container = std::vector<internal::format_part<char_type>>;
|
||||
using parts_container = std::vector<detail::format_part<char_type>>;
|
||||
|
||||
parts_container compiled_parts;
|
||||
|
||||
@ -305,7 +305,7 @@ struct compiled_format_base<S, enable_if_t<is_compile_string<S>::value>>
|
||||
const parts_container& parts() const {
|
||||
static FMT_CONSTEXPR_DECL const auto compiled_parts =
|
||||
compile_to_parts<char_type, num_format_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 <typename Char, typename OutputIt>
|
||||
OutputIt format_default(OutputIt out, double value) {
|
||||
return internal::write(out, value);
|
||||
return detail::write(out, value);
|
||||
}
|
||||
|
||||
template <typename Char, typename OutputIt>
|
||||
@ -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 <typename... Args, typename S,
|
||||
constexpr auto compile(S format_str) {
|
||||
constexpr basic_string_view<typename S::char_type> 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<internal::type_list<Args...>, 0, 0>(
|
||||
detail::compile_format_string<detail::type_list<Args...>, 0, 0>(
|
||||
format_str);
|
||||
if constexpr (std::is_same<remove_cvref_t<decltype(result)>,
|
||||
internal::unknown_format>()) {
|
||||
return internal::compiled_format<S, Args...>(to_string_view(format_str));
|
||||
detail::unknown_format>()) {
|
||||
return detail::compiled_format<S, Args...>(to_string_view(format_str));
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
@ -518,7 +518,7 @@ constexpr auto compile(S format_str) {
|
||||
|
||||
template <typename CompiledFormat, typename... Args,
|
||||
typename Char = typename CompiledFormat::char_type,
|
||||
FMT_ENABLE_IF(internal::is_compiled_format<CompiledFormat>::value)>
|
||||
FMT_ENABLE_IF(detail::is_compiled_format<CompiledFormat>::value)>
|
||||
std::basic_string<Char> format(const CompiledFormat& cf, const Args&... args) {
|
||||
basic_memory_buffer<Char> buffer;
|
||||
cf.format(std::back_inserter(buffer), args...);
|
||||
@ -526,7 +526,7 @@ std::basic_string<Char> format(const CompiledFormat& cf, const Args&... args) {
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename CompiledFormat, typename... Args,
|
||||
FMT_ENABLE_IF(internal::is_compiled_format<CompiledFormat>::value)>
|
||||
FMT_ENABLE_IF(detail::is_compiled_format<CompiledFormat>::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 <typename... Args, typename S,
|
||||
FMT_ENABLE_IF(is_compile_string<S>::value)>
|
||||
constexpr auto compile(S format_str) -> internal::compiled_format<S, Args...> {
|
||||
return internal::compiled_format<S, Args...>(to_string_view(format_str));
|
||||
constexpr auto compile(S format_str) -> detail::compiled_format<S, Args...> {
|
||||
return detail::compiled_format<S, Args...>(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<S, Args...> {
|
||||
// Compiles the format string which must be a string literal.
|
||||
template <typename... Args, typename Char, size_t N>
|
||||
auto compile(const Char (&format_str)[N])
|
||||
-> internal::compiled_format<const Char*, Args...> {
|
||||
return internal::compiled_format<const Char*, Args...>(
|
||||
-> detail::compiled_format<const Char*, Args...> {
|
||||
return detail::compiled_format<const Char*, Args...>(
|
||||
basic_string_view<Char>(format_str, N - 1));
|
||||
}
|
||||
|
||||
template <typename CompiledFormat, typename... Args,
|
||||
typename Char = typename CompiledFormat::char_type,
|
||||
FMT_ENABLE_IF(std::is_base_of<internal::basic_compiled_format,
|
||||
FMT_ENABLE_IF(std::is_base_of<detail::basic_compiled_format,
|
||||
CompiledFormat>::value)>
|
||||
std::basic_string<Char> format(const CompiledFormat& cf, const Args&... args) {
|
||||
basic_memory_buffer<Char> buffer;
|
||||
using range = buffer_range<Char>;
|
||||
using context = buffer_context<Char>;
|
||||
internal::cf::vformat_to<context>(range(buffer), cf,
|
||||
make_format_args<context>(args...));
|
||||
detail::cf::vformat_to<context>(range(buffer), cf,
|
||||
make_format_args<context>(args...));
|
||||
return to_string(buffer);
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename CompiledFormat, typename... Args,
|
||||
FMT_ENABLE_IF(std::is_base_of<internal::basic_compiled_format,
|
||||
FMT_ENABLE_IF(std::is_base_of<detail::basic_compiled_format,
|
||||
CompiledFormat>::value)>
|
||||
OutputIt format_to(OutputIt out, const CompiledFormat& cf,
|
||||
const Args&... args) {
|
||||
using char_type = typename CompiledFormat::char_type;
|
||||
using range = internal::output_range<OutputIt, char_type>;
|
||||
using range = detail::output_range<OutputIt, char_type>;
|
||||
using context = format_context_t<OutputIt, char_type>;
|
||||
return internal::cf::vformat_to<context>(range(out), cf,
|
||||
make_format_args<context>(args...));
|
||||
return detail::cf::vformat_to<context>(range(out), cf,
|
||||
make_format_args<context>(args...));
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename CompiledFormat, typename... Args,
|
||||
FMT_ENABLE_IF(
|
||||
internal::is_output_iterator<OutputIt>::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<OutputIt>::value&& std::is_base_of<
|
||||
detail::basic_compiled_format, CompiledFormat>::value)>
|
||||
format_to_n_result<OutputIt> format_to_n(OutputIt out, size_t n,
|
||||
const CompiledFormat& cf,
|
||||
const Args&... args) {
|
||||
auto it =
|
||||
format_to(internal::truncating_iterator<OutputIt>(out, n), cf, args...);
|
||||
format_to(detail::truncating_iterator<OutputIt>(out, n), cf, args...);
|
||||
return {it.base(), it.count()};
|
||||
}
|
||||
|
||||
template <typename CompiledFormat, typename... Args>
|
||||
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
|
||||
|
@ -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 <typename... Ts>
|
||||
using void_t = typename internal::void_t_impl<Ts...>::type;
|
||||
using void_t = typename detail::void_t_impl<Ts...>::type;
|
||||
|
||||
/**
|
||||
An implementation of ``std::basic_string_view`` for pre-C++17. It provides a
|
||||
@ -385,9 +387,8 @@ template <typename Char> class basic_string_view {
|
||||
: data_(s.data()),
|
||||
size_(s.size()) {}
|
||||
|
||||
template <
|
||||
typename S,
|
||||
FMT_ENABLE_IF(std::is_same<S, internal::std_string_view<Char>>::value)>
|
||||
template <typename S, FMT_ENABLE_IF(std::is_same<
|
||||
S, detail::std_string_view<Char>>::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<wchar_t>;
|
||||
template <typename T> struct is_char : std::false_type {};
|
||||
template <> struct is_char<char> : std::true_type {};
|
||||
template <> struct is_char<wchar_t> : std::true_type {};
|
||||
template <> struct is_char<internal::char8_type> : std::true_type {};
|
||||
template <> struct is_char<detail::char8_type> : std::true_type {};
|
||||
template <> struct is_char<char16_t> : std::true_type {};
|
||||
template <> struct is_char<char32_t> : std::true_type {};
|
||||
|
||||
@ -480,9 +481,8 @@ inline basic_string_view<Char> to_string_view(basic_string_view<Char> s) {
|
||||
}
|
||||
|
||||
template <typename Char,
|
||||
FMT_ENABLE_IF(!std::is_empty<internal::std_string_view<Char>>::value)>
|
||||
inline basic_string_view<Char> to_string_view(
|
||||
internal::std_string_view<Char> s) {
|
||||
FMT_ENABLE_IF(!std::is_empty<detail::std_string_view<Char>>::value)>
|
||||
inline basic_string_view<Char> to_string_view(detail::std_string_view<Char> s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -498,7 +498,7 @@ constexpr basic_string_view<typename S::char_type> 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 <typename S> using char_t = typename internal::char_t_impl<S>::type;
|
||||
template <typename S> using char_t = typename detail::char_t_impl<S>::type;
|
||||
|
||||
/**
|
||||
\rst
|
||||
@ -543,7 +543,7 @@ template <typename S> using char_t = typename internal::char_t_impl<S>::type;
|
||||
+-----------------------+-------------------------------------+
|
||||
\endrst
|
||||
*/
|
||||
template <typename Char, typename ErrorHandler = internal::error_handler>
|
||||
template <typename Char, typename ErrorHandler = detail::error_handler>
|
||||
class basic_format_parse_context : private ErrorHandler {
|
||||
private:
|
||||
basic_string_view<Char> 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 <typename T, typename Context>
|
||||
using has_formatter =
|
||||
std::is_constructible<typename Context::template formatter_type<T>>;
|
||||
|
||||
namespace internal {
|
||||
namespace detail {
|
||||
|
||||
/** A contiguous memory buffer with an optional growing ability. */
|
||||
template <typename T> class buffer {
|
||||
@ -749,8 +749,7 @@ using has_fallback_formatter =
|
||||
|
||||
struct view {};
|
||||
|
||||
template <typename Char, typename T>
|
||||
struct named_arg : view {
|
||||
template <typename Char, typename T> 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 <typename Context> class basic_format_arg {
|
||||
private:
|
||||
internal::value<Context> value_;
|
||||
internal::type type_;
|
||||
detail::value<Context> value_;
|
||||
detail::type type_;
|
||||
|
||||
template <typename ContextType, typename T>
|
||||
friend FMT_CONSTEXPR basic_format_arg<ContextType> internal::make_arg(
|
||||
friend FMT_CONSTEXPR basic_format_arg<ContextType> detail::make_arg(
|
||||
const T& value);
|
||||
|
||||
template <typename Visitor, typename Ctx>
|
||||
@ -1118,15 +1117,15 @@ template <typename Context> class basic_format_arg {
|
||||
using char_type = typename Context::char_type;
|
||||
|
||||
template <typename T, typename Char, size_t NUM_ARGS, size_t NUM_NAMED_ARGS>
|
||||
friend struct internal::arg_data;
|
||||
friend struct detail::arg_data;
|
||||
|
||||
basic_format_arg(const internal::named_arg_info<char_type>* args, size_t size)
|
||||
basic_format_arg(const detail::named_arg_info<char_type>* args, size_t size)
|
||||
: value_(args, size) {}
|
||||
|
||||
public:
|
||||
class handle {
|
||||
public:
|
||||
explicit handle(internal::custom_value<Context> custom) : custom_(custom) {}
|
||||
explicit handle(detail::custom_value<Context> custom) : custom_(custom) {}
|
||||
|
||||
void format(typename Context::parse_context_type& parse_ctx,
|
||||
Context& ctx) const {
|
||||
@ -1134,19 +1133,19 @@ template <typename Context> class basic_format_arg {
|
||||
}
|
||||
|
||||
private:
|
||||
internal::custom_value<Context> custom_;
|
||||
detail::custom_value<Context> 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<char_type>(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<Context>::handle(arg.value_.custom));
|
||||
}
|
||||
return vis(monostate());
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
namespace detail {
|
||||
// A type-erased reference to an std::locale to avoid heavy <locale> include.
|
||||
class locale_ref {
|
||||
private:
|
||||
@ -1291,7 +1290,7 @@ class dynamic_arg_list {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
} // namespace internal
|
||||
} // namespace detail
|
||||
|
||||
// Formatting context.
|
||||
template <typename OutputIt, typename Char> class basic_format_context {
|
||||
@ -1302,7 +1301,7 @@ template <typename OutputIt, typename Char> class basic_format_context {
|
||||
private:
|
||||
OutputIt out_;
|
||||
basic_format_args<basic_format_context> args_;
|
||||
internal::locale_ref loc_;
|
||||
detail::locale_ref loc_;
|
||||
|
||||
public:
|
||||
using iterator = OutputIt;
|
||||
@ -1318,7 +1317,7 @@ template <typename OutputIt, typename Char> class basic_format_context {
|
||||
*/
|
||||
basic_format_context(OutputIt out,
|
||||
basic_format_args<basic_format_context> 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 <typename OutputIt, typename Char> class basic_format_context {
|
||||
// specified name.
|
||||
format_arg arg(basic_string_view<char_type> 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 <typename OutputIt, typename Char> 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 <typename Char>
|
||||
using buffer_context =
|
||||
basic_format_context<std::back_insert_iterator<internal::buffer<Char>>,
|
||||
Char>;
|
||||
basic_format_context<std::back_insert_iterator<detail::buffer<Char>>, Char>;
|
||||
using format_context = buffer_context<char>;
|
||||
using wformat_context = buffer_context<wchar_t>;
|
||||
|
||||
@ -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<Args...>();
|
||||
static const bool is_packed = num_args <= internal::max_packed_args;
|
||||
static const size_t num_named_args = detail::count_named_args<Args...>();
|
||||
static const bool is_packed = num_args <= detail::max_packed_args;
|
||||
|
||||
using value_type = conditional_t<is_packed, internal::value<Context>,
|
||||
using value_type = conditional_t<is_packed, detail::value<Context>,
|
||||
basic_format_arg<Context>>;
|
||||
|
||||
internal::arg_data<value_type, typename Context::char_type, num_args,
|
||||
num_named_args>
|
||||
detail::arg_data<value_type, typename Context::char_type, num_args,
|
||||
num_named_args>
|
||||
data_;
|
||||
|
||||
friend class basic_format_args<Context>;
|
||||
|
||||
static constexpr unsigned long long desc =
|
||||
(is_packed ? internal::encode_types<Context, Args...>()
|
||||
: internal::is_unpacked_bit | num_args) |
|
||||
(is_packed ? detail::encode_types<Context, Args...>()
|
||||
: detail::is_unpacked_bit | num_args) |
|
||||
(num_named_args != 0
|
||||
? static_cast<unsigned long long>(internal::has_named_args_bit)
|
||||
? static_cast<unsigned long long>(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<Context>(*this),
|
||||
#endif
|
||||
data_{internal::make_arg<
|
||||
data_{detail::make_arg<
|
||||
is_packed, Context,
|
||||
internal::mapped_type_constant<Args, Context>::value>(args)...} {
|
||||
internal::init_named_args(data_.named_args(), 0, 0, args...);
|
||||
detail::mapped_type_constant<Args, Context>::value>(args)...} {
|
||||
detail::init_named_args(data_.named_args(), 0, 0, args...);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1419,8 +1417,8 @@ inline format_arg_store<Context, Args...> make_format_args(
|
||||
\endrst
|
||||
*/
|
||||
template <typename Char, typename T>
|
||||
inline internal::named_arg<Char, T> arg(const Char* name, const T& arg) {
|
||||
static_assert(!internal::is_named_arg<T>(), "nested named arguments");
|
||||
inline detail::named_arg<Char, T> arg(const Char* name, const T& arg) {
|
||||
static_assert(!detail::is_named_arg<T>(), "nested named arguments");
|
||||
return {name, arg};
|
||||
}
|
||||
|
||||
@ -1445,38 +1443,38 @@ class dynamic_format_arg_store
|
||||
using char_type = typename Context::char_type;
|
||||
|
||||
template <typename T> struct need_copy {
|
||||
static constexpr internal::type mapped_type =
|
||||
internal::mapped_type_constant<T, Context>::value;
|
||||
static constexpr detail::type mapped_type =
|
||||
detail::mapped_type_constant<T, Context>::value;
|
||||
|
||||
enum {
|
||||
value = !(internal::is_reference_wrapper<T>::value ||
|
||||
value = !(detail::is_reference_wrapper<T>::value ||
|
||||
std::is_same<T, basic_string_view<char_type>>::value ||
|
||||
std::is_same<T, internal::std_string_view<char_type>>::value ||
|
||||
(mapped_type != internal::type::cstring_type &&
|
||||
mapped_type != internal::type::string_type &&
|
||||
mapped_type != internal::type::custom_type))
|
||||
std::is_same<T, detail::std_string_view<char_type>>::value ||
|
||||
(mapped_type != detail::type::cstring_type &&
|
||||
mapped_type != detail::type::string_type &&
|
||||
mapped_type != detail::type::custom_type))
|
||||
};
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using stored_type = conditional_t<internal::is_string<T>::value,
|
||||
using stored_type = conditional_t<detail::is_string<T>::value,
|
||||
std::basic_string<char_type>, T>;
|
||||
|
||||
// Storage of basic_format_arg must be contiguous.
|
||||
std::vector<basic_format_arg<Context>> data_;
|
||||
std::vector<internal::named_arg_info<char_type>> named_info_;
|
||||
std::vector<detail::named_arg_info<char_type>> 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<Context>;
|
||||
|
||||
unsigned long long get_types() const {
|
||||
return internal::is_unpacked_bit | data_.size() |
|
||||
(named_info_.empty() ? 0ULL
|
||||
: static_cast<unsigned long long>(
|
||||
internal::has_named_args_bit));
|
||||
return detail::is_unpacked_bit | data_.size() |
|
||||
(named_info_.empty()
|
||||
? 0ULL
|
||||
: static_cast<unsigned long long>(detail::has_named_args_bit));
|
||||
}
|
||||
|
||||
const basic_format_arg<Context>* data() const {
|
||||
@ -1484,17 +1482,16 @@ class dynamic_format_arg_store
|
||||
}
|
||||
|
||||
template <typename T> void emplace_arg(const T& arg) {
|
||||
data_.emplace_back(internal::make_arg<Context>(arg));
|
||||
data_.emplace_back(detail::make_arg<Context>(arg));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void emplace_arg(const internal::named_arg<char_type, T>& arg) {
|
||||
void emplace_arg(const detail::named_arg<char_type, T>& arg) {
|
||||
if (named_info_.empty()) {
|
||||
constexpr const internal::named_arg_info<char_type>* zero_ptr{nullptr};
|
||||
constexpr const detail::named_arg_info<char_type>* zero_ptr{nullptr};
|
||||
data_.insert(data_.begin(), {zero_ptr, 0});
|
||||
}
|
||||
data_.emplace_back(
|
||||
internal::make_arg<Context>(internal::unwrap(arg.value)));
|
||||
data_.emplace_back(detail::make_arg<Context>(detail::unwrap(arg.value)));
|
||||
auto pop_one = [](std::vector<basic_format_arg<Context>>* data) {
|
||||
data->pop_back();
|
||||
};
|
||||
@ -1524,10 +1521,10 @@ class dynamic_format_arg_store
|
||||
\endrst
|
||||
*/
|
||||
template <typename T> void push_back(const T& arg) {
|
||||
if (internal::const_check(need_copy<T>::value))
|
||||
if (detail::const_check(need_copy<T>::value))
|
||||
emplace_arg(dynamic_args_.push<stored_type<T>>(arg));
|
||||
else
|
||||
emplace_arg(internal::unwrap(arg));
|
||||
emplace_arg(detail::unwrap(arg));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1553,7 +1550,7 @@ class dynamic_format_arg_store
|
||||
*/
|
||||
template <typename T> void push_back(std::reference_wrapper<T> arg) {
|
||||
static_assert(
|
||||
internal::is_named_arg<typename std::remove_cv<T>::type>::value ||
|
||||
detail::is_named_arg<typename std::remove_cv<T>::type>::value ||
|
||||
need_copy<T>::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 <typename T>
|
||||
void push_back(const internal::named_arg<char_type, T>& arg) {
|
||||
void push_back(const detail::named_arg<char_type, T>& arg) {
|
||||
const char_type* arg_name =
|
||||
dynamic_args_.push<std::basic_string<char_type>>(arg.name).c_str();
|
||||
if (internal::const_check(need_copy<T>::value)) {
|
||||
if (detail::const_check(need_copy<T>::value)) {
|
||||
emplace_arg(
|
||||
fmt::arg(arg_name, dynamic_args_.push<stored_type<T>>(arg.value)));
|
||||
} else {
|
||||
@ -1604,23 +1601,23 @@ template <typename Context> 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<Context>* values_;
|
||||
const detail::value<Context>* 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<internal::type>((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<detail::type>((desc_ >> shift) & mask);
|
||||
}
|
||||
|
||||
basic_format_args(unsigned long long desc,
|
||||
const internal::value<Context>* values)
|
||||
const detail::value<Context>* 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 <typename Context> 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 <typename Context> 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 <typename Context> 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<int>(is_packed() ? max_packed
|
||||
: desc_ & ~internal::is_unpacked_bit);
|
||||
: desc_ & ~detail::is_unpacked_bit);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1702,9 +1699,9 @@ template <typename Char>
|
||||
struct is_contiguous<std::basic_string<Char>> : std::true_type {};
|
||||
|
||||
template <typename Char>
|
||||
struct is_contiguous<internal::buffer<Char>> : std::true_type {};
|
||||
struct is_contiguous<detail::buffer<Char>> : std::true_type {};
|
||||
|
||||
namespace internal {
|
||||
namespace detail {
|
||||
|
||||
template <typename OutputIt>
|
||||
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<Container> with
|
||||
// vformat_to<ArgFormatter>(...) overload, so SFINAE on iterator type instead.
|
||||
template <typename OutputIt, typename S, typename Char = char_t<S>,
|
||||
FMT_ENABLE_IF(
|
||||
internal::is_contiguous_back_insert_iterator<OutputIt>::value)>
|
||||
template <
|
||||
typename OutputIt, typename S, typename Char = char_t<S>,
|
||||
FMT_ENABLE_IF(detail::is_contiguous_back_insert_iterator<OutputIt>::value)>
|
||||
OutputIt vformat_to(
|
||||
OutputIt out, const S& format_str,
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
||||
auto& c = internal::get_container(out);
|
||||
internal::container_buffer<remove_reference_t<decltype(c)>> buf(c);
|
||||
internal::vformat_to(buf, to_string_view(format_str), args);
|
||||
auto& c = detail::get_container(out);
|
||||
detail::container_buffer<remove_reference_t<decltype(c)>> buf(c);
|
||||
detail::vformat_to(buf, to_string_view(format_str), args);
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename Container, typename S, typename... Args,
|
||||
FMT_ENABLE_IF(
|
||||
is_contiguous<Container>::value&& internal::is_string<S>::value)>
|
||||
is_contiguous<Container>::value&& detail::is_string<S>::value)>
|
||||
inline std::back_insert_iterator<Container> format_to(
|
||||
std::back_insert_iterator<Container> out, const S& format_str,
|
||||
Args&&... args) {
|
||||
return vformat_to(out, to_string_view(format_str),
|
||||
internal::make_args_checked<Args...>(format_str, args...));
|
||||
detail::make_args_checked<Args...>(format_str, args...));
|
||||
}
|
||||
|
||||
template <typename S, typename Char = char_t<S>>
|
||||
FMT_INLINE std::basic_string<Char> vformat(
|
||||
const S& format_str,
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> 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<Char> vformat(
|
||||
// std::basic_string<char_t<S>> to reduce the symbol size.
|
||||
template <typename S, typename... Args, typename Char = char_t<S>>
|
||||
FMT_INLINE std::basic_string<Char> format(const S& format_str, Args&&... args) {
|
||||
const auto& vargs = internal::make_args_checked<Args...>(format_str, args...);
|
||||
return internal::vformat(to_string_view(format_str), vargs);
|
||||
const auto& vargs = detail::make_args_checked<Args...>(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 <typename S, typename... Args, typename Char = char_t<S>>
|
||||
inline void print(std::FILE* f, const S& format_str, Args&&... args) {
|
||||
const auto& vargs = internal::make_args_checked<Args...>(format_str, args...);
|
||||
return internal::is_unicode<Char>()
|
||||
const auto& vargs = detail::make_args_checked<Args...>(format_str, args...);
|
||||
return detail::is_unicode<Char>()
|
||||
? 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 <typename S, typename... Args, typename Char = char_t<S>>
|
||||
inline void print(const S& format_str, Args&&... args) {
|
||||
const auto& vargs = internal::make_args_checked<Args...>(format_str, args...);
|
||||
return internal::is_unicode<Char>()
|
||||
const auto& vargs = detail::make_args_checked<Args...>(format_str, args...);
|
||||
return detail::is_unicode<Char>()
|
||||
? 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
|
||||
|
||||
|
@ -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<char>& out, int error_code,
|
||||
FMT_FUNC void format_error_code(detail::buffer<char>& 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<char>& 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<uint32_or_64_or_128_t<int>>(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 <typename Locale>
|
||||
locale_ref::locale_ref(const Locale& loc) : locale_(&loc) {
|
||||
@ -200,18 +200,16 @@ template <typename Char> FMT_FUNC Char decimal_point_impl(locale_ref loc) {
|
||||
return std::use_facet<std::numpunct<Char>>(loc.get<std::locale>())
|
||||
.decimal_point();
|
||||
}
|
||||
} // namespace internal
|
||||
} // namespace detail
|
||||
#else
|
||||
template <typename Char>
|
||||
FMT_FUNC std::string internal::grouping_impl(locale_ref) {
|
||||
FMT_FUNC std::string detail::grouping_impl(locale_ref) {
|
||||
return "\03";
|
||||
}
|
||||
template <typename Char>
|
||||
FMT_FUNC Char internal::thousands_sep_impl(locale_ref) {
|
||||
template <typename Char> FMT_FUNC Char detail::thousands_sep_impl(locale_ref) {
|
||||
return FMT_STATIC_THOUSANDS_SEPARATOR;
|
||||
}
|
||||
template <typename Char>
|
||||
FMT_FUNC Char internal::decimal_point_impl(locale_ref) {
|
||||
template <typename Char> 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<int>(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<internal::bigint> {
|
||||
template <> struct formatter<detail::bigint> {
|
||||
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<internal::bigint> {
|
||||
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<char>& out, int error_code,
|
||||
FMT_FUNC void format_system_error(detail::buffer<char>& 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<char>& 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<char>& 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<buffer_context<char>>(args));
|
||||
detail::vformat_to(buffer, format_str,
|
||||
basic_format_args<buffer_context<char>>(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<HANDLE>(_get_osfhandle(fd)),
|
||||
u16.c_str(), static_cast<DWORD>(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<buffer_context<char>>(args));
|
||||
detail::vformat_to(buffer, format_str,
|
||||
basic_format_args<buffer_context<char>>(args));
|
||||
fwrite_fully(buffer.data(), 1, buffer.size(), f);
|
||||
}
|
||||
#endif
|
||||
|
@ -96,16 +96,16 @@
|
||||
# if FMT_EXCEPTIONS
|
||||
# if FMT_MSC_VER || FMT_NVCC
|
||||
FMT_BEGIN_NAMESPACE
|
||||
namespace internal {
|
||||
namespace detail {
|
||||
template <typename Exception> 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 <intrin.h> // _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<Dest*>(&source)` that doesn't have
|
||||
// undefined behavior (e.g. due to type aliasing).
|
||||
@ -572,17 +572,18 @@ void buffer<T>::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 <typename T>
|
||||
class buffer_range : public internal::output_range<
|
||||
std::back_insert_iterator<internal::buffer<T>>, T> {
|
||||
class buffer_range
|
||||
: public detail::output_range<std::back_insert_iterator<detail::buffer<T>>,
|
||||
T> {
|
||||
public:
|
||||
using iterator = std::back_insert_iterator<internal::buffer<T>>;
|
||||
using internal::output_range<iterator, T>::output_range;
|
||||
buffer_range(internal::buffer<T>& buf)
|
||||
: internal::output_range<iterator, T>(std::back_inserter(buf)) {}
|
||||
using iterator = std::back_insert_iterator<detail::buffer<T>>;
|
||||
using detail::output_range<iterator, T>::output_range;
|
||||
buffer_range(detail::buffer<T>& buf)
|
||||
: detail::output_range<iterator, T>(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 <typename T, size_t SIZE = inline_buffer_size,
|
||||
typename Allocator = std::allocator<T>>
|
||||
class basic_memory_buffer : public internal::buffer<T> {
|
||||
class basic_memory_buffer : public detail::buffer<T> {
|
||||
private:
|
||||
T store_[SIZE];
|
||||
|
||||
@ -655,7 +656,7 @@ class basic_memory_buffer : public internal::buffer<T> {
|
||||
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<T, SIZE, Allocator>::grow(size_t size) {
|
||||
std::allocator_traits<Allocator>::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 <unsigned BITS, typename UInt> 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<UInt>() + 1 };
|
||||
Char buffer[2 * max_size];
|
||||
auto end = format_decimal(buffer, value, num_digits, add_thousands_sep);
|
||||
return internal::copy_str<Char>(buffer, end, out);
|
||||
return detail::copy_str<Char>(buffer, end, out);
|
||||
}
|
||||
|
||||
template <typename Char, typename It, typename UInt>
|
||||
@ -939,7 +940,7 @@ inline Char* format_uint(Char* buffer, UInt value, int num_digits,
|
||||
}
|
||||
|
||||
template <unsigned BASE_BITS, typename Char>
|
||||
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<unsigned char>::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<UInt>() / BASE_BITS + 1];
|
||||
format_uint<BASE_BITS>(buffer, value, num_digits, upper);
|
||||
return internal::copy_str<Char>(buffer, buffer + num_digits, out);
|
||||
return detail::copy_str<Char>(buffer, buffer + num_digits, out);
|
||||
}
|
||||
|
||||
// A converter from UTF-8 to UTF-16.
|
||||
@ -1016,7 +1017,7 @@ template <typename Char> 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 <typename Char> struct basic_format_specs {
|
||||
align_t align : 4;
|
||||
sign_t sign : 3;
|
||||
bool alt : 1; // Alternate form ('#').
|
||||
internal::fill_t<Char> fill;
|
||||
detail::fill_t<Char> fill;
|
||||
|
||||
constexpr basic_format_specs()
|
||||
: width(0),
|
||||
@ -1047,12 +1048,12 @@ template <typename Char> struct basic_format_specs {
|
||||
align(align::none),
|
||||
sign(sign::none),
|
||||
alt(false),
|
||||
fill(internal::fill_t<Char>::make()) {}
|
||||
fill(detail::fill_t<Char>::make()) {}
|
||||
};
|
||||
|
||||
using format_specs = basic_format_specs<char>;
|
||||
|
||||
namespace internal {
|
||||
namespace detail {
|
||||
|
||||
// A floating-point presentation format.
|
||||
enum class float_format : unsigned char {
|
||||
@ -1675,7 +1676,7 @@ template <typename T> struct is_integral : std::is_integral<T> {};
|
||||
template <> struct is_integral<int128_t> : std::true_type {};
|
||||
template <> struct is_integral<uint128_t> : std::true_type {};
|
||||
|
||||
template <typename Range, typename ErrorHandler = internal::error_handler>
|
||||
template <typename Range, typename ErrorHandler = detail::error_handler>
|
||||
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<decltype(
|
||||
internal::reserve(std::declval<iterator&>(), 0))>;
|
||||
detail::reserve(std::declval<iterator&>(), 0))>;
|
||||
|
||||
struct char_writer {
|
||||
char_type value;
|
||||
@ -1779,11 +1780,11 @@ class arg_formatter_base {
|
||||
|
||||
template <typename Char>
|
||||
void write(basic_string_view<Char> 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<char_type>(out_, internal::to_uintptr(p), specs_);
|
||||
out_ = write_ptr<char_type>(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<char_type>(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<char_type> 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 <typename Char> class specs_setter {
|
||||
|
||||
template <typename ErrorHandler> 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 <typename ErrorHandler> 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 <typename Handler> 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<typename Context::char_type> {
|
||||
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<char_type> 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<false, char>(const char* first, const char* last, char value,
|
||||
const char*& out) {
|
||||
out = static_cast<const char*>(
|
||||
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<char_type>;
|
||||
using mapped_type =
|
||||
conditional_t<internal::mapped_type_constant<T, context>::value !=
|
||||
conditional_t<detail::mapped_type_constant<T, context>::value !=
|
||||
type::custom_type,
|
||||
decltype(arg_mapper<context>().map(std::declval<T>())), T>;
|
||||
auto f = conditional_t<has_formatter<mapped_type, context>::value,
|
||||
formatter<mapped_type, char_type>,
|
||||
internal::fallback_formatter<T, char_type>>();
|
||||
detail::fallback_formatter<T, char_type>>();
|
||||
return f.parse(ctx);
|
||||
}
|
||||
|
||||
@ -2651,17 +2651,17 @@ FMT_CONSTEXPR basic_string_view<Char> 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<decltype(s[0])>; \
|
||||
FMT_MAYBE_UNUSED __VA_ARGS__ FMT_CONSTEXPR \
|
||||
operator fmt::basic_string_view<char_type>() const { \
|
||||
return fmt::internal::compile_string_to_view<char_type>(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<decltype(s[0])>; \
|
||||
FMT_MAYBE_UNUSED __VA_ARGS__ FMT_CONSTEXPR \
|
||||
operator fmt::basic_string_view<char_type>() const { \
|
||||
return fmt::detail::compile_string_to_view<char_type>(s); \
|
||||
} \
|
||||
}; \
|
||||
return FMT_COMPILE_STRING(); \
|
||||
}()
|
||||
|
||||
/**
|
||||
@ -2694,31 +2694,31 @@ void handle_dynamic_spec(int& value, arg_ref<typename Context::char_type> ref,
|
||||
case arg_id_kind::none:
|
||||
break;
|
||||
case arg_id_kind::index:
|
||||
value = internal::get_dynamic_spec<Handler>(ctx.arg(ref.val.index),
|
||||
ctx.error_handler());
|
||||
value = detail::get_dynamic_spec<Handler>(ctx.arg(ref.val.index),
|
||||
ctx.error_handler());
|
||||
break;
|
||||
case arg_id_kind::name:
|
||||
value = internal::get_dynamic_spec<Handler>(ctx.arg(ref.val.name),
|
||||
ctx.error_handler());
|
||||
value = detail::get_dynamic_spec<Handler>(ctx.arg(ref.val.name),
|
||||
ctx.error_handler());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
using format_func = void (*)(internal::buffer<char>&, int, string_view);
|
||||
using format_func = void (*)(detail::buffer<char>&, int, string_view);
|
||||
|
||||
FMT_API void format_error_code(buffer<char>& 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 <typename Range>
|
||||
class arg_formatter : public internal::arg_formatter_base<Range> {
|
||||
class arg_formatter : public detail::arg_formatter_base<Range> {
|
||||
private:
|
||||
using char_type = typename Range::value_type;
|
||||
using base = internal::arg_formatter_base<Range>;
|
||||
using base = detail::arg_formatter_base<Range>;
|
||||
using context_type = basic_format_context<typename base::iterator, char_type>;
|
||||
|
||||
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<char>& out, int error_code,
|
||||
FMT_API void format_system_error(detail::buffer<char>& 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<unsigned>((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<char>('0' + value);
|
||||
return ptr;
|
||||
}
|
||||
auto index = static_cast<unsigned>(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 <typename T, typename Char>
|
||||
struct formatter<T, Char,
|
||||
enable_if_t<internal::type_constant<T, Char>::value !=
|
||||
internal::type::custom_type>> {
|
||||
enable_if_t<detail::type_constant<T, Char>::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 <typename ParseContext>
|
||||
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
||||
using handler_type = internal::dynamic_specs_handler<ParseContext>;
|
||||
auto type = internal::type_constant<T, Char>::value;
|
||||
internal::specs_checker<handler_type> handler(handler_type(specs_, ctx),
|
||||
type);
|
||||
using handler_type = detail::dynamic_specs_handler<ParseContext>;
|
||||
auto type = detail::type_constant<T, Char>::value;
|
||||
detail::specs_checker<handler_type> 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<decltype(eh)>(eh));
|
||||
detail::int_type_checker<decltype(eh)>(eh));
|
||||
break;
|
||||
case internal::type::char_type:
|
||||
case detail::type::char_type:
|
||||
handle_char_specs(
|
||||
&specs_, internal::char_specs_checker<decltype(eh)>(specs_.type, eh));
|
||||
&specs_, detail::char_specs_checker<decltype(eh)>(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<decltype(eh)>(eh));
|
||||
case detail::type::cstring_type:
|
||||
detail::handle_cstring_type_spec(
|
||||
specs_.type, detail::cstring_type_checker<decltype(eh)>(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<T, Char,
|
||||
|
||||
template <typename FormatContext>
|
||||
auto format(const T& val, FormatContext& ctx) -> decltype(ctx.out()) {
|
||||
internal::handle_dynamic_spec<internal::width_checker>(
|
||||
specs_.width, specs_.width_ref, ctx);
|
||||
internal::handle_dynamic_spec<internal::precision_checker>(
|
||||
detail::handle_dynamic_spec<detail::width_checker>(specs_.width,
|
||||
specs_.width_ref, ctx);
|
||||
detail::handle_dynamic_spec<detail::precision_checker>(
|
||||
specs_.precision, specs_.precision_ref, ctx);
|
||||
using range_type =
|
||||
internal::output_range<typename FormatContext::iterator,
|
||||
typename FormatContext::char_type>;
|
||||
using range_type = detail::output_range<typename FormatContext::iterator,
|
||||
typename FormatContext::char_type>;
|
||||
return visit_format_arg(arg_formatter<range_type>(ctx, nullptr, &specs_),
|
||||
internal::make_arg<FormatContext>(val));
|
||||
detail::make_arg<FormatContext>(val));
|
||||
}
|
||||
|
||||
private:
|
||||
internal::dynamic_format_specs<Char> specs_;
|
||||
detail::dynamic_format_specs<Char> 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<Char>, basic_string_view<Char>);
|
||||
FMT_FORMAT_AS(std::nullptr_t, const void*);
|
||||
FMT_FORMAT_AS(internal::std_string_view<Char>, basic_string_view<Char>);
|
||||
FMT_FORMAT_AS(detail::std_string_view<Char>, basic_string_view<Char>);
|
||||
|
||||
template <typename Char>
|
||||
struct formatter<void*, Char> : formatter<const void*, Char> {
|
||||
@ -3036,7 +3035,7 @@ struct formatter<Char[N], Char> : formatter<basic_string_view<Char>, Char> {
|
||||
// };
|
||||
template <typename Char = char> 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 <typename Char = char> 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<ParseContext> handler(specs_, ctx);
|
||||
detail::dynamic_specs_handler<ParseContext> handler(specs_, ctx);
|
||||
return parse_format_specs(ctx.begin(), ctx.end(), handler);
|
||||
}
|
||||
|
||||
template <typename T, typename FormatContext>
|
||||
auto format(const T& val, FormatContext& ctx) -> decltype(ctx.out()) {
|
||||
handle_specs(ctx);
|
||||
internal::specs_checker<null_handler> checker(
|
||||
null_handler(),
|
||||
internal::mapped_type_constant<T, FormatContext>::value);
|
||||
detail::specs_checker<null_handler> checker(
|
||||
null_handler(), detail::mapped_type_constant<T, FormatContext>::value);
|
||||
checker.on_align(specs_.align);
|
||||
switch (specs_.sign) {
|
||||
case sign::none:
|
||||
@ -3075,22 +3073,22 @@ template <typename Char = char> class dynamic_formatter {
|
||||
}
|
||||
if (specs_.alt) checker.on_hash();
|
||||
if (specs_.precision >= 0) checker.end_precision();
|
||||
using range = internal::output_range<typename FormatContext::iterator,
|
||||
typename FormatContext::char_type>;
|
||||
using range = detail::output_range<typename FormatContext::iterator,
|
||||
typename FormatContext::char_type>;
|
||||
visit_format_arg(arg_formatter<range>(ctx, nullptr, &specs_),
|
||||
internal::make_arg<FormatContext>(val));
|
||||
detail::make_arg<FormatContext>(val));
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Context> void handle_specs(Context& ctx) {
|
||||
internal::handle_dynamic_spec<internal::width_checker>(
|
||||
specs_.width, specs_.width_ref, ctx);
|
||||
internal::handle_dynamic_spec<internal::precision_checker>(
|
||||
detail::handle_dynamic_spec<detail::width_checker>(specs_.width,
|
||||
specs_.width_ref, ctx);
|
||||
detail::handle_dynamic_spec<detail::precision_checker>(
|
||||
specs_.precision, specs_.precision_ref, ctx);
|
||||
}
|
||||
|
||||
internal::dynamic_format_specs<Char> specs_;
|
||||
detail::dynamic_format_specs<Char> specs_;
|
||||
const Char* format_str_;
|
||||
};
|
||||
|
||||
@ -3101,24 +3099,23 @@ FMT_CONSTEXPR void advance_to(
|
||||
}
|
||||
|
||||
template <typename ArgFormatter, typename Char, typename Context>
|
||||
struct format_handler : internal::error_handler {
|
||||
struct format_handler : detail::error_handler {
|
||||
using range = typename ArgFormatter::range;
|
||||
|
||||
format_handler(range r, basic_string_view<Char> str,
|
||||
basic_format_args<Context> format_args,
|
||||
internal::locale_ref loc)
|
||||
basic_format_args<Context> 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 <typename ID> 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<Context> f(parse_context, context);
|
||||
detail::custom_formatter<Context> f(parse_context, context);
|
||||
if (visit_format_arg(f, arg)) return parse_context.begin();
|
||||
basic_format_specs<Char> specs;
|
||||
using internal::specs_handler;
|
||||
using detail::specs_handler;
|
||||
using parse_context_t = basic_format_parse_context<Char>;
|
||||
internal::specs_checker<specs_handler<parse_context_t, Context>> handler(
|
||||
detail::specs_checker<specs_handler<parse_context_t, Context>> handler(
|
||||
specs_handler<parse_context_t, Context>(specs, parse_context, context),
|
||||
arg.type());
|
||||
begin = parse_format_specs(begin, end, handler);
|
||||
@ -3162,9 +3159,9 @@ template <typename ArgFormatter, typename Char, typename Context>
|
||||
typename Context::iterator vformat_to(
|
||||
typename ArgFormatter::range out, basic_string_view<Char> format_str,
|
||||
basic_format_args<Context> args,
|
||||
internal::locale_ref loc = internal::locale_ref()) {
|
||||
detail::locale_ref loc = detail::locale_ref()) {
|
||||
format_handler<ArgFormatter, Char, Context> h(out, format_str, args, loc);
|
||||
internal::parse_format_string<false>(format_str, h);
|
||||
detail::parse_format_string<false>(format_str, h);
|
||||
return h.context.out();
|
||||
}
|
||||
|
||||
@ -3191,28 +3188,28 @@ class bytes {
|
||||
template <> struct formatter<bytes> {
|
||||
template <typename ParseContext>
|
||||
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
||||
using handler_type = internal::dynamic_specs_handler<ParseContext>;
|
||||
internal::specs_checker<handler_type> handler(handler_type(specs_, ctx),
|
||||
internal::type::string_type);
|
||||
using handler_type = detail::dynamic_specs_handler<ParseContext>;
|
||||
detail::specs_checker<handler_type> 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 <typename FormatContext>
|
||||
auto format(bytes b, FormatContext& ctx) -> decltype(ctx.out()) {
|
||||
internal::handle_dynamic_spec<internal::width_checker>(
|
||||
specs_.width, specs_.width_ref, ctx);
|
||||
internal::handle_dynamic_spec<internal::precision_checker>(
|
||||
detail::handle_dynamic_spec<detail::width_checker>(specs_.width,
|
||||
specs_.width_ref, ctx);
|
||||
detail::handle_dynamic_spec<detail::precision_checker>(
|
||||
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<char> specs_;
|
||||
detail::dynamic_format_specs<char> specs_;
|
||||
};
|
||||
|
||||
template <typename It, typename Char> struct arg_join : internal::view {
|
||||
template <typename It, typename Char> struct arg_join : detail::view {
|
||||
It begin;
|
||||
It end;
|
||||
basic_string_view<Char> sep;
|
||||
@ -3272,14 +3269,14 @@ arg_join<It, wchar_t> join(It begin, It end, wstring_view sep) {
|
||||
\endrst
|
||||
*/
|
||||
template <typename Range>
|
||||
arg_join<internal::iterator_t<const Range>, char> join(const Range& range,
|
||||
string_view sep) {
|
||||
arg_join<detail::iterator_t<const Range>, char> join(const Range& range,
|
||||
string_view sep) {
|
||||
return join(std::begin(range), std::end(range), sep);
|
||||
}
|
||||
|
||||
template <typename Range>
|
||||
arg_join<internal::iterator_t<const Range>, wchar_t> join(const Range& range,
|
||||
wstring_view sep) {
|
||||
arg_join<detail::iterator_t<const Range>, 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<Char> to_string(const basic_memory_buffer<Char, SIZE>& buf) {
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
typename buffer_context<Char>::iterator internal::vformat_to(
|
||||
internal::buffer<Char>& buf, basic_string_view<Char> format_str,
|
||||
typename buffer_context<Char>::iterator detail::vformat_to(
|
||||
detail::buffer<Char>& buf, basic_string_view<Char> format_str,
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
||||
using range = buffer_range<Char>;
|
||||
return vformat_to<arg_formatter<range>>(buf, to_string_view(format_str),
|
||||
@ -3320,9 +3317,9 @@ typename buffer_context<Char>::iterator internal::vformat_to(
|
||||
}
|
||||
|
||||
#ifndef FMT_HEADER_ONLY
|
||||
extern template format_context::iterator internal::vformat_to(
|
||||
internal::buffer<char>&, string_view, basic_format_args<format_context>);
|
||||
namespace internal {
|
||||
extern template format_context::iterator detail::vformat_to(
|
||||
detail::buffer<char>&, string_view, basic_format_args<format_context>);
|
||||
namespace detail {
|
||||
extern template FMT_API std::string grouping_impl<char>(locale_ref loc);
|
||||
extern template FMT_API std::string grouping_impl<wchar_t>(locale_ref loc);
|
||||
extern template FMT_API char thousands_sep_impl<char>(locale_ref loc);
|
||||
@ -3343,25 +3340,25 @@ extern template int snprintf_float<long double>(long double value,
|
||||
int precision,
|
||||
float_specs specs,
|
||||
buffer<char>& buf);
|
||||
} // namespace internal
|
||||
} // namespace detail
|
||||
#endif
|
||||
|
||||
template <typename S, typename Char = char_t<S>,
|
||||
FMT_ENABLE_IF(internal::is_string<S>::value)>
|
||||
FMT_ENABLE_IF(detail::is_string<S>::value)>
|
||||
inline typename buffer_context<Char>::iterator vformat_to(
|
||||
internal::buffer<Char>& buf, const S& format_str,
|
||||
detail::buffer<Char>& buf, const S& format_str,
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
||||
return internal::vformat_to(buf, to_string_view(format_str), args);
|
||||
return detail::vformat_to(buf, to_string_view(format_str), args);
|
||||
}
|
||||
|
||||
template <typename S, typename... Args, size_t SIZE = inline_buffer_size,
|
||||
typename Char = enable_if_t<internal::is_string<S>::value, char_t<S>>>
|
||||
typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
|
||||
inline typename buffer_context<Char>::iterator format_to(
|
||||
basic_memory_buffer<Char, SIZE>& buf, const S& format_str, Args&&... args) {
|
||||
internal::check_format_string<Args...>(format_str);
|
||||
detail::check_format_string<Args...>(format_str);
|
||||
using context = buffer_context<Char>;
|
||||
return internal::vformat_to(buf, to_string_view(format_str),
|
||||
make_format_args<context>(args...));
|
||||
return detail::vformat_to(buf, to_string_view(format_str),
|
||||
make_format_args<context>(args...));
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename Char = char>
|
||||
@ -3370,14 +3367,14 @@ using format_context_t = basic_format_context<OutputIt, Char>;
|
||||
template <typename OutputIt, typename Char = char>
|
||||
using format_args_t = basic_format_args<format_context_t<OutputIt, Char>>;
|
||||
|
||||
template <typename S, typename OutputIt, typename... Args,
|
||||
FMT_ENABLE_IF(
|
||||
internal::is_output_iterator<OutputIt>::value &&
|
||||
!internal::is_contiguous_back_insert_iterator<OutputIt>::value)>
|
||||
template <
|
||||
typename S, typename OutputIt, typename... Args,
|
||||
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt>::value &&
|
||||
!detail::is_contiguous_back_insert_iterator<OutputIt>::value)>
|
||||
inline OutputIt vformat_to(
|
||||
OutputIt out, const S& format_str,
|
||||
format_args_t<type_identity_t<OutputIt>, char_t<S>> args) {
|
||||
using range = internal::output_range<OutputIt, char_t<S>>;
|
||||
using range = detail::output_range<OutputIt, char_t<S>>;
|
||||
return vformat_to<arg_formatter<range>>(range(out),
|
||||
to_string_view(format_str), args);
|
||||
}
|
||||
@ -3395,11 +3392,11 @@ inline OutputIt vformat_to(
|
||||
*/
|
||||
template <typename OutputIt, typename S, typename... Args,
|
||||
FMT_ENABLE_IF(
|
||||
internal::is_output_iterator<OutputIt>::value &&
|
||||
!internal::is_contiguous_back_insert_iterator<OutputIt>::value &&
|
||||
internal::is_string<S>::value)>
|
||||
detail::is_output_iterator<OutputIt>::value &&
|
||||
!detail::is_contiguous_back_insert_iterator<OutputIt>::value &&
|
||||
detail::is_string<S>::value)>
|
||||
inline OutputIt format_to(OutputIt out, const S& format_str, Args&&... args) {
|
||||
internal::check_format_string<Args...>(format_str);
|
||||
detail::check_format_string<Args...>(format_str);
|
||||
using context = format_context_t<OutputIt, char_t<S>>;
|
||||
return vformat_to(out, to_string_view(format_str),
|
||||
make_format_args<context>(args...));
|
||||
@ -3414,7 +3411,7 @@ template <typename OutputIt> struct format_to_n_result {
|
||||
|
||||
template <typename OutputIt, typename Char = typename OutputIt::value_type>
|
||||
using format_to_n_context =
|
||||
format_context_t<internal::truncating_iterator<OutputIt>, Char>;
|
||||
format_context_t<detail::truncating_iterator<OutputIt>, Char>;
|
||||
|
||||
template <typename OutputIt, typename Char = typename OutputIt::value_type>
|
||||
using format_to_n_args = basic_format_args<format_to_n_context<OutputIt, Char>>;
|
||||
@ -3427,11 +3424,11 @@ make_format_to_n_args(const Args&... args) {
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename Char, typename... Args,
|
||||
FMT_ENABLE_IF(internal::is_output_iterator<OutputIt>::value)>
|
||||
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt>::value)>
|
||||
inline format_to_n_result<OutputIt> vformat_to_n(
|
||||
OutputIt out, size_t n, basic_string_view<Char> format_str,
|
||||
format_to_n_args<type_identity_t<OutputIt>, type_identity_t<Char>> args) {
|
||||
auto it = vformat_to(internal::truncating_iterator<OutputIt>(out, n),
|
||||
auto it = vformat_to(detail::truncating_iterator<OutputIt>(out, n),
|
||||
format_str, args);
|
||||
return {it.base(), it.count()};
|
||||
}
|
||||
@ -3444,23 +3441,23 @@ inline format_to_n_result<OutputIt> vformat_to_n(
|
||||
\endrst
|
||||
*/
|
||||
template <typename OutputIt, typename S, typename... Args,
|
||||
FMT_ENABLE_IF(internal::is_string<S>::value&&
|
||||
internal::is_output_iterator<OutputIt>::value)>
|
||||
FMT_ENABLE_IF(detail::is_string<S>::value&&
|
||||
detail::is_output_iterator<OutputIt>::value)>
|
||||
inline format_to_n_result<OutputIt> format_to_n(OutputIt out, size_t n,
|
||||
const S& format_str,
|
||||
const Args&... args) {
|
||||
internal::check_format_string<Args...>(format_str);
|
||||
detail::check_format_string<Args...>(format_str);
|
||||
using context = format_to_n_context<OutputIt, char_t<S>>;
|
||||
return vformat_to_n(out, n, to_string_view(format_str),
|
||||
make_format_args<context>(args...));
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
std::basic_string<Char> internal::vformat(
|
||||
std::basic_string<Char> detail::vformat(
|
||||
basic_string_view<Char> format_str,
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
||||
basic_memory_buffer<Char> 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<Char> internal::vformat(
|
||||
*/
|
||||
template <typename... Args>
|
||||
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 <typename Char, FMT_ENABLE_IF(std::is_same<Char, wchar_t>::value)>
|
||||
void vprint(std::FILE* f, basic_string_view<Char> 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<Char> format_str, wformat_args args) {
|
||||
}
|
||||
|
||||
#if FMT_USE_USER_DEFINED_LITERALS
|
||||
namespace internal {
|
||||
namespace detail {
|
||||
|
||||
# if FMT_USE_UDL_TEMPLATE
|
||||
template <typename Char, Char... CHARS> class udl_formatter {
|
||||
@ -3519,7 +3516,7 @@ template <typename Char> struct udl_arg {
|
||||
return {str, std::forward<T>(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 <typename Char, Char... CHARS>
|
||||
FMT_CONSTEXPR internal::udl_formatter<Char, CHARS...> operator""_format() {
|
||||
FMT_CONSTEXPR detail::udl_formatter<Char, CHARS...> operator""_format() {
|
||||
return {};
|
||||
}
|
||||
# pragma GCC diagnostic pop
|
||||
@ -3544,11 +3541,11 @@ FMT_CONSTEXPR internal::udl_formatter<Char, CHARS...> operator""_format() {
|
||||
std::string message = "The answer is {}"_format(42);
|
||||
\endrst
|
||||
*/
|
||||
FMT_CONSTEXPR internal::udl_formatter<char> operator"" _format(const char* s,
|
||||
size_t n) {
|
||||
FMT_CONSTEXPR detail::udl_formatter<char> operator"" _format(const char* s,
|
||||
size_t n) {
|
||||
return {{s, n}};
|
||||
}
|
||||
FMT_CONSTEXPR internal::udl_formatter<wchar_t> operator"" _format(
|
||||
FMT_CONSTEXPR detail::udl_formatter<wchar_t> operator"" _format(
|
||||
const wchar_t* s, size_t n) {
|
||||
return {{s, n}};
|
||||
}
|
||||
@ -3564,11 +3561,10 @@ FMT_CONSTEXPR internal::udl_formatter<wchar_t> operator"" _format(
|
||||
fmt::print("Elapsed time: {s:.2f} seconds", "s"_a=1.23);
|
||||
\endrst
|
||||
*/
|
||||
FMT_CONSTEXPR internal::udl_arg<char> operator"" _a(const char* s, size_t) {
|
||||
FMT_CONSTEXPR detail::udl_arg<char> operator"" _a(const char* s, size_t) {
|
||||
return {s};
|
||||
}
|
||||
FMT_CONSTEXPR internal::udl_arg<wchar_t> operator"" _a(const wchar_t* s,
|
||||
size_t) {
|
||||
FMT_CONSTEXPR detail::udl_arg<wchar_t> operator"" _a(const wchar_t* s, size_t) {
|
||||
return {s};
|
||||
}
|
||||
} // namespace literals
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
|
||||
namespace internal {
|
||||
namespace detail {
|
||||
template <typename Char>
|
||||
typename buffer_context<Char>::iterator vformat_to(
|
||||
const std::locale& loc, buffer<Char>& buf,
|
||||
@ -22,7 +22,7 @@ typename buffer_context<Char>::iterator vformat_to(
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
||||
using range = buffer_range<Char>;
|
||||
return vformat_to<arg_formatter<range>>(buf, to_string_view(format_str), args,
|
||||
internal::locale_ref(loc));
|
||||
detail::locale_ref(loc));
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
@ -30,43 +30,43 @@ std::basic_string<Char> vformat(
|
||||
const std::locale& loc, basic_string_view<Char> format_str,
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
||||
basic_memory_buffer<Char> 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 <typename S, typename Char = char_t<S>>
|
||||
inline std::basic_string<Char> vformat(
|
||||
const std::locale& loc, const S& format_str,
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
||||
return internal::vformat(loc, to_string_view(format_str), args);
|
||||
return detail::vformat(loc, to_string_view(format_str), args);
|
||||
}
|
||||
|
||||
template <typename S, typename... Args, typename Char = char_t<S>>
|
||||
inline std::basic_string<Char> 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<Args...>(format_str, args...));
|
||||
detail::make_args_checked<Args...>(format_str, args...));
|
||||
}
|
||||
|
||||
template <typename S, typename OutputIt, typename... Args,
|
||||
typename Char = enable_if_t<
|
||||
internal::is_output_iterator<OutputIt>::value, char_t<S>>>
|
||||
detail::is_output_iterator<OutputIt>::value, char_t<S>>>
|
||||
inline OutputIt vformat_to(
|
||||
OutputIt out, const std::locale& loc, const S& format_str,
|
||||
format_args_t<type_identity_t<OutputIt>, Char> args) {
|
||||
using range = internal::output_range<OutputIt, Char>;
|
||||
using range = detail::output_range<OutputIt, Char>;
|
||||
return vformat_to<arg_formatter<range>>(
|
||||
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 <typename OutputIt, typename S, typename... Args,
|
||||
FMT_ENABLE_IF(internal::is_output_iterator<OutputIt>::value&&
|
||||
internal::is_string<S>::value)>
|
||||
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt>::value&&
|
||||
detail::is_string<S>::value)>
|
||||
inline OutputIt format_to(OutputIt out, const std::locale& loc,
|
||||
const S& format_str, Args&&... args) {
|
||||
internal::check_format_string<Args...>(format_str);
|
||||
detail::check_format_string<Args...>(format_str);
|
||||
using context = format_context_t<OutputIt, char_t<S>>;
|
||||
format_arg_store<context, Args...> as{args...};
|
||||
return vformat_to(out, loc, to_string_view(format_str),
|
||||
|
@ -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<char>& out, int error_code,
|
||||
string_view message) FMT_NOEXCEPT;
|
||||
} // namespace internal
|
||||
} // namespace detail
|
||||
|
||||
/** A Windows error. */
|
||||
class windows_error : public system_error {
|
||||
|
@ -17,7 +17,7 @@ FMT_BEGIN_NAMESPACE
|
||||
template <typename Char> class basic_printf_parse_context;
|
||||
template <typename OutputIt, typename Char> class basic_printf_context;
|
||||
|
||||
namespace internal {
|
||||
namespace detail {
|
||||
|
||||
template <class Char> class formatbuf : public std::basic_streambuf<Char> {
|
||||
private:
|
||||
@ -136,14 +136,14 @@ struct fallback_formatter<T, Char, enable_if_t<is_streamable<T, Char>::value>>
|
||||
return std::copy(buffer.begin(), buffer.end(), ctx.out());
|
||||
}
|
||||
};
|
||||
} // namespace internal
|
||||
} // namespace detail
|
||||
|
||||
template <typename Char>
|
||||
void vprint(std::basic_ostream<Char>& os, basic_string_view<Char> format_str,
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
||||
basic_memory_buffer<Char> 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<Char>& os, basic_string_view<Char> format_str,
|
||||
\endrst
|
||||
*/
|
||||
template <typename S, typename... Args,
|
||||
typename Char = enable_if_t<internal::is_string<S>::value, char_t<S>>>
|
||||
typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
|
||||
void print(std::basic_ostream<Char>& os, const S& format_str, Args&&... args) {
|
||||
vprint(os, to_string_view(format_str),
|
||||
internal::make_args_checked<Args...>(format_str, args...));
|
||||
detail::make_args_checked<Args...>(format_str, args...));
|
||||
}
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
|
@ -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 <typename T, typename Context> 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<Context>(
|
||||
arg_ = detail::make_arg<Context>(
|
||||
static_cast<int>(static_cast<target_type>(value)));
|
||||
} else {
|
||||
using unsigned_type = typename make_unsigned_or_bool<target_type>::type;
|
||||
arg_ = internal::make_arg<Context>(
|
||||
arg_ = detail::make_arg<Context>(
|
||||
static_cast<unsigned>(static_cast<unsigned_type>(value)));
|
||||
}
|
||||
} else {
|
||||
@ -102,9 +102,9 @@ template <typename T, typename Context> 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<Context>(static_cast<long long>(value));
|
||||
arg_ = detail::make_arg<Context>(static_cast<long long>(value));
|
||||
} else {
|
||||
arg_ = internal::make_arg<Context>(
|
||||
arg_ = detail::make_arg<Context>(
|
||||
static_cast<typename make_unsigned_or_bool<U>::type>(value));
|
||||
}
|
||||
}
|
||||
@ -133,7 +133,7 @@ template <typename Context> class char_converter {
|
||||
|
||||
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
|
||||
void operator()(T value) {
|
||||
arg_ = internal::make_arg<Context>(
|
||||
arg_ = detail::make_arg<Context>(
|
||||
static_cast<typename Context::char_type>(value));
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ template <typename Char> class printf_width_handler {
|
||||
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
|
||||
unsigned operator()(T value) {
|
||||
auto width = static_cast<uint32_or_64_or_128_t<T>>(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<Char>& buf, basic_string_view<Char> format,
|
||||
basic_format_args<Context> args) {
|
||||
Context(std::back_inserter(buf), format, args).format();
|
||||
}
|
||||
} // namespace internal
|
||||
} // namespace detail
|
||||
|
||||
// For printing into memory_buffer.
|
||||
template <typename Char, typename Context>
|
||||
FMT_DEPRECATED void printf(internal::buffer<Char>& buf,
|
||||
FMT_DEPRECATED void printf(detail::buffer<Char>& buf,
|
||||
basic_string_view<Char> format,
|
||||
basic_format_args<Context> args) {
|
||||
return internal::vprintf(buf, format, args);
|
||||
return detail::vprintf(buf, format, args);
|
||||
}
|
||||
using internal::vprintf;
|
||||
using detail::vprintf;
|
||||
|
||||
template <typename Range> class printf_arg_formatter;
|
||||
|
||||
@ -208,13 +208,13 @@ template <typename OutputIt, typename Char> class basic_printf_context;
|
||||
\endrst
|
||||
*/
|
||||
template <typename Range>
|
||||
class printf_arg_formatter : public internal::arg_formatter_base<Range> {
|
||||
class printf_arg_formatter : public detail::arg_formatter_base<Range> {
|
||||
public:
|
||||
using iterator = typename Range::iterator;
|
||||
|
||||
private:
|
||||
using char_type = typename Range::value_type;
|
||||
using base = internal::arg_formatter_base<Range>;
|
||||
using base = detail::arg_formatter_base<Range>;
|
||||
using context_type = basic_printf_context<iterator, char_type>;
|
||||
|
||||
context_type& context_;
|
||||
@ -240,9 +240,9 @@ class printf_arg_formatter : public internal::arg_formatter_base<Range> {
|
||||
\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 <typename T, FMT_ENABLE_IF(fmt::internal::is_integral<T>::value)>
|
||||
template <typename T, FMT_ENABLE_IF(fmt::detail::is_integral<T>::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 <typename T> struct printf_formatter {
|
||||
|
||||
template <typename FormatContext>
|
||||
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 <typename OutputIt, typename Char> 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<OutputIt, Char>::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 <typename OutputIt, typename Char>
|
||||
@ -432,7 +432,7 @@ int basic_printf_context<OutputIt, Char>::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<OutputIt, Char>::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<int>(visit_format_arg(
|
||||
internal::printf_width_handler<char_type>(specs), get_arg()));
|
||||
detail::printf_width_handler<char_type>(specs), get_arg()));
|
||||
}
|
||||
}
|
||||
return arg_index;
|
||||
@ -491,27 +491,27 @@ OutputIt basic_printf_context<OutputIt, Char>::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<int>(
|
||||
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<Char>(), arg);
|
||||
if (specs.precision >= 0 && arg.type() == detail::type::cstring_type) {
|
||||
auto str = visit_format_arg(detail::get_cstring<Char>(), arg);
|
||||
auto str_end = str + specs.precision;
|
||||
auto nul = std::find(str, str_end, Char());
|
||||
arg = internal::make_arg<basic_printf_context>(basic_string_view<Char>(
|
||||
arg = detail::make_arg<basic_printf_context>(basic_string_view<Char>(
|
||||
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<OutputIt, Char>::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<OutputIt, Char>::format() {
|
||||
specs.type = 'd';
|
||||
break;
|
||||
case 'c':
|
||||
visit_format_arg(internal::char_converter<basic_printf_context>(arg),
|
||||
visit_format_arg(detail::char_converter<basic_printf_context>(arg),
|
||||
arg);
|
||||
break;
|
||||
}
|
||||
@ -588,8 +588,7 @@ OutputIt basic_printf_context<OutputIt, Char>::format() {
|
||||
|
||||
template <typename Char>
|
||||
using basic_printf_context_t =
|
||||
basic_printf_context<std::back_insert_iterator<internal::buffer<Char>>,
|
||||
Char>;
|
||||
basic_printf_context<std::back_insert_iterator<detail::buffer<Char>>, Char>;
|
||||
|
||||
using printf_context = basic_printf_context_t<char>;
|
||||
using wprintf_context = basic_printf_context_t<wchar_t>;
|
||||
@ -640,7 +639,7 @@ inline std::basic_string<Char> vsprintf(
|
||||
\endrst
|
||||
*/
|
||||
template <typename S, typename... Args,
|
||||
typename Char = enable_if_t<internal::is_string<S>::value, char_t<S>>>
|
||||
typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
|
||||
inline std::basic_string<Char> sprintf(const S& format, const Args&... args) {
|
||||
using context = basic_printf_context_t<Char>;
|
||||
return vsprintf(to_string_view(format), make_format_args<context>(args...));
|
||||
@ -668,7 +667,7 @@ inline int vfprintf(
|
||||
\endrst
|
||||
*/
|
||||
template <typename S, typename... Args,
|
||||
typename Char = enable_if_t<internal::is_string<S>::value, char_t<S>>>
|
||||
typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
|
||||
inline int fprintf(std::FILE* f, const S& format, const Args&... args) {
|
||||
using context = basic_printf_context_t<Char>;
|
||||
return vfprintf(f, to_string_view(format),
|
||||
@ -692,7 +691,7 @@ inline int vprintf(
|
||||
\endrst
|
||||
*/
|
||||
template <typename S, typename... Args,
|
||||
FMT_ENABLE_IF(internal::is_string<S>::value)>
|
||||
FMT_ENABLE_IF(detail::is_string<S>::value)>
|
||||
inline int printf(const S& format_str, const Args&... args) {
|
||||
using context = basic_printf_context_t<char_t<S>>;
|
||||
return vprintf(to_string_view(format_str),
|
||||
@ -705,7 +704,7 @@ inline int vfprintf(
|
||||
basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
|
||||
basic_memory_buffer<Char> buffer;
|
||||
vprintf(buffer, to_string_view(format), args);
|
||||
internal::write(os, buffer);
|
||||
detail::write(os, buffer);
|
||||
return static_cast<int>(buffer.size());
|
||||
}
|
||||
|
||||
@ -714,7 +713,7 @@ template <typename ArgFormatter, typename Char,
|
||||
typename Context =
|
||||
basic_printf_context<typename ArgFormatter::iterator, Char>>
|
||||
typename ArgFormatter::iterator vprintf(
|
||||
internal::buffer<Char>& out, basic_string_view<Char> format_str,
|
||||
detail::buffer<Char>& out, basic_string_view<Char> format_str,
|
||||
basic_format_args<type_identity_t<Context>> args) {
|
||||
typename ArgFormatter::iterator iter(out);
|
||||
Context(iter, format_str, args).template format<ArgFormatter>();
|
||||
|
@ -54,7 +54,7 @@ struct formatting_tuple : formatting_base<Char> {
|
||||
static FMT_CONSTEXPR_DECL const bool add_prepostfix_space = false;
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
namespace detail {
|
||||
|
||||
template <typename RangeT, typename OutputIterator>
|
||||
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 <typename T> struct is_tuple_like {
|
||||
static FMT_CONSTEXPR_DECL const bool value =
|
||||
internal::is_tuple_like_<T>::value && !internal::is_range_<T>::value;
|
||||
detail::is_tuple_like_<T>::value && !detail::is_range_<T>::value;
|
||||
};
|
||||
|
||||
template <typename TupleT, typename Char>
|
||||
@ -200,10 +200,10 @@ struct formatter<TupleT, Char, enable_if_t<fmt::is_tuple_like<TupleT>::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<TupleT, Char, enable_if_t<fmt::is_tuple_like<TupleT>::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<FormatContext>{formatting, i, out});
|
||||
detail::for_each(values, format_each<FormatContext>{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<TupleT, Char, enable_if_t<fmt::is_tuple_like<TupleT>::value>> {
|
||||
|
||||
template <typename T, typename Char> struct is_range {
|
||||
static FMT_CONSTEXPR_DECL const bool value =
|
||||
internal::is_range_<T>::value &&
|
||||
!internal::is_like_std_string<T>::value &&
|
||||
detail::is_range_<T>::value && !detail::is_like_std_string<T>::value &&
|
||||
!std::is_convertible<T, std::basic_string<Char>>::value &&
|
||||
!std::is_constructible<internal::std_string_view<Char>, T>::value;
|
||||
!std::is_constructible<detail::std_string_view<Char>, T>::value;
|
||||
};
|
||||
|
||||
template <typename RangeT, typename Char>
|
||||
@ -260,15 +259,15 @@ struct formatter<RangeT, Char,
|
||||
template <typename FormatContext>
|
||||
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<RangeT, Char,
|
||||
}
|
||||
}
|
||||
if (formatting.add_prepostfix_space) *out++ = ' ';
|
||||
return internal::copy(formatting.postfix, out);
|
||||
return detail::copy(formatting.postfix, out);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Char, typename... T> struct tuple_arg_join : internal::view {
|
||||
template <typename Char, typename... T> struct tuple_arg_join : detail::view {
|
||||
const std::tuple<T...>& tuple;
|
||||
basic_string_view<Char> sep;
|
||||
|
||||
@ -299,14 +298,14 @@ struct formatter<tuple_arg_join<Char, T...>, Char> {
|
||||
template <typename FormatContext>
|
||||
typename FormatContext::iterator format(
|
||||
const tuple_arg_join<Char, T...>& value, FormatContext& ctx) {
|
||||
return format(value, ctx, internal::make_index_sequence<sizeof...(T)>{});
|
||||
return format(value, ctx, detail::make_index_sequence<sizeof...(T)>{});
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename FormatContext, size_t... N>
|
||||
typename FormatContext::iterator format(
|
||||
const tuple_arg_join<Char, T...>& value, FormatContext& ctx,
|
||||
internal::index_sequence<N...>) {
|
||||
detail::index_sequence<N...>) {
|
||||
return format_args(value, ctx, std::get<N>(value.tuple)...);
|
||||
}
|
||||
|
||||
@ -369,13 +368,13 @@ FMT_CONSTEXPR tuple_arg_join<wchar_t, T...> join(const std::tuple<T...>& tuple,
|
||||
\endrst
|
||||
*/
|
||||
template <typename T>
|
||||
arg_join<internal::iterator_t<const std::initializer_list<T>>, char> join(
|
||||
arg_join<detail::iterator_t<const std::initializer_list<T>>, char> join(
|
||||
std::initializer_list<T> list, string_view sep) {
|
||||
return join(std::begin(list), std::end(list), sep);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
arg_join<internal::iterator_t<const std::initializer_list<T>>, wchar_t> join(
|
||||
arg_join<detail::iterator_t<const std::initializer_list<T>>, wchar_t> join(
|
||||
std::initializer_list<T> list, wstring_view sep) {
|
||||
return join(std::begin(list), std::end(list), sep);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "fmt/format-inl.h"
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
namespace internal {
|
||||
namespace detail {
|
||||
|
||||
template <typename T>
|
||||
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<void>;
|
||||
template struct FMT_INSTANTIATION_DEF_API detail::basic_data<void>;
|
||||
|
||||
// Workaround a bug in MSVC2013 that prevents instantiation of format_float.
|
||||
int (*instantiate_format_float)(double, int, internal::float_specs,
|
||||
internal::buffer<char>&) =
|
||||
internal::format_float;
|
||||
int (*instantiate_format_float)(double, int, detail::float_specs,
|
||||
detail::buffer<char>&) = 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<std::locale>() const;
|
||||
template FMT_API detail::locale_ref::locale_ref(const std::locale& loc);
|
||||
template FMT_API std::locale detail::locale_ref::get<std::locale>() const;
|
||||
#endif
|
||||
|
||||
// Explicit instantiations for char.
|
||||
|
||||
template FMT_API std::string internal::grouping_impl<char>(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<char>(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<char>::append(const char*, const char*);
|
||||
template FMT_API void detail::buffer<char>::append(const char*, const char*);
|
||||
|
||||
template FMT_API std::string internal::vformat<char>(
|
||||
template FMT_API std::string detail::vformat<char>(
|
||||
string_view, basic_format_args<format_context>);
|
||||
|
||||
template FMT_API format_context::iterator internal::vformat_to(
|
||||
internal::buffer<char>&, string_view, basic_format_args<format_context>);
|
||||
template FMT_API format_context::iterator detail::vformat_to(
|
||||
detail::buffer<char>&, string_view, basic_format_args<format_context>);
|
||||
|
||||
template FMT_API int internal::snprintf_float(double, int,
|
||||
internal::float_specs,
|
||||
internal::buffer<char>&);
|
||||
template FMT_API int internal::snprintf_float(long double, int,
|
||||
internal::float_specs,
|
||||
internal::buffer<char>&);
|
||||
template FMT_API int internal::format_float(double, int, internal::float_specs,
|
||||
internal::buffer<char>&);
|
||||
template FMT_API int internal::format_float(long double, int,
|
||||
internal::float_specs,
|
||||
internal::buffer<char>&);
|
||||
template FMT_API int detail::snprintf_float(double, int, detail::float_specs,
|
||||
detail::buffer<char>&);
|
||||
template FMT_API int detail::snprintf_float(long double, int,
|
||||
detail::float_specs,
|
||||
detail::buffer<char>&);
|
||||
template FMT_API int detail::format_float(double, int, detail::float_specs,
|
||||
detail::buffer<char>&);
|
||||
template FMT_API int detail::format_float(long double, int, detail::float_specs,
|
||||
detail::buffer<char>&);
|
||||
|
||||
// Explicit instantiations for wchar_t.
|
||||
|
||||
template FMT_API std::string internal::grouping_impl<wchar_t>(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<wchar_t>(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<wchar_t>::append(const wchar_t*,
|
||||
const wchar_t*);
|
||||
template FMT_API void detail::buffer<wchar_t>::append(const wchar_t*,
|
||||
const wchar_t*);
|
||||
FMT_END_NAMESPACE
|
||||
|
16
src/os.cc
16
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<int>(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<char>& out, int error_code,
|
||||
string_view message) FMT_NOEXCEPT {
|
||||
void detail::format_windows_error(detail::buffer<char>& 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<char>& 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) {
|
||||
|
@ -40,8 +40,8 @@ using testing::StrictMock;
|
||||
#if FMT_USE_CONSTEXPR
|
||||
template <unsigned EXPECTED_PARTS_COUNT, typename Format>
|
||||
void check_prepared_parts_type(Format format) {
|
||||
typedef fmt::internal::compiled_format_base<decltype(format)> provider;
|
||||
typedef fmt::internal::format_part<char>
|
||||
typedef fmt::detail::compiled_format_base<decltype(format)> provider;
|
||||
typedef fmt::detail::format_part<char>
|
||||
expected_parts_type[EXPECTED_PARTS_COUNT];
|
||||
static_assert(std::is_same<typename provider::parts_container,
|
||||
expected_parts_type>::value,
|
||||
@ -85,11 +85,11 @@ TEST(CompileTest, PassCompileString) {
|
||||
TEST(CompileTest, FormatToArrayOfChars) {
|
||||
char buffer[32] = {0};
|
||||
const auto prepared = fmt::compile<int>("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<int>(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);
|
||||
}
|
||||
|
||||
|
@ -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 <typename Context, typename T>
|
||||
basic_format_arg<Context> make_arg(const T& value) {
|
||||
return fmt::internal::make_arg<Context>(value);
|
||||
return fmt::detail::make_arg<Context>(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<char>& const_buffer = buffer;
|
||||
const fmt::detail::buffer<char>& 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<custom_context> arg(
|
||||
fmt::internal::arg_mapper<custom_context>().map(t));
|
||||
fmt::detail::value<custom_context> arg(
|
||||
fmt::detail::arg_mapper<custom_context>().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 <typename Char>
|
||||
bool operator==(custom_value<Char> lhs, custom_value<Char> 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<fmt::format_context>::handle h) const {
|
||||
struct test_buffer : fmt::internal::buffer<char> {
|
||||
struct test_buffer : fmt::detail::buffer<char> {
|
||||
char data[10];
|
||||
test_buffer() : fmt::internal::buffer<char>(data, 0, 10) {}
|
||||
test_buffer() : fmt::detail::buffer<char>(data, 0, 10) {}
|
||||
void grow(size_t) {}
|
||||
} buffer;
|
||||
fmt::internal::buffer<char>& base = buffer;
|
||||
fmt::detail::buffer<char>& 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<Char> {};
|
||||
} // namespace
|
||||
|
||||
TYPED_TEST(IsStringTest, IsString) {
|
||||
EXPECT_TRUE(fmt::internal::is_string<TypeParam*>::value);
|
||||
EXPECT_TRUE(fmt::internal::is_string<const TypeParam*>::value);
|
||||
EXPECT_TRUE(fmt::internal::is_string<TypeParam[2]>::value);
|
||||
EXPECT_TRUE(fmt::internal::is_string<const TypeParam[2]>::value);
|
||||
EXPECT_TRUE(fmt::internal::is_string<std::basic_string<TypeParam>>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_string<TypeParam*>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_string<const TypeParam*>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_string<TypeParam[2]>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_string<const TypeParam[2]>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_string<std::basic_string<TypeParam>>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_string<fmt::basic_string_view<TypeParam>>::value);
|
||||
EXPECT_TRUE(
|
||||
fmt::internal::is_string<fmt::basic_string_view<TypeParam>>::value);
|
||||
EXPECT_TRUE(
|
||||
fmt::internal::is_string<derived_from_string_view<TypeParam>>::value);
|
||||
using string_view = fmt::internal::std_string_view<TypeParam>;
|
||||
fmt::detail::is_string<derived_from_string_view<TypeParam>>::value);
|
||||
using string_view = fmt::detail::std_string_view<TypeParam>;
|
||||
EXPECT_TRUE(std::is_empty<string_view>::value !=
|
||||
fmt::internal::is_string<string_view>::value);
|
||||
EXPECT_TRUE(fmt::internal::is_string<my_ns::my_string<TypeParam>>::value);
|
||||
EXPECT_FALSE(fmt::internal::is_string<my_ns::non_string>::value);
|
||||
fmt::detail::is_string<string_view>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_string<my_ns::my_string<TypeParam>>::value);
|
||||
EXPECT_FALSE(fmt::detail::is_string<my_ns::non_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<char>("42")), "42");
|
||||
fmt::internal::type type =
|
||||
fmt::internal::mapped_type_constant<my_string<char>,
|
||||
fmt::format_context>::value;
|
||||
EXPECT_EQ(type, fmt::internal::type::string_type);
|
||||
fmt::detail::type type =
|
||||
fmt::detail::mapped_type_constant<my_string<char>,
|
||||
fmt::format_context>::value;
|
||||
EXPECT_EQ(type, fmt::detail::type::string_type);
|
||||
}
|
||||
|
||||
TEST(CoreTest, FormatForeignStrings) {
|
||||
|
@ -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<bigint>::value, "");
|
||||
static_assert(!std::is_copy_assignable<bigint>::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<uint32_t>(acc), 34);
|
||||
acc += 56;
|
||||
EXPECT_EQ(acc.lower, 90);
|
||||
acc += fmt::internal::max_value<uint64_t>();
|
||||
acc += fmt::detail::max_value<uint64_t>();
|
||||
EXPECT_EQ(acc.upper, 13);
|
||||
EXPECT_EQ(acc.lower, 89);
|
||||
acc >>= 32;
|
||||
@ -262,7 +262,7 @@ TEST(FPTest, GetCachedPower) {
|
||||
typedef std::numeric_limits<double> 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 <typename T> struct value_extractor {
|
||||
@ -330,11 +330,11 @@ template <typename T> 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 <typename T> struct value_extractor {
|
||||
|
||||
TEST(FormatTest, ArgConverter) {
|
||||
long long value = max_value<long long>();
|
||||
auto arg = fmt::internal::make_arg<fmt::format_context>(value);
|
||||
auto arg = fmt::detail::make_arg<fmt::format_context>(value);
|
||||
fmt::visit_format_arg(
|
||||
fmt::internal::arg_converter<long long, fmt::format_context>(arg, 'd'),
|
||||
fmt::detail::arg_converter<long long, fmt::format_context>(arg, 'd'),
|
||||
arg);
|
||||
EXPECT_EQ(value, fmt::visit_format_arg(value_extractor<long long>(), 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<fmt::internal::char8_type>(
|
||||
reinterpret_cast<const fmt::internal::char8_type*>("ёжик"))));
|
||||
EXPECT_EQ(4,
|
||||
fmt::detail::count_code_points(
|
||||
fmt::basic_string_view<fmt::detail::char8_type>(
|
||||
reinterpret_cast<const fmt::detail::char8_type*>("ёжик"))));
|
||||
}
|
||||
|
||||
// Tests fmt::internal::count_digits for integer type Int.
|
||||
// Tests fmt::detail::count_digits for integer type Int.
|
||||
template <typename Int> 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<Int>() / 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<char>(
|
||||
fmt::detail::write_ptr<char>(
|
||||
std::back_inserter(s),
|
||||
fmt::internal::fallback_uintptr(reinterpret_cast<void*>(0xface)),
|
||||
nullptr);
|
||||
fmt::detail::fallback_uintptr(reinterpret_cast<void*>(0xface)), nullptr);
|
||||
EXPECT_EQ(s, "0xface");
|
||||
}
|
||||
|
@ -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<uint32_pair>(uint64_t{42});
|
||||
EXPECT_EQ(fmt::internal::bit_cast<uint64_t>(s), 42ull);
|
||||
s = fmt::internal::bit_cast<uint32_pair>(uint64_t(~0ull));
|
||||
EXPECT_EQ(fmt::internal::bit_cast<uint64_t>(s), ~0ull);
|
||||
auto s = fmt::detail::bit_cast<uint32_pair>(uint64_t{42});
|
||||
EXPECT_EQ(fmt::detail::bit_cast<uint64_t>(s), 42ull);
|
||||
s = fmt::detail::bit_cast<uint32_pair>(uint64_t(~0ull));
|
||||
EXPECT_EQ(fmt::detail::bit_cast<uint64_t>(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<char*> it(p, 3);
|
||||
fmt::detail::truncating_iterator<char*> 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<decltype(bi)> it(bi, 2);
|
||||
fmt::detail::truncating_iterator<decltype(bi)> 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<char*>::value);
|
||||
EXPECT_FALSE(fmt::internal::is_output_iterator<const char*>::value);
|
||||
EXPECT_FALSE(fmt::internal::is_output_iterator<std::string>::value);
|
||||
EXPECT_TRUE(fmt::internal::is_output_iterator<
|
||||
EXPECT_TRUE(fmt::detail::is_output_iterator<char*>::value);
|
||||
EXPECT_FALSE(fmt::detail::is_output_iterator<const char*>::value);
|
||||
EXPECT_FALSE(fmt::detail::is_output_iterator<std::string>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_output_iterator<
|
||||
std::back_insert_iterator<std::string>>::value);
|
||||
EXPECT_TRUE(fmt::internal::is_output_iterator<std::string::iterator>::value);
|
||||
EXPECT_TRUE(fmt::detail::is_output_iterator<std::string::iterator>::value);
|
||||
EXPECT_FALSE(
|
||||
fmt::internal::is_output_iterator<std::string::const_iterator>::value);
|
||||
EXPECT_FALSE(fmt::internal::is_output_iterator<std::list<char>>::value);
|
||||
fmt::detail::is_output_iterator<std::string::const_iterator>::value);
|
||||
EXPECT_FALSE(fmt::detail::is_output_iterator<std::list<char>>::value);
|
||||
EXPECT_TRUE(
|
||||
fmt::internal::is_output_iterator<std::list<char>::iterator>::value);
|
||||
EXPECT_FALSE(fmt::internal::is_output_iterator<
|
||||
std::list<char>::const_iterator>::value);
|
||||
EXPECT_FALSE(fmt::internal::is_output_iterator<uint32_pair>::value);
|
||||
fmt::detail::is_output_iterator<std::list<char>::iterator>::value);
|
||||
EXPECT_FALSE(
|
||||
fmt::detail::is_output_iterator<std::list<char>::const_iterator>::value);
|
||||
EXPECT_FALSE(fmt::detail::is_output_iterator<uint32_pair>::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<max_packed_args>::format(format_str),
|
||||
format_error, "argument not found");
|
||||
@ -961,7 +961,7 @@ TEST(FormatterTest, Precision) {
|
||||
EXPECT_THROW_MSG(format("{0:.2f}", reinterpret_cast<void*>(0xcafe)),
|
||||
format_error,
|
||||
"precision not allowed for this argument type");
|
||||
EXPECT_THROW_MSG(format("{:.{}e}", 42.0, fmt::internal::max_value<int>()),
|
||||
EXPECT_THROW_MSG(format("{:.{}e}", 42.0, fmt::detail::max_value<int>()),
|
||||
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<fmt::basic_format_arg<ctx>> args;
|
||||
args.emplace_back(fmt::internal::make_arg<ctx>(42));
|
||||
args.emplace_back(fmt::internal::make_arg<ctx>("abc1"));
|
||||
args.emplace_back(fmt::internal::make_arg<ctx>(1.5f));
|
||||
args.emplace_back(fmt::detail::make_arg<ctx>(42));
|
||||
args.emplace_back(fmt::detail::make_arg<ctx>("abc1"));
|
||||
args.emplace_back(fmt::detail::make_arg<ctx>(1.5f));
|
||||
|
||||
std::string result = fmt::vformat(
|
||||
"{} and {} and {}",
|
||||
@ -1808,7 +1808,7 @@ TEST(FormatTest, StrongEnum) {
|
||||
using buffer_range = fmt::buffer_range<char>;
|
||||
|
||||
class mock_arg_formatter
|
||||
: public fmt::internal::arg_formatter_base<buffer_range> {
|
||||
: public fmt::detail::arg_formatter_base<buffer_range> {
|
||||
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<buffer_range> base;
|
||||
typedef fmt::detail::arg_formatter_base<buffer_range> 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 T>
|
||||
typename std::enable_if<fmt::internal::is_integral<T>::value, iterator>::type
|
||||
typename std::enable_if<fmt::detail::is_integral<T>::value, iterator>::type
|
||||
operator()(T value) {
|
||||
call(value);
|
||||
return base::operator()(value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<!fmt::internal::is_integral<T>::value, iterator>::type
|
||||
typename std::enable_if<!fmt::detail::is_integral<T>::value, iterator>::type
|
||||
operator()(T value) {
|
||||
return base::operator()(value);
|
||||
}
|
||||
@ -2020,7 +2020,7 @@ struct test_arg_id_handler {
|
||||
template <size_t N>
|
||||
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<char> width_ref;
|
||||
fmt::detail::arg_ref<char> width_ref;
|
||||
int precision = 0;
|
||||
fmt::internal::arg_ref<char> precision_ref;
|
||||
fmt::detail::arg_ref<char> 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 <size_t N>
|
||||
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 <typename Id>
|
||||
FMT_CONSTEXPR fmt::basic_format_arg<test_context> arg(Id id) {
|
||||
return fmt::internal::make_arg<test_context>(id);
|
||||
return fmt::detail::make_arg<test_context>(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<test_parse_context, test_context> h(
|
||||
fmt::detail::specs_handler<test_parse_context, test_context> h(
|
||||
specs, parse_ctx, ctx);
|
||||
parse_format_specs(s, s + N, h);
|
||||
return specs;
|
||||
@ -2167,11 +2167,11 @@ TEST(FormatTest, ConstexprSpecsHandler) {
|
||||
}
|
||||
|
||||
template <size_t N>
|
||||
FMT_CONSTEXPR fmt::internal::dynamic_format_specs<char> parse_dynamic_specs(
|
||||
FMT_CONSTEXPR fmt::detail::dynamic_format_specs<char> parse_dynamic_specs(
|
||||
const char (&s)[N]) {
|
||||
fmt::internal::dynamic_format_specs<char> specs;
|
||||
fmt::detail::dynamic_format_specs<char> specs;
|
||||
test_parse_context ctx{};
|
||||
fmt::internal::dynamic_specs_handler<test_parse_context> h(specs, ctx);
|
||||
fmt::detail::dynamic_specs_handler<test_parse_context> h(specs, ctx);
|
||||
parse_format_specs(s, s + N, h);
|
||||
return specs;
|
||||
}
|
||||
@ -2195,8 +2195,8 @@ TEST(FormatTest, ConstexprDynamicSpecsHandler) {
|
||||
|
||||
template <size_t N>
|
||||
FMT_CONSTEXPR test_format_specs_handler check_specs(const char (&s)[N]) {
|
||||
fmt::internal::specs_checker<test_format_specs_handler> checker(
|
||||
test_format_specs_handler(), fmt::internal::type::double_type);
|
||||
fmt::detail::specs_checker<test_format_specs_handler> 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 <size_t N> FMT_CONSTEXPR bool parse_string(const char (&s)[N]) {
|
||||
test_format_string_handler h;
|
||||
fmt::internal::parse_format_string<true>(fmt::string_view(s, N - 1), h);
|
||||
fmt::detail::parse_format_string<true>(fmt::string_view(s, N - 1), h);
|
||||
return !h.error;
|
||||
}
|
||||
|
||||
@ -2283,9 +2283,9 @@ template <typename... Args>
|
||||
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<char, test_error_handler, Args...>
|
||||
checker(s, test_error_handler(actual_error));
|
||||
fmt::internal::parse_format_string<true>(s, checker);
|
||||
fmt::detail::format_string_checker<char, test_error_handler, Args...> checker(
|
||||
s, test_error_handler(actual_error));
|
||||
fmt::detail::parse_format_string<true>(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<context> arg = fmt::internal::make_arg<context>(42);
|
||||
fmt::basic_format_arg<context> arg = fmt::detail::make_arg<context>(42);
|
||||
fmt::basic_format_args<context> 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<wcontext> warg = fmt::internal::make_arg<wcontext>(42);
|
||||
fmt::basic_format_arg<wcontext> warg = fmt::detail::make_arg<wcontext>(42);
|
||||
fmt::basic_format_args<wcontext> 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>::char_type c;
|
||||
(void)c;
|
||||
@ -2434,13 +2434,12 @@ template <typename S> std::string from_u8str(const S& str) {
|
||||
}
|
||||
|
||||
TEST(FormatTest, FormatUTF8Precision) {
|
||||
using str_type = std::basic_string<fmt::internal::char8_type>;
|
||||
str_type format(
|
||||
reinterpret_cast<const fmt::internal::char8_type*>(u8"{:.4}"));
|
||||
str_type str(reinterpret_cast<const fmt::internal::char8_type*>(
|
||||
using str_type = std::basic_string<fmt::detail::char8_type>;
|
||||
str_type format(reinterpret_cast<const fmt::detail::char8_type*>(u8"{:.4}"));
|
||||
str_type str(reinterpret_cast<const fmt::detail::char8_type*>(
|
||||
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)));
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include "gmock.h"
|
||||
|
||||
using fmt::internal::max_value;
|
||||
using fmt::detail::max_value;
|
||||
|
||||
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
|
||||
template <typename Char> struct numpunct : std::numpunct<Char> {
|
||||
|
@ -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<Char> str = fmt::basic_string_view<Char>(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<fmt::internal::utf16_to_utf8, wchar_t>(
|
||||
check_utf_conversion_error<fmt::detail::utf16_to_utf8, wchar_t>(
|
||||
"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<LPWSTR>(&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<size_t>();
|
||||
fmt::internal::format_windows_error(actual_message, ERROR_FILE_EXISTS,
|
||||
fmt::string_view(0, max_size));
|
||||
auto max_size = fmt::detail::max_value<size_t>();
|
||||
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<LPWSTR>(&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"),
|
||||
|
@ -74,12 +74,12 @@ struct test_arg_formatter : fmt::arg_formatter<range> {
|
||||
|
||||
TEST(OStreamTest, CustomArg) {
|
||||
fmt::memory_buffer buffer;
|
||||
fmt::internal::buffer<char>& base = buffer;
|
||||
fmt::detail::buffer<char>& 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<fmt::format_context>(streamable_enum()));
|
||||
af, fmt::detail::make_arg<fmt::format_context>(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<size_t>();
|
||||
std::streamsize max_streamsize = fmt::internal::max_value<std::streamsize>();
|
||||
if (max_size <= fmt::internal::to_unsigned(max_streamsize)) return;
|
||||
size_t max_size = fmt::detail::max_value<size_t>();
|
||||
std::streamsize max_streamsize = fmt::detail::max_value<std::streamsize>();
|
||||
if (max_size <= fmt::detail::to_unsigned(max_streamsize)) return;
|
||||
|
||||
struct test_buffer : fmt::internal::buffer<char> {
|
||||
struct test_buffer : fmt::detail::buffer<char> {
|
||||
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<std::streamsize>::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<std::streamsize>(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<char>() const {
|
||||
explicit operator fmt::detail::std_string_view<char>() const {
|
||||
return {"foo", 3u};
|
||||
}
|
||||
};
|
||||
|
@ -261,8 +261,8 @@ TEST(FileTest, Size) {
|
||||
EXPECT_EQ(content.size(), static_cast<unsigned long long>(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;
|
||||
|
@ -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<U>();
|
||||
using fmt::internal::const_check;
|
||||
using fmt::detail::const_check;
|
||||
if (const_check(max <= static_cast<unsigned>(max_value<int>()))) {
|
||||
signed_value = static_cast<int>(value);
|
||||
unsigned_value = static_cast<unsigned long long>(value);
|
||||
|
@ -75,7 +75,7 @@ template <> struct scanner<tm> {
|
||||
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;
|
||||
|
22
test/scan.h
22
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<T*>(arg), ctx));
|
||||
}
|
||||
};
|
||||
} // namespace internal
|
||||
} // namespace detail
|
||||
|
||||
struct scan_args {
|
||||
int size;
|
||||
const internal::scan_arg* data;
|
||||
const detail::scan_arg* data;
|
||||
|
||||
template <size_t N>
|
||||
scan_args(const std::array<internal::scan_arg, N>& store)
|
||||
scan_args(const std::array<detail::scan_arg, N>& 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 <typename... Args>
|
||||
std::array<internal::scan_arg, sizeof...(Args)> make_scan_args(Args&... args) {
|
||||
std::array<detail::scan_arg, sizeof...(Args)> 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<false>(format_str, h);
|
||||
detail::scan_handler h(format_str, input, args);
|
||||
detail::parse_format_string<false>(format_str, h);
|
||||
return input.begin() + (h.pos() - &*input.begin());
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ template <> struct std::formatter<S> {
|
||||
if constexpr (!is_integral_v<type> || is_same_v<type, bool>)
|
||||
throw format_error("width is not integral");
|
||||
// else if (value < 0 || value > numeric_limits<int>::max())
|
||||
else if (fmt::internal::is_negative(value) ||
|
||||
else if (fmt::detail::is_negative(value) ||
|
||||
value > numeric_limits<int>::max())
|
||||
throw format_error("invalid width");
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user