1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Update cpp fmt to 8.0.1

This commit is contained in:
Sandu Liviu Catalin 2021-07-03 13:37:01 +03:00
parent ab1f65b53f
commit 990dd68e7f
10 changed files with 69 additions and 70 deletions

View File

@ -10,7 +10,6 @@ add_library(FmtLib STATIC
include/fmt/locale.h
include/fmt/os.h
include/fmt/ostream.h
include/fmt/posix.h
include/fmt/printf.h
include/fmt/ranges.h
include/fmt/xchar.h

View File

@ -47,6 +47,9 @@ template FMT_API char detail::decimal_point_impl(locale_ref);
template FMT_API void detail::buffer<char>::append(const char*, const char*);
// DEPRECATED!
// There is no correspondent extern template in format.h because of
// incompatibility between clang and gcc (#2377).
template FMT_API void detail::vformat_to(
detail::buffer<char>&, string_view,
basic_format_args<FMT_BUFFER_CONTEXT(char)>, detail::locale_ref);

View File

@ -507,7 +507,7 @@ void vformat_to(buffer<Char>& buf, const text_style& ts,
auto background = detail::make_background_color<Char>(ts.get_background());
buf.append(background.begin(), background.end());
}
detail::vformat_to(buf, format_str, args);
detail::vformat_to(buf, format_str, args, {});
if (has_style) detail::reset_color<Char>(buf);
}

View File

@ -16,7 +16,7 @@
#include <type_traits>
// The fmt library version in the form major * 10000 + minor * 100 + patch.
#define FMT_VERSION 80000
#define FMT_VERSION 80001
#ifdef __clang__
# define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
@ -24,7 +24,7 @@
# define FMT_CLANG_VERSION 0
#endif
#if defined(__GNUC__) && !defined(__clang__)
#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
# define FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
# define FMT_GCC_PRAGMA(arg) _Pragma(arg)
#else
@ -64,7 +64,8 @@
# define FMT_HAS_FEATURE(x) 0
#endif
#if defined(__has_include) && !defined(__INTELLISENSE__) && \
#if defined(__has_include) && \
(!defined(__INTELLISENSE__) || FMT_MSC_VER > 1900) && \
(!FMT_ICC_VERSION || FMT_ICC_VERSION >= 1600)
# define FMT_HAS_INCLUDE(x) __has_include(x)
#else
@ -228,12 +229,12 @@
# define FMT_INLINE_NAMESPACE namespace
# define FMT_END_NAMESPACE \
} \
using namespace v7; \
using namespace v8; \
}
# endif
# define FMT_BEGIN_NAMESPACE \
namespace fmt { \
FMT_INLINE_NAMESPACE v7 {
FMT_INLINE_NAMESPACE v8 {
#endif
#ifndef FMT_MODULE_EXPORT
@ -316,9 +317,9 @@ FMT_BEGIN_NAMESPACE
FMT_MODULE_EXPORT_BEGIN
// Implementations of enable_if_t and other metafunctions for older systems.
template <bool B, class T = void>
template <bool B, typename T = void>
using enable_if_t = typename std::enable_if<B, T>::type;
template <bool B, class T, class F>
template <bool B, typename T, typename F>
using conditional_t = typename std::conditional<B, T, F>::type;
template <bool B> using bool_constant = std::integral_constant<bool, B>;
template <typename T>
@ -332,6 +333,11 @@ struct monostate {
constexpr monostate() {}
};
// Suppress "unused variable" warnings with the method described in
// https://herbsutter.com/2009/10/18/mailbag-shutting-up-compiler-warnings/.
// (void)var does not work on many Intel compilers.
template <typename... T> FMT_CONSTEXPR void ignore_unused(const T&...) {}
// An enable_if helper to be used in template parameters which results in much
// shorter symbols: https://godbolt.org/z/sWw4vP. Extra parentheses are needed
// to workaround a bug in MSVC 2019 (see #1140 and #1186).
@ -360,7 +366,8 @@ FMT_NORETURN FMT_API void assert_fail(const char* file, int line,
#ifndef FMT_ASSERT
# ifdef NDEBUG
// FMT_ASSERT is not empty to avoid -Werror=empty-body.
# define FMT_ASSERT(condition, message) ((void)0)
# define FMT_ASSERT(condition, message) \
::fmt::ignore_unused((condition), (message))
# else
# define FMT_ASSERT(condition, message) \
((condition) /* void() fails with -Winvalid-constexpr on clang 4.0.1 */ \
@ -525,39 +532,21 @@ using string_view = basic_string_view<char>;
template <typename T> struct is_char : std::false_type {};
template <> struct is_char<char> : std::true_type {};
/**
\rst
Returns a string view of `s`. In order to add custom string type support to
{fmt} provide an overload of `to_string_view` for it in the same namespace as
the type for the argument-dependent lookup to work.
**Example**::
namespace my_ns {
inline string_view to_string_view(const my_string& s) {
return {s.data(), s.length()};
}
}
std::string message = fmt::format(my_string("The answer is {}"), 42);
\endrst
*/
// Returns a string view of `s`.
template <typename Char, FMT_ENABLE_IF(is_char<Char>::value)>
FMT_INLINE auto to_string_view(const Char* s) -> basic_string_view<Char> {
return s;
}
template <typename Char, typename Traits, typename Alloc>
inline auto to_string_view(const std::basic_string<Char, Traits, Alloc>& s)
-> basic_string_view<Char> {
return s;
}
template <typename Char>
constexpr auto to_string_view(basic_string_view<Char> s)
-> basic_string_view<Char> {
return s;
}
template <typename Char,
FMT_ENABLE_IF(!std::is_empty<detail::std_string_view<Char>>::value)>
inline auto to_string_view(detail::std_string_view<Char> s)
@ -581,7 +570,7 @@ constexpr auto to_string_view(const S& s)
FMT_BEGIN_DETAIL_NAMESPACE
void to_string_view(...);
using fmt::v7::to_string_view;
using fmt::v8::to_string_view;
// Specifies whether S is a string type convertible to fmt::basic_string_view.
// It should be a constexpr function but MSVC 2017 fails to compile it in
@ -624,7 +613,7 @@ template <typename S> using char_t = typename detail::char_t_impl<S>::type;
\rst
Parsing context consisting of a format string range being parsed and an
argument counter for automatic indexing.
You can use the ```format_parse_context`` type alias for ``char`` instead.
You can use the ``format_parse_context`` type alias for ``char`` instead.
\endrst
*/
template <typename Char, typename ErrorHandler = detail::error_handler>
@ -2420,7 +2409,7 @@ FMT_CONSTEXPR FMT_INLINE void parse_format_string(
if (pbegin == pend) return;
for (;;) {
const Char* p = nullptr;
if (!find<IS_CONSTEXPR>(pbegin, pend, '}', p))
if (!find<IS_CONSTEXPR>(pbegin, pend, Char('}'), p))
return handler_.on_text(pbegin, pend);
++p;
if (p == pend || *p != '}')
@ -2435,7 +2424,7 @@ FMT_CONSTEXPR FMT_INLINE void parse_format_string(
// Doing two passes with memchr (one for '{' and another for '}') is up to
// 2.5x faster than the naive one-pass implementation on big format strings.
const Char* p = begin;
if (*begin != '{' && !find<IS_CONSTEXPR>(begin + 1, end, '{', p))
if (*begin != '{' && !find<IS_CONSTEXPR>(begin + 1, end, Char('{'), p))
return write(begin, end);
write(begin, p);
begin = parse_replacement_field(p, end, handler);
@ -2588,8 +2577,8 @@ FMT_CONSTEXPR auto check_cstring_type_spec(Char spec, ErrorHandler&& eh = {})
return false;
}
template <typename Char, typename ErrorHandler>
FMT_CONSTEXPR void check_string_type_spec(Char spec, ErrorHandler&& eh) {
template <typename Char, typename ErrorHandler = error_handler>
FMT_CONSTEXPR void check_string_type_spec(Char spec, ErrorHandler&& eh = {}) {
if (spec != 0 && spec != 's') eh.on_error("invalid type specifier");
}
@ -2656,21 +2645,28 @@ constexpr auto get_arg_index_by_name(basic_string_view<Char> name) -> int {
if constexpr (detail::is_statically_named_arg<T>()) {
if (name == T::name) return N;
}
if constexpr (sizeof...(Args) > 0)
if constexpr (sizeof...(Args) > 0) {
return get_arg_index_by_name<N + 1, Args...>(name);
(void)name; // Workaround an MSVC bug about "unused" parameter.
return invalid_arg_index;
} else {
(void)name; // Workaround an MSVC bug about "unused" parameter.
return invalid_arg_index;
}
}
#endif
template <typename... Args, typename Char>
FMT_CONSTEXPR auto get_arg_index_by_name(basic_string_view<Char> name) -> int {
#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS
if constexpr (sizeof...(Args) > 0)
if constexpr (sizeof...(Args) > 0) {
return get_arg_index_by_name<0, Args...>(name);
#endif
} else {
(void)name;
return invalid_arg_index;
}
#else
(void)name;
return invalid_arg_index;
#endif
}
template <typename Char, typename ErrorHandler, typename... Args>
@ -2731,14 +2727,14 @@ void check_format_string(S format_str) {
remove_cvref_t<Args>...>;
FMT_CONSTEXPR bool invalid_format =
(parse_format_string<true>(s, checker(s, {})), true);
(void)invalid_format;
ignore_unused(invalid_format);
}
template <typename Char>
void vformat_to(
buffer<Char>& buf, basic_string_view<Char> fmt,
basic_format_args<FMT_BUFFER_CONTEXT(type_identity_t<Char>)> args,
detail::locale_ref loc = {});
locale_ref loc = {});
FMT_API void vprint_mojibake(std::FILE*, string_view, format_args);
#ifndef _WIN32
@ -2896,7 +2892,7 @@ template <typename OutputIt,
auto vformat_to(OutputIt out, string_view fmt, format_args args) -> OutputIt {
using detail::get_buffer;
auto&& buf = get_buffer<char>(out);
detail::vformat_to(buf, string_view(fmt), args);
detail::vformat_to(buf, string_view(fmt), args, {});
return detail::get_iterator(buf);
}
@ -2933,7 +2929,7 @@ auto vformat_to_n(OutputIt out, size_t n, string_view fmt, format_args args)
using buffer =
detail::iterator_buffer<OutputIt, char, detail::fixed_buffer_traits>;
auto buf = buffer(out, n);
detail::vformat_to(buf, fmt, args);
detail::vformat_to(buf, fmt, args, {});
return {buf.out(), buf.count()};
}
@ -2955,7 +2951,7 @@ FMT_INLINE auto format_to_n(OutputIt out, size_t n, format_string<T...> fmt,
template <typename... T>
FMT_INLINE auto formatted_size(format_string<T...> fmt, T&&... args) -> size_t {
auto buf = detail::counting_buffer<>();
detail::vformat_to(buf, string_view(fmt), fmt::make_format_args(args...));
detail::vformat_to(buf, string_view(fmt), fmt::make_format_args(args...), {});
return buf.count();
}

View File

@ -563,7 +563,6 @@ class bigint {
(*this)[bigit_index] = static_cast<bigit>(sum);
sum >>= bits<bigit>::value;
}
--num_result_bigits;
remove_leading_zeros();
exp_ *= 2;
}

View File

@ -520,9 +520,9 @@ FMT_CONSTEXPR inline size_t compute_width(string_view s) {
1 +
(error == 0 && cp >= 0x1100 &&
(cp <= 0x115f || // Hangul Jamo init. consonants
cp == 0x2329 || // LEFT-POINTING ANGLE BRACKET
cp == 0x232a || // RIGHT-POINTING ANGLE BRACKET
// CJK ... Yi except Unicode Character “〿”:
cp == 0x2329 || // LEFT-POINTING ANGLE BRACKET
cp == 0x232a || // RIGHT-POINTING ANGLE BRACKET
// CJK ... Yi except IDEOGRAPHIC HALF FILL SPACE:
(cp >= 0x2e80 && cp <= 0xa4cf && cp != 0x303f) ||
(cp >= 0xac00 && cp <= 0xd7a3) || // Hangul Syllables
(cp >= 0xf900 && cp <= 0xfaff) || // CJK Compatibility Ideographs
@ -603,7 +603,7 @@ enum { inline_buffer_size = 500 };
A dynamically growing memory buffer for trivially copyable/constructible types
with the first ``SIZE`` elements stored in the object itself.
You can use the ```memory_buffer`` type alias for ``char`` instead.
You can use the ``memory_buffer`` type alias for ``char`` instead.
**Example**::
@ -859,7 +859,7 @@ template <typename T = void> struct basic_data {
static const uint64_t log10_2_significand = 0x4d104d427de7fbcc;
// GCC generates slightly better code for pairs than chars.
FMT_API static constexpr const char digits[][2] = {
FMT_API static constexpr const char digits[100][2] = {
{'0', '0'}, {'0', '1'}, {'0', '2'}, {'0', '3'}, {'0', '4'}, {'0', '5'},
{'0', '6'}, {'0', '7'}, {'0', '8'}, {'0', '9'}, {'1', '0'}, {'1', '1'},
{'1', '2'}, {'1', '3'}, {'1', '4'}, {'1', '5'}, {'1', '6'}, {'1', '7'},
@ -879,11 +879,13 @@ template <typename T = void> struct basic_data {
{'9', '6'}, {'9', '7'}, {'9', '8'}, {'9', '9'}};
FMT_API static constexpr const char hex_digits[] = "0123456789abcdef";
FMT_API static constexpr const char signs[] = {0, '-', '+', ' '};
FMT_API static constexpr const char signs[4] = {0, '-', '+', ' '};
FMT_API static constexpr const unsigned prefixes[4] = {0, 0, 0x1000000u | '+',
0x1000000u | ' '};
FMT_API static constexpr const char left_padding_shifts[] = {31, 31, 0, 1, 0};
FMT_API static constexpr const char right_padding_shifts[] = {0, 31, 0, 1, 0};
FMT_API static constexpr const char left_padding_shifts[5] = {31, 31, 0, 1,
0};
FMT_API static constexpr const char right_padding_shifts[5] = {0, 31, 0, 1,
0};
};
#ifdef FMT_SHARED
@ -1023,7 +1025,7 @@ template <> inline auto decimal_point(locale_ref loc) -> wchar_t {
// Compares two characters for equality.
template <typename Char> auto equal2(const Char* lhs, const char* rhs) -> bool {
return lhs[0] == rhs[0] && lhs[1] == rhs[1];
return lhs[0] == Char(rhs[0]) && lhs[1] == Char(rhs[1]);
}
inline auto equal2(const char* lhs, const char* rhs) -> bool {
return memcmp(lhs, rhs, 2) == 0;
@ -1567,6 +1569,7 @@ FMT_CONSTEXPR auto write(OutputIt out,
basic_string_view<type_identity_t<Char>> s,
const basic_format_specs<Char>& specs, locale_ref)
-> OutputIt {
check_string_type_spec(specs.type);
return write(out, s, specs);
}
template <typename Char, typename OutputIt>
@ -2621,9 +2624,10 @@ auto to_string(const basic_memory_buffer<Char, SIZE>& buf)
FMT_BEGIN_DETAIL_NAMESPACE
template <typename Char>
void vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt,
basic_format_args<buffer_context<type_identity_t<Char>>> args,
locale_ref loc) {
void vformat_to(
buffer<Char>& buf, basic_string_view<Char> fmt,
basic_format_args<FMT_BUFFER_CONTEXT(type_identity_t<Char>)> args,
locale_ref loc) {
// workaround for msvc bug regarding name-lookup in module
// link names into function scope
using detail::arg_formatter;
@ -2703,10 +2707,6 @@ void vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt,
}
#ifndef FMT_HEADER_ONLY
extern template void vformat_to(detail::buffer<char>&, string_view,
basic_format_args<format_context>,
detail::locale_ref);
extern template FMT_API auto thousands_sep_impl<char>(locale_ref)
-> thousands_sep_result<char>;
extern template FMT_API auto thousands_sep_impl<wchar_t>(locale_ref)
@ -2730,6 +2730,8 @@ extern template auto snprintf_float<long double>(long double value,
#endif // FMT_HEADER_ONLY
FMT_END_DETAIL_NAMESPACE
#if FMT_USE_USER_DEFINED_LITERALS
inline namespace literals {
/**
\rst
@ -2741,18 +2743,18 @@ inline namespace literals {
fmt::print("Elapsed time: {s:.2f} seconds", "s"_a=1.23);
\endrst
*/
#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS
# if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS
template <detail_exported::fixed_string Str>
constexpr auto operator""_a()
-> detail::udl_arg<remove_cvref_t<decltype(Str.data[0])>,
sizeof(Str.data) / sizeof(decltype(Str.data[0])), Str> {
return {};
}
#else
# else
constexpr auto operator"" _a(const char* s, size_t) -> detail::udl_arg<char> {
return {s};
}
#endif
# endif
/**
\rst
@ -2769,6 +2771,7 @@ constexpr auto operator"" _format(const char* s, size_t n)
return {{s, n}};
}
} // namespace literals
#endif // FMT_USE_USER_DEFINED_LITERALS
template <typename Locale, FMT_ENABLE_IF(detail::is_locale<Locale>::value)>
inline auto vformat(const Locale& loc, string_view fmt, format_args args)

View File

@ -394,7 +394,7 @@ struct ostream_params {
FMT_END_DETAIL_NAMESPACE
static constexpr detail::buffer_size buffer_size;
constexpr detail::buffer_size buffer_size;
/** A fast output stream which is not thread-safe. */
class FMT_API ostream final : private detail::buffer<char> {

View File

@ -1,2 +0,0 @@
#include "os.h"
#warning "fmt/posix.h is deprecated; use fmt/os.h instead"

View File

@ -392,7 +392,8 @@ struct formatter<tuple_join_view<Char, T...>, Char> {
auto format(const tuple_join_view<Char, T...>& value, FormatContext& ctx,
detail::index_sequence<N...>) ->
typename FormatContext::iterator {
return format_args(value, ctx, std::get<N>(value.tuple)...);
using std::get;
return format_args(value, ctx, get<N>(value.tuple)...);
}
template <typename FormatContext>

View File

@ -142,7 +142,7 @@ FMT_DEPRECATED auto format_to(basic_memory_buffer<Char, SIZE, Allocator>& buf,
const S& format_str, Args&&... args) ->
typename buffer_context<Char>::iterator {
const auto& vargs = fmt::make_args_checked<Args...>(format_str, args...);
detail::vformat_to(buf, to_string_view(format_str), vargs);
detail::vformat_to(buf, to_string_view(format_str), vargs, {});
return detail::buffer_appender<Char>(buf);
}