d4c6fa3122
cd4af11ef Update version 1ebc2f7cc Bump version f4c997062 Fix changelog 72920ba30 Update changelog 0907c08ae Fix handling of default alignmment with locale (#1801) 37c8f4eaf Don't use 128 bit integers with clang-cl (#1800) eaaaec999 Workaround a bug in msvc ccf8561cb Workaround broken numeric_limites, part 2 (#1787) 0cc73ebf7 Report error on missing named argument (#1796) 33efc3c94 Fix handling of iterators in locale-specific formatting (#1782) b9d749095 Update version 86b63bb71 Bump version cbf6be960 Update changelog 229ee9b46 Workaround broken numeric_limits (#1725) 2b7a146fa Fix a regression in handling digit separators (#1782) 89d0c7124 Fix compatibility with CMake 3.4 (#1779) f19b1a521 Update version 5c67fefb2 Fix a changelog entry 1d2a556e1 Fix undefined reference error 04c9b62fb Merge release branch 6be6762e5 Fix date f1dd2eb3c Bump version fbf3b943c Workaround a bug in gcc a29a01d30 Fix docs 9f0b3afb7 Bump version in namespace 86b2f99f8 Fix the docs c472ff12d Update version 5173a76ba Update version 1614af352 Minor corrections in the changelog 569a9b3a7 Bump version 4e7e3c65a Update docs 0f7a6bfa1 Add a section on std::format compatibility 4faec5a5e Update README.rst 7dbc8ac71 Update changelog c87dd746f Update changelog 372175caf Revert changelog changes 904754876 Add ClickHouse to the list of projects (#1751) d30bca64e Revert changelog conversion since GFM is not supported there d6047cdc4 Update changelog 810241b36 Convert changlog to markdown 661c47473 Rename changelog 7c33059fa Update ChangeLog.rst 9e20883ab Update README.rst 41899d522 Update changelog f42f45908 Update changelog 2381df654 Update readme 7ae816563 Update README.rst c56cf3d07 Update changelog and readme 01309a34a Deprecate arg_formatter a62d06055 Update changelog 23e3a2eee Update changelog d8e0554b9 Disable numeric formatting by default 1e8eea4f4 Update changelog 44bd5384a Fix formatting 20e19387a Update changelog 56fed7814 FMT_NUMERIC_ALIGN -> FMT_DEPRECATED_NUMERIC_ALIGN 56e63078f Make the n specifier an opt-in 31ce6bc70 Fix a conversion warning with Clang10 on Windows (#1750) c9c5b90da Fix a typo. Thanks Tracy Chapman from TripleChecker 1f3f84631 Fix a typo 5de62af60 Fix possible infinite recursion in FMT_ASSERT (#1744) cbddab2fe Use consistent include style f69b6eaab Add a simple buffered stream with no sync ba363b3a2 Use digit pairs as in unrolledlut a6f8e7d86 Update changelog e753244ab Update changelog 98a7a8b40 Update changelog and disable internal 3135d95fd Don't use non-portable attribute 8630a8f5f Tweak the docs cc3a88e6b Extract docs from compile.h 79c4b6bd7 Apply clang-format d130ee070 Document format string compilation d0f90b5be Spelling fixes 6e080660d Update README.rst 31c3a2426 Spelling fixes 613b3b459 Spelling fixes 978521bb8 Fix a compile error introduced in #1738 4e94c649f Deprecate compile 1a83443e6 Add user-defined type support to compilation 8bef1c3b3 Tweaks for EDG based compilers (Intel, nVidia, MCST/Elbrus, etc). b287c37c6 Do not use -Wl,--as-needed with emscripten. 2cac8a9d2 Reintroduce UDT support to fmt::to_string and test ADL 9a4cc8842 Add FMT_COMPILE support to format_to 5ddf9ee1b Streamline default FP formatting 0b3a83f7f Update README.rst 5aa5c9873 Added #define WIN32_LEAN_AND_MEAN before including windows.h (#1729) 397ad1bec Optimize common case 7431165f3 Make to_string bypass format ee4d4c7fd Inline compiled format ab2f8484e Finish text::format e900d735b Re-enable assert in format_decimal f4de7b684 Fix ambiguity 1f8f5450b Reuse format_decimal d702a68df Fix formatting of bool with FMT_COMPILE and add more tests e956a14e9 Use write instead of format_int in to_string 98dcc251e Undo branching reduction 5b8641ddd Undo branching reduction 8c88abde6 Fix sign handling in 'L' 23b976a61 Reduce branching 9edee0e72 Optimize small string parsing a909d42b7 Fix a warning 16637341b Enable compilation for all types 2d71d7e03 Add a simple format string compilation API d259fcfb0 Tweak comments 704ed557a Move project in order to solve a CMake warning 8603bd20d Update README.rst 547f12ae6 Fix a warning (#1722) f904e8a1b c++11 use formatting user-defined types (#1721) 100e8af08 Update README.rst c11d0f056 Update README.rst 2453ee576 Improve default formatting 47ae52155 MINGW cross compiler fixes 936a1833c Add default_arg_formatter f2c9cb624 Fix a UB d3107f855 Cleanup arg_formatter_base 5e7c70e20 Simplify arg_formatter_base 38cc68b3e Inline visitor 6732ea500 Make symbols readable 57ddc77ce Make advance_to a noop for back_insert_iterator 50bad7d62 Optimize format string parsing 8f7a824e4 Inline visit f11e96870 Optimize format string parsing 09737dd83 Optimize format handler d9e3d6e6e Move format_handler to detail 795b47a7b Fix a warning (#1712) 95c6ac0cc fix typo which caused the loss of the counting information when using a printf context with a truncating_iterator 21409cfdd Fix warnings 88c8d534e Move digits10 to where they belong and add comments 0f3eaeac0 Fix a warning 344218510 Ignore /doc/node_modules directory 16aec0617 Cleanup arg_formatter_base 1e1193590 Fix format_decimal overloads 0893c9c2e Inline parse_format_string 3245145a4 Remove undocumented buffer_range and output_range 57fc44907 Increase VM disk size 7d22bebb6 Remove uses of buffer_range 8f2b5fe74 Don't install sphinx cache files f095c67b6 Remove uses of buffer_range 5aabf1f71 Simplify copy_str 19c5b5d15 Simplify arg_formatter 519571ede Simplify arg_formatter_base ac8dfd841 Improve handling of separators 2c6165a22 Reduce the number of comparisons 28639969e Use memcpy for copying digits f5fa1dee5 Support custom FMT_INC_DIR in pkgconfig and cmake configs (#1702) 51bf9cfac Fix Mingw support 1a716caf5 Optimize common case 98d4bbf81 Update README.rst 8c8f74a87 fix zero flag for char types and make zero flag ignored if a precision is specified bc1b89da2 Temporarily revert parsing changes a7fb321ac Remove a redundant branch 8cadb9650 fix max/min macro (#1697) 297c3b2ed Fix an example (thanks Alexey Kuzmenko) 943532fec Make ostream formatter work with compile-time format strings (#1692) bd8804019 Update README.rst f230300ac Knuth is using fmt library (#1691) a265e25b7 Optimize small string parsing 2aa2526f6 Optimize small string concatenation 8d78045e7 Move void_t to where it's used 7aafa6bc6 Update analytics c66aae165 Adding sentinel support to fmt::join(). (#1689) 6d66de380 Add c specifier support to integral types (#1652) 6b219a58d fix interaction of space flag and '+' flag, as well as '-' flag and '0' flag (#1687) eee2023c2 Update signatures c5ed73aab Add fmt::detail::buffer to the docs (#704) ea1cd9638 Fix apidoc d3964d7b1 Merge branch 'master' of github.com:fmtlib/fmt d18c6723a Update docs 96c18b26c make plus flag for printf not be ignored for char argument (#1683) ba25baeb9 Apply doc patch to 6.2.1 981b517cc nested replacement fields may omit arg_id (#1681) 922ea924b Make dynamic_format_arg_store reusable and add reserve() (#1677) e0d98923c Update version 806926537 internal -> detail (#1538) 963ee0831 Simplify named arguments 02a6fe59f Named arguments go brrr de290f5c4 Ditch internal::arg_map d0623de51 Bump version 73e335ed3 Make implicit capture explicit for C++20 (#1669) b4d46e398 Update changelog a182f7341 Update changelog 68201831a Support named args in dynamic_format_arg_store (#1655). (#1663) 7f723fbcb Consistently namespace qualify size_t c06851456 Purge basic_writer 2f05054dd Purge basic_writer f0ce21164 Revert enum change 44639b11f Fix some warnings (#1667) 1c86a99e8 Purge basic_writer 8f511fc12 Make copyfmt not throw (#1666) 59fe455f3 Remove compatibility stubs b0f47a13e Separate nonfinite formatting d6cea50d0 Remove deprecated APIs 40bc7163f Move FMT_MAYBE_UNUSED to where it's actually used 080e44d0b Fix inconsistent type detection (#1662) 7e57cace5 Exclude std::abort from compilation when compiling CUDA with Clang (#1661) 7b66e2f21 Inherit arg_formatter_base from basic_writer bab3f5800 Refactor pointer formatting 9cc7edfdd Move int_writer to the namespace scope 8d9d528bf Improve handling of alignment 8efd1a8ef Improve handling of alignment a71bc9c82 Use '0' fill with numeric align for consistency with std::format 60d85d598 Suppress ubsan warning c3099beb6 Cleanup cbb4cb899 Remove undocumented deprecated APIs b85e9ac38 Simplify vformat_to e3710ab97 FMT_CONSTEXPR -> constexpr d59751f0f Update date formatting example to use threadsafe localtime d6abb2fa0 Reduce library size e9fdea90b Update README.rst 44b6584f2 Update README.rst 78f041ab5 build: Fix installation paths 7ca89bf87 Reduce template bloat in write_int 3c114d091 Fix a shadowing warning (#1658) e2ef12a8c Allow to avoid inclusion of os.cc in fmt target bca82719a Pass iterator by value 99da38962 Make write_padded non-members f19d66794 Bump fuzzer allocation limit 3e6984761 Reduce branching in write_padded 9ac1eebd4 Reduce library size e2ff91067 Replace FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION with fmt-specific macro (#1650) f2ed03b91 Fix a warning (#1649) 9dde9f013 Reduce library size b1af642d1 Reduce library size 4a617f25c Clarify encoding conversion in chrono 6f435f55c Improve compile time by using extern template (#1452) cb475cb88 Clarify why we don't check argument id 1e1ac6e96 Check dynamic width/precision id at compile time (#1614) e51c449fe Revert "Check dynamic widht/precision id at compile time (#1614)" 0463665ef Don't access a C string past precision in printf (#1595) 7d748a6f8 Check dynamic widht/precision id at compile time (#1614) 2b75bd7ce Get rid of do_check_format_string 4a1d5931c Simplify udl_formatter with FMT_STRING 811b0f905 Enable compile-time error tests 450e8eed9 Fix markup b8fbcec1b Clarify formatter reuse 56bc86ffa Suppress bogus MSVC analysis warnings 3f79357ef Fix a recent regression in handling max packed arguments 8a11148f9 Add Facebook Folly to the list of projects e371e8b68 Tweak readme 813732fed Improve readme formatting 3670d5b3f README: add vectorized.io/redpanda in the list of users 9e2ad7cf6 Add windows terminal to the projects using {fmt} 63479c851 Use a delegating ctor and add inlines 5944fcad3 Remove remaining wchar_t instantiation e253b371b Don't generate RTTI for allocator 0c86f467b Fix build on ancient gcc 1929df4bc Simplify format_args a13822181 Always inline arg_data functions 04e0dfd4b Always inline value ctors 04cde756b Simplify checks c9a57b9a8 Fix incorrect assumptions about nul termination f46f5ecaf Reenable constexpr _compile on GCC 9 6e8d7e277 Don't use constexpr on Intel compiler (#1628) 567ed03f8 Merge arg overloads and cleanup c3fa33314 Remove warning in core.h with when compiling with gcc and -Wshadow 84898b462 Remove warning in format.h when compiling with gcc and -Wshadow 538d83fd0 Cleanup named arguments 8a4630686 Improve handling of named arguments a9d62d3f3 Add check for CompiledFormat to avoid ambiguous call fdcf7870a Add stack-based named argument storage 5899267c4 Fix a clang-tidy warning 07b4c246e Fix a typo e99809f29 Fix ostream support in sprintf (#1631) 3cd5179f3 Fixed clang tidy warning -multiple declarations in a single statement reduces readability 7404e33a7 Fix clang warning about explicit ctor 3aab2171e Clean up basic_format_args 7645ca072 Clean up printf e30d8391e Suppress an MSVC warning (#1622) 8cd8ef03e Simplify warning suppression bbb6b357c Add floating-point L specifier (#1624) 36ea32640 Suppress a bogus MSVC warning 141a00d64 Define FMT_EXTERN_TEMPLATE_API on export 3860edc5d Bump version 7d01859ef Fix handling of unsigned char strings in printf 63b23e786 Merge branch 'master' of github.com:fmtlib/fmt 4999796c1 Fix the docs 34b3f7b7a Avoid windows issue with min() max() macros 27e3c0fe9 Update signature in the docs git-subtree-dir: externals/fmt git-subtree-split: cd4af11efc9c622896a3e4cb599fa28668ca3d05
855 lines
32 KiB
Text
855 lines
32 KiB
Text
// Formatting library for C++ - the standard API implementation
|
|
//
|
|
// Copyright (c) 2012 - present, Victor Zverovich
|
|
// All rights reserved.
|
|
//
|
|
// For the license information refer to format.h.
|
|
|
|
#ifndef FMT_FORMAT_
|
|
#define FMT_FORMAT_
|
|
|
|
#include <cassert>
|
|
#include <variant>
|
|
#include "fmt/format.h"
|
|
|
|
// This implementation verifies the correctness of the standard API proposed in
|
|
// P0645 Text Formatting and is optimized for copy-pasting from the paper, not
|
|
// for efficiency or readability. An efficient implementation should not use
|
|
// std::variant and should store packed argument type tags separately from
|
|
// values in basic_format_args for small number of arguments.
|
|
|
|
namespace std {
|
|
template<class T>
|
|
constexpr bool Integral = is_integral_v<T>;
|
|
|
|
template <class O>
|
|
using iter_difference_t = ptrdiff_t;
|
|
}
|
|
|
|
// https://fmt.dev/Text%20Formatting.html#format.syn
|
|
namespace std {
|
|
// [format.error], class format_error
|
|
class format_error;
|
|
|
|
// [format.formatter], formatter
|
|
template<class charT> class basic_format_parse_context;
|
|
using format_parse_context = basic_format_parse_context<char>;
|
|
using wformat_parse_context = basic_format_parse_context<wchar_t>;
|
|
|
|
template<class Out, class charT> class basic_format_context;
|
|
using format_context = basic_format_context<
|
|
/* unspecified */ std::back_insert_iterator<fmt::detail::buffer<char>>, char>;
|
|
using wformat_context = basic_format_context<
|
|
/* unspecified */ std::back_insert_iterator<fmt::detail::buffer<wchar_t>>, wchar_t>;
|
|
|
|
template<class T, class charT = char> struct formatter {
|
|
formatter() = delete;
|
|
};
|
|
|
|
// [format.arguments], arguments
|
|
template<class Context> class basic_format_arg;
|
|
|
|
template<class Visitor, class Context>
|
|
/* see below */ auto visit_format_arg(Visitor&& vis, basic_format_arg<Context> arg);
|
|
|
|
template<class Context, class... Args> struct format_arg_store; // exposition only
|
|
|
|
template<class Context> class basic_format_args;
|
|
using format_args = basic_format_args<format_context>;
|
|
using wformat_args = basic_format_args<wformat_context>;
|
|
|
|
template<class Out, class charT>
|
|
using format_args_t = basic_format_args<basic_format_context<Out, charT>>;
|
|
|
|
template<class Context = format_context, class... Args>
|
|
format_arg_store<Context, Args...>
|
|
make_format_args(const Args&... args);
|
|
template<class... Args>
|
|
format_arg_store<wformat_context, Args...>
|
|
make_wformat_args(const Args&... args);
|
|
|
|
// [format.functions], formatting functions
|
|
template<class... Args>
|
|
string format(string_view fmt, const Args&... args);
|
|
template<class... Args>
|
|
wstring format(wstring_view fmt, const Args&... args);
|
|
|
|
string vformat(string_view fmt, format_args args);
|
|
wstring vformat(wstring_view fmt, wformat_args args);
|
|
|
|
template<class Out, class... Args>
|
|
Out format_to(Out out, string_view fmt, const Args&... args);
|
|
template<class Out, class... Args>
|
|
Out format_to(Out out, wstring_view fmt, const Args&... args);
|
|
|
|
template<class Out>
|
|
Out vformat_to(Out out, string_view fmt, format_args_t<fmt::type_identity_t<Out>, char> args);
|
|
template<class Out>
|
|
Out vformat_to(Out out, wstring_view fmt, format_args_t<fmt::type_identity_t<Out>, wchar_t> args);
|
|
|
|
template<class Out>
|
|
struct format_to_n_result {
|
|
Out out;
|
|
iter_difference_t<Out> size;
|
|
};
|
|
|
|
template<class Out, class... Args>
|
|
format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
|
|
string_view fmt, const Args&... args);
|
|
template<class Out, class... Args>
|
|
format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
|
|
wstring_view fmt, const Args&... args);
|
|
|
|
template<class... Args>
|
|
size_t formatted_size(string_view fmt, const Args&... args);
|
|
template<class... Args>
|
|
size_t formatted_size(wstring_view fmt, const Args&... args);
|
|
}
|
|
|
|
// https://fmt.dev/Text%20Formatting.html#format.error
|
|
namespace std {
|
|
class format_error : public runtime_error {
|
|
public:
|
|
explicit format_error(const string& what_arg) : runtime_error(what_arg) {}
|
|
explicit format_error(const char* what_arg) : runtime_error(what_arg) {}
|
|
};
|
|
}
|
|
|
|
namespace std {
|
|
namespace detail {
|
|
struct error_handler {
|
|
// This function is intentionally not constexpr to give a compile-time error.
|
|
void on_error(const char* message) {
|
|
throw std::format_error(message);
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
// https://fmt.dev/Text%20Formatting.html#format.parse_context
|
|
namespace std {
|
|
template<class charT>
|
|
class basic_format_parse_context {
|
|
public:
|
|
using char_type = charT;
|
|
using const_iterator = typename basic_string_view<charT>::const_iterator;
|
|
using iterator = const_iterator;
|
|
|
|
private:
|
|
iterator begin_; // exposition only
|
|
iterator end_; // exposition only
|
|
enum indexing { unknown, manual, automatic }; // exposition only
|
|
indexing indexing_; // exposition only
|
|
size_t next_arg_id_; // exposition only
|
|
size_t num_args_; // exposition only
|
|
|
|
public:
|
|
explicit constexpr basic_format_parse_context(basic_string_view<charT> fmt,
|
|
size_t num_args = 0) noexcept;
|
|
basic_format_parse_context(const basic_format_parse_context&) = delete;
|
|
basic_format_parse_context& operator=(const basic_format_parse_context&) = delete;
|
|
|
|
constexpr const_iterator begin() const noexcept;
|
|
constexpr const_iterator end() const noexcept;
|
|
constexpr void advance_to(const_iterator it);
|
|
|
|
constexpr size_t next_arg_id();
|
|
constexpr void check_arg_id(size_t id);
|
|
|
|
// Implementation detail:
|
|
constexpr void check_arg_id(fmt::string_view) {}
|
|
detail::error_handler error_handler() const { return {}; }
|
|
void on_error(const char* msg) { error_handler().on_error(msg); }
|
|
};
|
|
}
|
|
|
|
namespace std {
|
|
template<class charT>
|
|
/* explicit */ constexpr basic_format_parse_context<charT>::
|
|
basic_format_parse_context(basic_string_view<charT> fmt,
|
|
size_t num_args) noexcept
|
|
: begin_(fmt.begin()), end_(fmt.end()), indexing_(unknown), next_arg_id_(0), num_args_(num_args) {}
|
|
|
|
template<class charT>
|
|
constexpr typename basic_format_parse_context<charT>::const_iterator basic_format_parse_context<charT>::begin() const noexcept { return begin_; }
|
|
|
|
template<class charT>
|
|
constexpr typename basic_format_parse_context<charT>::const_iterator basic_format_parse_context<charT>::end() const noexcept { return end_; }
|
|
|
|
template<class charT>
|
|
constexpr void basic_format_parse_context<charT>::advance_to(typename basic_format_parse_context<charT>::iterator it) { begin_ = it; }
|
|
|
|
template<class charT>
|
|
constexpr size_t basic_format_parse_context<charT>::next_arg_id() {
|
|
if (indexing_ == manual)
|
|
throw format_error("manual to automatic indexing");
|
|
if (indexing_ == unknown)
|
|
indexing_ = automatic;
|
|
return next_arg_id_++;
|
|
}
|
|
|
|
template<class charT>
|
|
constexpr void basic_format_parse_context<charT>::check_arg_id(size_t id) {
|
|
// clang doesn't support __builtin_is_constant_evaluated yet
|
|
//if (!(!__builtin_is_constant_evaluated() || id < num_args_))
|
|
// throw format_error(invalid index is out of range");
|
|
if (indexing_ == automatic)
|
|
throw format_error("automatic to manual indexing");
|
|
if (indexing_ == unknown)
|
|
indexing_ = manual;
|
|
}
|
|
}
|
|
|
|
// https://fmt.dev/Text%20Formatting.html#format.context
|
|
namespace std {
|
|
template<class Out, class charT>
|
|
class basic_format_context {
|
|
basic_format_args<basic_format_context> args_; // exposition only
|
|
Out out_; // exposition only
|
|
|
|
public:
|
|
using iterator = Out;
|
|
using char_type = charT;
|
|
template<class T> using formatter_type = formatter<T, charT>;
|
|
|
|
basic_format_arg<basic_format_context> arg(size_t id) const;
|
|
|
|
iterator out();
|
|
void advance_to(iterator it);
|
|
|
|
// Implementation details:
|
|
using format_arg = basic_format_arg<basic_format_context>;
|
|
basic_format_context(Out out, basic_format_args<basic_format_context> args, fmt::detail::locale_ref)
|
|
: args_(args), out_(out) {}
|
|
detail::error_handler error_handler() const { return {}; }
|
|
basic_format_arg<basic_format_context> arg(fmt::basic_string_view<charT>) const {
|
|
return {}; // unused: named arguments are not supported yet
|
|
}
|
|
void on_error(const char* msg) { error_handler().on_error(msg); }
|
|
};
|
|
}
|
|
|
|
namespace std {
|
|
template<class O, class charT>
|
|
basic_format_arg<basic_format_context<O, charT>> basic_format_context<O, charT>::arg(size_t id) const { return args_.get(id); }
|
|
|
|
template<class O, class charT>
|
|
typename basic_format_context<O, charT>::iterator basic_format_context<O, charT>::out() { return out_; }
|
|
|
|
template<class O, class charT>
|
|
void basic_format_context<O, charT>::advance_to(typename basic_format_context<O, charT>::iterator it) { out_ = it; }
|
|
}
|
|
|
|
namespace std {
|
|
namespace detail {
|
|
template <typename T>
|
|
constexpr bool is_standard_integer_v =
|
|
std::is_same_v<T, signed char> ||
|
|
std::is_same_v<T, short int> ||
|
|
std::is_same_v<T, int> ||
|
|
std::is_same_v<T, long int> ||
|
|
std::is_same_v<T, long long int>;
|
|
|
|
template <typename T>
|
|
constexpr bool is_standard_unsigned_integer_v =
|
|
std::is_same_v<T, unsigned char> ||
|
|
std::is_same_v<T, unsigned short int> ||
|
|
std::is_same_v<T, unsigned int> ||
|
|
std::is_same_v<T, unsigned long int> ||
|
|
std::is_same_v<T, unsigned long long int>;
|
|
|
|
template <typename T, typename Char> struct formatter;
|
|
}
|
|
}
|
|
|
|
// https://fmt.dev/Text%20Formatting.html#format.arg
|
|
namespace std {
|
|
template<class Context>
|
|
class basic_format_arg {
|
|
public:
|
|
class handle;
|
|
|
|
private:
|
|
using char_type = typename Context::char_type; // exposition only
|
|
|
|
variant<monostate, bool, char_type,
|
|
int, unsigned int, long long int, unsigned long long int,
|
|
double, long double,
|
|
const char_type*, basic_string_view<char_type>,
|
|
const void*, handle> value; // exposition only
|
|
|
|
template<typename T,
|
|
typename = enable_if_t<
|
|
std::is_same_v<T, bool> ||
|
|
std::is_same_v<T, char_type> ||
|
|
(std::is_same_v<T, char> && std::is_same_v<char_type, wchar_t>) ||
|
|
detail::is_standard_integer_v<T> ||
|
|
detail::is_standard_unsigned_integer_v<T> ||
|
|
sizeof(typename Context::template formatter_type<T>().format(declval<const T&>(), declval<Context&>())) != 0
|
|
>> explicit basic_format_arg(const T& v) noexcept; // exposition only
|
|
explicit basic_format_arg(float n) noexcept; // exposition only
|
|
explicit basic_format_arg(double n) noexcept; // exposition only
|
|
explicit basic_format_arg(long double n) noexcept; // exposition only
|
|
explicit basic_format_arg(const char_type* s); // exposition only
|
|
|
|
template<class traits>
|
|
explicit basic_format_arg(
|
|
basic_string_view<char_type, traits> s) noexcept; // exposition only
|
|
|
|
template<class traits, class Allocator>
|
|
explicit basic_format_arg(
|
|
const basic_string<char_type, traits, Allocator>& s) noexcept; // exposition only
|
|
|
|
explicit basic_format_arg(nullptr_t) noexcept; // exposition only
|
|
|
|
template<class T, typename = enable_if_t<is_void_v<T>>>
|
|
explicit basic_format_arg(const T* p) noexcept; // exposition only
|
|
|
|
// Fails due to a bug in clang
|
|
//template<class Visitor, class Ctx>
|
|
// friend auto visit_format_arg(Visitor&& vis,
|
|
// basic_format_arg<Ctx> arg); // exposition only
|
|
|
|
friend auto get_value(basic_format_arg arg) {
|
|
return arg.value;
|
|
}
|
|
|
|
template <typename T, typename Char> friend struct detail::formatter;
|
|
|
|
template<class Ctx, class... Args>
|
|
friend format_arg_store<Ctx, Args...>
|
|
make_format_args(const Args&... args); // exposition only
|
|
|
|
public:
|
|
basic_format_arg() noexcept;
|
|
|
|
explicit operator bool() const noexcept;
|
|
};
|
|
}
|
|
|
|
namespace std {
|
|
template<class Context>
|
|
basic_format_arg<Context>::basic_format_arg() noexcept {}
|
|
|
|
template<class Context>
|
|
template<class T, typename> /* explicit */ basic_format_arg<Context>::basic_format_arg(const T& v) noexcept {
|
|
if constexpr (std::is_same_v<T, bool> || std::is_same_v<T, char_type>)
|
|
value = v;
|
|
else if constexpr (std::is_same_v<T, char> && std::is_same_v<char_type, wchar_t>)
|
|
value = static_cast<wchar_t>(v);
|
|
else if constexpr (detail::is_standard_integer_v<T> && sizeof(T) <= sizeof(int))
|
|
value = static_cast<int>(v);
|
|
else if constexpr (detail::is_standard_unsigned_integer_v<T> && sizeof(T) <= sizeof(unsigned))
|
|
value = static_cast<unsigned>(v);
|
|
else if constexpr (detail::is_standard_integer_v<T>)
|
|
value = static_cast<long long int>(v);
|
|
else if constexpr (detail::is_standard_unsigned_integer_v<T>)
|
|
value = static_cast<unsigned long long int>(v);
|
|
else if constexpr (sizeof(typename Context::template formatter_type<T>().format(declval<const T&>(), declval<Context&>())) != 0)
|
|
value = handle(v);
|
|
}
|
|
|
|
template<class Context>
|
|
/* explicit */ basic_format_arg<Context>::basic_format_arg(float n) noexcept
|
|
: value(static_cast<double>(n)) {}
|
|
|
|
template<class Context>
|
|
/* explicit */ basic_format_arg<Context>::basic_format_arg(double n) noexcept
|
|
: value(n) {}
|
|
|
|
template<class Context>
|
|
/* explicit */ basic_format_arg<Context>::basic_format_arg(long double n) noexcept
|
|
: value(n) {}
|
|
|
|
template<class Context>
|
|
/* explicit */ basic_format_arg<Context>::basic_format_arg(const typename basic_format_arg<Context>::char_type* s)
|
|
: value(s) {
|
|
assert(s != nullptr);
|
|
}
|
|
|
|
template<class Context>
|
|
template<class traits>
|
|
/* explicit */ basic_format_arg<Context>::basic_format_arg(basic_string_view<char_type, traits> s) noexcept
|
|
: value(s) {}
|
|
|
|
template<class Context>
|
|
template<class traits, class Allocator>
|
|
/* explicit */ basic_format_arg<Context>::basic_format_arg(
|
|
const basic_string<char_type, traits, Allocator>& s) noexcept
|
|
: value(basic_string_view<char_type>(s.data(), s.size())) {}
|
|
|
|
|
|
template<class Context>
|
|
/* explicit */ basic_format_arg<Context>::basic_format_arg(nullptr_t) noexcept
|
|
: value(static_cast<const void*>(nullptr)) {}
|
|
|
|
template<class Context>
|
|
template<class T, typename> /* explicit */ basic_format_arg<Context>::basic_format_arg(const T* p) noexcept
|
|
: value(p) {}
|
|
|
|
template<class Context>
|
|
/* explicit */ basic_format_arg<Context>::operator bool() const noexcept {
|
|
return !holds_alternative<monostate>(value);
|
|
}
|
|
}
|
|
|
|
namespace std {
|
|
template<class Context>
|
|
class basic_format_arg<Context>::handle {
|
|
const void* ptr_; // exposition only
|
|
void (*format_)(basic_format_parse_context<char_type>&,
|
|
Context&, const void*); // exposition only
|
|
|
|
template<class T> explicit handle(const T& val) noexcept; // exposition only
|
|
|
|
friend class basic_format_arg<Context>; // exposition only
|
|
|
|
public:
|
|
void format(basic_format_parse_context<char_type>&, Context& ctx) const;
|
|
};
|
|
}
|
|
|
|
namespace std {
|
|
template<class Context>
|
|
template<class T> /* explicit */ basic_format_arg<Context>::handle::handle(const T& val) noexcept
|
|
: ptr_(&val), format_([](basic_format_parse_context<char_type>& parse_ctx, Context& format_ctx, const void* ptr) {
|
|
typename Context::template formatter_type<T> f;
|
|
parse_ctx.advance_to(f.parse(parse_ctx));
|
|
format_ctx.advance_to(f.format(*static_cast<const T*>(ptr), format_ctx));
|
|
}) {}
|
|
|
|
template<class Context>
|
|
void basic_format_arg<Context>::handle::format(basic_format_parse_context<char_type>& parse_ctx, Context& format_ctx) const {
|
|
format_(parse_ctx, format_ctx, ptr_);
|
|
}
|
|
|
|
// https://fmt.dev/Text%20Formatting.html#format.visit
|
|
template<class Visitor, class Context>
|
|
auto visit_format_arg(Visitor&& vis, basic_format_arg<Context> arg) {
|
|
return visit(vis, get_value(arg));
|
|
}
|
|
}
|
|
|
|
// https://fmt.dev/Text%20Formatting.html#format.store
|
|
namespace std {
|
|
template<class Context, class... Args>
|
|
struct format_arg_store { // exposition only
|
|
array<basic_format_arg<Context>, sizeof...(Args)> args;
|
|
};
|
|
}
|
|
|
|
// https://fmt.dev/Text%20Formatting.html#format.basic_args
|
|
namespace std {
|
|
template<class Context>
|
|
class basic_format_args {
|
|
size_t size_; // exposition only
|
|
const basic_format_arg<Context>* data_; // exposition only
|
|
|
|
public:
|
|
basic_format_args() noexcept;
|
|
|
|
template<class... Args>
|
|
basic_format_args(const format_arg_store<Context, Args...>& store) noexcept;
|
|
|
|
basic_format_arg<Context> get(size_t i) const noexcept;
|
|
};
|
|
}
|
|
|
|
namespace std {
|
|
|
|
template<class Context>
|
|
basic_format_args<Context>::basic_format_args() noexcept : size_(0) {}
|
|
|
|
template<class Context>
|
|
template<class... Args>
|
|
basic_format_args<Context>::basic_format_args(const format_arg_store<Context, Args...>& store) noexcept
|
|
: size_(sizeof...(Args)), data_(store.args.data()) {}
|
|
|
|
template<class Context>
|
|
basic_format_arg<Context> basic_format_args<Context>::get(size_t i) const noexcept {
|
|
return i < size_ ? data_[i] : basic_format_arg<Context>();
|
|
}
|
|
}
|
|
|
|
namespace std {
|
|
// https://fmt.dev/Text%20Formatting.html#format.make_args
|
|
template<class Context /*= format_context*/, class... Args>
|
|
format_arg_store<Context, Args...> make_format_args(const Args&... args) {
|
|
return {basic_format_arg<Context>(args)...};
|
|
}
|
|
|
|
// https://fmt.dev/Text%20Formatting.html#format.make_wargs
|
|
template<class... Args>
|
|
format_arg_store<wformat_context, Args...> make_wformat_args(const Args&... args) {
|
|
return make_format_args<wformat_context>(args...);
|
|
}
|
|
}
|
|
|
|
namespace std {
|
|
namespace detail {
|
|
|
|
template <typename OutputIt, typename Char>
|
|
class arg_formatter
|
|
: public fmt::detail::arg_formatter_base<OutputIt, Char, error_handler> {
|
|
private:
|
|
using char_type = Char;
|
|
using base = fmt::detail::arg_formatter_base<OutputIt, Char, error_handler>;
|
|
using format_context = std::basic_format_context<OutputIt, Char>;
|
|
using parse_context = basic_format_parse_context<Char>;
|
|
|
|
parse_context* parse_ctx_;
|
|
format_context& ctx_;
|
|
|
|
public:
|
|
using iterator = OutputIt;
|
|
using format_specs = typename base::format_specs;
|
|
|
|
/**
|
|
\rst
|
|
Constructs an argument formatter object.
|
|
*ctx* is a reference to the formatting context,
|
|
*spec* contains format specifier information for standard argument types.
|
|
\endrst
|
|
*/
|
|
arg_formatter(format_context& ctx, parse_context* parse_ctx = nullptr, fmt::format_specs* spec = nullptr)
|
|
: base(ctx.out(), spec, {}), parse_ctx_(parse_ctx), ctx_(ctx) {}
|
|
|
|
using base::operator();
|
|
|
|
/** Formats an argument of a user-defined type. */
|
|
iterator operator()(typename std::basic_format_arg<format_context>::handle handle) {
|
|
handle.format(*parse_ctx_, ctx_);
|
|
return this->out();
|
|
}
|
|
|
|
iterator operator()(monostate) {
|
|
throw format_error("");
|
|
}
|
|
};
|
|
|
|
template <typename Context>
|
|
inline fmt::detail::type get_type(basic_format_arg<Context> arg) {
|
|
return visit_format_arg([&] (auto val) {
|
|
using char_type = typename Context::char_type;
|
|
using T = decltype(val);
|
|
if (std::is_same_v<T, monostate>)
|
|
return fmt::detail::type::none_type;
|
|
if (std::is_same_v<T, bool>)
|
|
return fmt::detail::type::bool_type;
|
|
if (std::is_same_v<T, char_type>)
|
|
return fmt::detail::type::char_type;
|
|
if (std::is_same_v<T, int>)
|
|
return fmt::detail::type::int_type;
|
|
if (std::is_same_v<T, unsigned int>)
|
|
return fmt::detail::type::uint_type;
|
|
if (std::is_same_v<T, long long int>)
|
|
return fmt::detail::type::long_long_type;
|
|
if (std::is_same_v<T, unsigned long long int>)
|
|
return fmt::detail::type::ulong_long_type;
|
|
if (std::is_same_v<T, double>)
|
|
return fmt::detail::type::double_type;
|
|
if (std::is_same_v<T, long double>)
|
|
return fmt::detail::type::long_double_type;
|
|
if (std::is_same_v<T, const char_type*>)
|
|
return fmt::detail::type::cstring_type;
|
|
if (std::is_same_v<T, basic_string_view<char_type>>)
|
|
return fmt::detail::type::string_type;
|
|
if (std::is_same_v<T, const void*>)
|
|
return fmt::detail::type::pointer_type;
|
|
assert(get_value(arg).index() == 12);
|
|
return fmt::detail::type::custom_type;
|
|
}, arg);
|
|
}
|
|
|
|
template <typename Context>
|
|
class custom_formatter {
|
|
private:
|
|
using parse_context = basic_format_parse_context<typename Context::char_type>;
|
|
parse_context& parse_ctx_;
|
|
Context& format_ctx_;
|
|
|
|
public:
|
|
custom_formatter(parse_context& parse_ctx, Context& ctx) : parse_ctx_(parse_ctx), format_ctx_(ctx) {}
|
|
|
|
bool operator()(typename basic_format_arg<Context>::handle h) const {
|
|
h.format(parse_ctx_, format_ctx_);
|
|
return true;
|
|
}
|
|
|
|
template <typename T> bool operator()(T) const { return false; }
|
|
};
|
|
|
|
template <typename ArgFormatter, typename Char, typename Context>
|
|
struct format_handler : detail::error_handler {
|
|
using iterator = typename ArgFormatter::iterator;
|
|
|
|
format_handler(iterator out, basic_string_view<Char> str,
|
|
basic_format_args<Context> format_args,
|
|
fmt::detail::locale_ref loc)
|
|
: parse_ctx(str), context(out, format_args, loc) {}
|
|
|
|
void on_text(const Char* begin, const Char* end) {
|
|
auto size = fmt::detail::to_unsigned(end - begin);
|
|
auto out = context.out();
|
|
auto&& it = fmt::detail::reserve(out, size);
|
|
it = std::copy_n(begin, size, it);
|
|
context.advance_to(out);
|
|
}
|
|
|
|
int on_arg_id() { return parse_ctx.next_arg_id(); }
|
|
int on_arg_id(unsigned id) { return parse_ctx.check_arg_id(id), id; }
|
|
int on_arg_id(fmt::basic_string_view<Char>) { return 0; }
|
|
|
|
void on_replacement_field(int id, const Char* p) {
|
|
auto arg = context.arg(id);
|
|
parse_ctx.advance_to(parse_ctx.begin() + (p - &*parse_ctx.begin()));
|
|
custom_formatter<Context> f(parse_ctx, context);
|
|
if (!visit_format_arg(f, arg))
|
|
context.advance_to(visit_format_arg(ArgFormatter(context, &parse_ctx), arg));
|
|
}
|
|
|
|
const Char* on_format_specs(int id, const Char* begin, const Char* end) {
|
|
auto arg = context.arg(id);
|
|
parse_ctx.advance_to(parse_ctx.begin() + (begin - &*parse_ctx.begin()));
|
|
custom_formatter<Context> f(parse_ctx, context);
|
|
if (visit_format_arg(f, arg)) return &*parse_ctx.begin();
|
|
fmt::basic_format_specs<Char> specs;
|
|
using fmt::detail::specs_handler;
|
|
using parse_context = basic_format_parse_context<Char>;
|
|
fmt::detail::specs_checker<specs_handler<parse_context, Context>> handler(
|
|
specs_handler<parse_context, Context>(specs, parse_ctx, context), get_type(arg));
|
|
begin = parse_format_specs(begin, end, handler);
|
|
if (begin == end || *begin != '}') on_error("missing '}' in format string");
|
|
parse_ctx.advance_to(parse_ctx.begin() + (begin - &*parse_ctx.begin()));
|
|
context.advance_to(visit_format_arg(ArgFormatter(context, &parse_ctx, &specs), arg));
|
|
return begin;
|
|
}
|
|
|
|
basic_format_parse_context<Char> parse_ctx;
|
|
Context context;
|
|
};
|
|
|
|
template <typename T, typename Char>
|
|
struct formatter {
|
|
// Parses format specifiers stopping either at the end of the range or at the
|
|
// terminating '}'.
|
|
template <typename ParseContext>
|
|
FMT_CONSTEXPR typename ParseContext::iterator parse(ParseContext& ctx) {
|
|
namespace detail = fmt::detail;
|
|
typedef detail::dynamic_specs_handler<ParseContext> handler_type;
|
|
auto type = detail::mapped_type_constant<T, fmt::buffer_context<Char>>::value;
|
|
detail::specs_checker<handler_type> handler(handler_type(specs_, ctx),
|
|
type);
|
|
auto it = parse_format_specs(ctx.begin(), ctx.end(), handler);
|
|
auto type_spec = specs_.type;
|
|
auto eh = ctx.error_handler();
|
|
switch (type) {
|
|
case detail::type::none_type:
|
|
FMT_ASSERT(false, "invalid argument type");
|
|
break;
|
|
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::bool_type:
|
|
handle_int_type_spec(type_spec,
|
|
detail::int_type_checker<decltype(eh)>(eh));
|
|
break;
|
|
case detail::type::char_type:
|
|
handle_char_specs(
|
|
&specs_, detail::char_specs_checker<decltype(eh)>(type_spec, eh));
|
|
break;
|
|
case detail::type::double_type:
|
|
case detail::type::long_double_type:
|
|
detail::parse_float_type_spec(specs_, eh);
|
|
break;
|
|
case detail::type::cstring_type:
|
|
detail::handle_cstring_type_spec(
|
|
type_spec, detail::cstring_type_checker<decltype(eh)>(eh));
|
|
break;
|
|
case detail::type::string_type:
|
|
detail::check_string_type_spec(type_spec, eh);
|
|
break;
|
|
case detail::type::pointer_type:
|
|
detail::check_pointer_type_spec(type_spec, eh);
|
|
break;
|
|
case detail::type::custom_type:
|
|
// Custom format specifiers should be checked in parse functions of
|
|
// formatter specializations.
|
|
break;
|
|
}
|
|
return it;
|
|
}
|
|
|
|
template <typename FormatContext>
|
|
auto format(const T& val, FormatContext& ctx) -> decltype(ctx.out()) {
|
|
fmt::detail::handle_dynamic_spec<fmt::detail::width_checker>(
|
|
specs_.width, specs_.width_ref, ctx);
|
|
fmt::detail::handle_dynamic_spec<fmt::detail::precision_checker>(
|
|
specs_.precision, specs_.precision_ref, ctx);
|
|
using af = arg_formatter<typename FormatContext::iterator,
|
|
typename FormatContext::char_type>;
|
|
return visit_format_arg(af(ctx, nullptr, &specs_),
|
|
basic_format_arg<FormatContext>(val));
|
|
}
|
|
|
|
private:
|
|
fmt::detail::dynamic_format_specs<Char> specs_;
|
|
};
|
|
} // namespace detail
|
|
|
|
// https://fmt.dev/Text%20Formatting.html#format.functions
|
|
template<class... Args>
|
|
string format(string_view fmt, const Args&... args) {
|
|
return vformat(fmt, make_format_args(args...));
|
|
}
|
|
|
|
template<class... Args>
|
|
wstring format(wstring_view fmt, const Args&... args) {
|
|
return vformat(fmt, make_wformat_args(args...));
|
|
}
|
|
|
|
string vformat(string_view fmt, format_args args) {
|
|
fmt::memory_buffer mbuf;
|
|
fmt::detail::buffer<char>& buf = mbuf;
|
|
using af = detail::arg_formatter<fmt::format_context::iterator, char>;
|
|
detail::format_handler<af, char, format_context>
|
|
h(std::back_inserter(buf), fmt, args, {});
|
|
fmt::detail::parse_format_string<false>(fmt::to_string_view(fmt), h);
|
|
return to_string(mbuf);
|
|
}
|
|
|
|
wstring vformat(wstring_view fmt, wformat_args args);
|
|
|
|
template<class Out, class... Args>
|
|
Out format_to(Out out, string_view fmt, const Args&... args) {
|
|
using context = basic_format_context<Out, decltype(fmt)::value_type>;
|
|
return vformat_to(out, fmt, make_format_args<context>(args...));
|
|
}
|
|
|
|
template<class Out, class... Args>
|
|
Out format_to(Out out, wstring_view fmt, const Args&... args) {
|
|
using context = basic_format_context<Out, decltype(fmt)::value_type>;
|
|
return vformat_to(out, fmt, make_format_args<context>(args...));
|
|
}
|
|
|
|
template<class Out>
|
|
Out vformat_to(Out out, string_view fmt, format_args_t<fmt::type_identity_t<Out>, char> args) {
|
|
using af = detail::arg_formatter<Out, char>;
|
|
detail::format_handler<af, char, basic_format_context<Out, char>>
|
|
h(out, fmt, args, {});
|
|
fmt::detail::parse_format_string<false>(fmt::to_string_view(fmt), h);
|
|
return h.context.out();
|
|
}
|
|
|
|
template<class Out>
|
|
Out vformat_to(Out out, wstring_view fmt, format_args_t<fmt::type_identity_t<Out>, wchar_t> args);
|
|
|
|
template<class Out, class... Args>
|
|
format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
|
|
string_view fmt, const Args&... args);
|
|
template<class Out, class... Args>
|
|
format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
|
|
wstring_view fmt, const Args&... args);
|
|
|
|
template<class... Args>
|
|
size_t formatted_size(string_view fmt, const Args&... args);
|
|
template<class... Args>
|
|
size_t formatted_size(wstring_view fmt, const Args&... args);
|
|
|
|
#define charT char
|
|
|
|
template<> struct formatter<charT, charT> : detail::formatter<charT, charT> {};
|
|
|
|
template<> struct formatter<char, wchar_t>;
|
|
|
|
template<> struct formatter<charT*, charT> : detail::formatter<const charT*, charT> {};
|
|
|
|
template<> struct formatter<const charT*, charT> : detail::formatter<const charT*, charT> {};
|
|
|
|
template<size_t N> struct formatter<const charT[N], charT>
|
|
: detail::formatter<std::basic_string_view<charT>, charT> {};
|
|
|
|
template<class traits, class Allocator>
|
|
struct formatter<basic_string<charT, traits, Allocator>, charT>
|
|
: detail::formatter<std::basic_string_view<charT>, charT> {};
|
|
|
|
template<class traits>
|
|
struct formatter<basic_string_view<charT, traits>, charT>
|
|
: detail::formatter<std::basic_string_view<charT>, charT> {};
|
|
|
|
template <> struct formatter<nullptr_t, charT> : detail::formatter<const void*, charT> {};
|
|
template <> struct formatter<void*, charT> : detail::formatter<const void*, charT> {};
|
|
template <> struct formatter<const void*, charT> : detail::formatter<const void*, charT> {};
|
|
template <> struct formatter<bool, charT> : detail::formatter<bool, charT> {};
|
|
|
|
template <> struct formatter<signed char, charT> : detail::formatter<int, charT> {};
|
|
template <> struct formatter<short, charT> : detail::formatter<int, charT> {};
|
|
template <> struct formatter<int, charT> : detail::formatter<int, charT> {};
|
|
template <> struct formatter<long, charT>
|
|
: detail::formatter<std::conditional_t<sizeof(long) == sizeof(int), int, long long>, charT> {};
|
|
template <> struct formatter<long long, charT> : detail::formatter<long long, charT> {};
|
|
template <> struct formatter<unsigned char, charT> : detail::formatter<unsigned int, charT> {};
|
|
template <> struct formatter<unsigned short, charT> : detail::formatter<unsigned int, charT> {};
|
|
template <> struct formatter<unsigned int, charT> : detail::formatter<unsigned int, charT> {};
|
|
template <> struct formatter<unsigned long, charT>
|
|
: detail::formatter<std::conditional_t<sizeof(long) == sizeof(int), unsigned, unsigned long long>, charT> {};
|
|
template <> struct formatter<unsigned long long, charT> : detail::formatter<unsigned long long, charT> {};
|
|
|
|
template <> struct formatter<float, charT> : detail::formatter<double, charT> {};
|
|
template <> struct formatter<double, charT> : detail::formatter<double, charT> {};
|
|
template <> struct formatter<long double, charT> : detail::formatter<long double, charT> {};
|
|
|
|
#undef charT
|
|
|
|
#define charT wchar_t
|
|
|
|
template<> struct formatter<charT, charT> : detail::formatter<charT, charT> {};
|
|
|
|
template<> struct formatter<char, wchar_t> : detail::formatter<charT, charT> {};
|
|
|
|
template<> struct formatter<charT*, charT> : detail::formatter<const charT*, charT> {};
|
|
|
|
template<> struct formatter<const charT*, charT> : detail::formatter<const charT*, charT> {};
|
|
|
|
template<size_t N> struct formatter<const charT[N], charT>
|
|
: detail::formatter<std::basic_string_view<charT>, charT> {};
|
|
|
|
template<class traits, class Allocator>
|
|
struct formatter<std::basic_string<charT, traits, Allocator>, charT>
|
|
: detail::formatter<std::basic_string_view<charT>, charT> {};
|
|
|
|
template<class traits>
|
|
struct formatter<std::basic_string_view<charT, traits>, charT>
|
|
: detail::formatter<std::basic_string_view<charT>, charT> {};
|
|
|
|
template <> struct formatter<nullptr_t, charT> : detail::formatter<const void*, charT> {};
|
|
template <> struct formatter<void*, charT> : detail::formatter<const void*, charT> {};
|
|
template <> struct formatter<const void*, charT> : detail::formatter<const void*, charT> {};
|
|
template <> struct formatter<bool, charT> : detail::formatter<bool, charT> {};
|
|
|
|
template <> struct formatter<signed char, charT> : detail::formatter<int, charT> {};
|
|
template <> struct formatter<short, charT> : detail::formatter<int, charT> {};
|
|
template <> struct formatter<int, charT> : detail::formatter<int, charT> {};
|
|
template <> struct formatter<long, charT>
|
|
: detail::formatter<std::conditional_t<sizeof(long) == sizeof(int), int, long long>, charT> {};
|
|
template <> struct formatter<long long, charT> : detail::formatter<long long, charT> {};
|
|
template <> struct formatter<unsigned char, charT> : detail::formatter<unsigned int, charT> {};
|
|
template <> struct formatter<unsigned short, charT> : detail::formatter<unsigned int, charT> {};
|
|
template <> struct formatter<unsigned int, charT> : detail::formatter<unsigned int, charT> {};
|
|
template <> struct formatter<unsigned long, charT>
|
|
: detail::formatter<std::conditional_t<sizeof(long) == sizeof(int), unsigned, unsigned long long>, charT> {};
|
|
template <> struct formatter<unsigned long long, charT> : detail::formatter<unsigned long long, charT> {};
|
|
|
|
template <> struct formatter<float, charT> : detail::formatter<double, charT> {};
|
|
template <> struct formatter<double, charT> : detail::formatter<double, charT> {};
|
|
template <> struct formatter<long double, charT> : detail::formatter<long double, charT> {};
|
|
|
|
#undef charT
|
|
|
|
template<> struct formatter<const wchar_t, char> {
|
|
formatter() = delete;
|
|
};
|
|
}
|
|
|
|
#endif // FMT_FORMAT_
|