Move _BitInt next to bitref formatter
This commit is contained in:
@@ -196,23 +196,6 @@ struct is_contiguous<std::basic_string<Char, Traits, Allocator>>
|
||||
|
||||
namespace detail {
|
||||
|
||||
#ifdef FMT_USE_BITINT
|
||||
// Use the provided definition.
|
||||
#elif FMT_CLANG_VERSION >= 1500 && !defined(__CUDACC__)
|
||||
# define FMT_USE_BITINT 1
|
||||
#else
|
||||
# define FMT_USE_BITINT 0
|
||||
#endif
|
||||
|
||||
#if FMT_USE_BITINT
|
||||
FMT_PRAGMA_CLANG(diagnostic ignored "-Wbit-int-extension")
|
||||
template <int N> using bitint = _BitInt(N);
|
||||
template <int N> using ubitint = unsigned _BitInt(N);
|
||||
#else
|
||||
template <int N> struct bitint {};
|
||||
template <int N> struct ubitint {};
|
||||
#endif // FMT_USE_BITINT
|
||||
|
||||
// __builtin_clz is broken in clang with Microsoft codegen:
|
||||
// https://github.com/fmtlib/fmt/issues/519.
|
||||
#if !FMT_MSC_VERSION
|
||||
@@ -4053,30 +4036,6 @@ template <typename Char, typename Traits, typename Allocator>
|
||||
class formatter<std::basic_string<Char, Traits, Allocator>, Char>
|
||||
: public formatter<basic_string_view<Char>, Char> {};
|
||||
|
||||
template <int N, typename Char>
|
||||
struct formatter<detail::bitint<N>, Char> : formatter<long long, Char> {
|
||||
static_assert(N <= 64, "unsupported _BitInt");
|
||||
static auto format_as(detail::bitint<N> x) -> long long {
|
||||
return static_cast<long long>(x);
|
||||
}
|
||||
template <typename Context>
|
||||
auto format(detail::bitint<N> x, Context& ctx) const -> decltype(ctx.out()) {
|
||||
return formatter<long long, Char>::format(format_as(x), ctx);
|
||||
}
|
||||
};
|
||||
|
||||
template <int N, typename Char>
|
||||
struct formatter<detail::ubitint<N>, Char> : formatter<ullong, Char> {
|
||||
static_assert(N <= 64, "unsupported _BitInt");
|
||||
static auto format_as(detail::ubitint<N> x) -> ullong {
|
||||
return static_cast<ullong>(x);
|
||||
}
|
||||
template <typename Context>
|
||||
auto format(detail::ubitint<N> x, Context& ctx) const -> decltype(ctx.out()) {
|
||||
return formatter<ullong, Char>::format(format_as(x), ctx);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Char>
|
||||
struct formatter<detail::float128, Char>
|
||||
: detail::native_formatter<detail::float128, Char,
|
||||
|
||||
@@ -79,6 +79,23 @@
|
||||
FMT_BEGIN_NAMESPACE
|
||||
namespace detail {
|
||||
|
||||
#ifdef FMT_USE_BITINT
|
||||
// Use the provided definition.
|
||||
#elif FMT_CLANG_VERSION >= 1500 && !defined(__CUDACC__)
|
||||
# define FMT_USE_BITINT 1
|
||||
#else
|
||||
# define FMT_USE_BITINT 0
|
||||
#endif
|
||||
|
||||
#if FMT_USE_BITINT
|
||||
FMT_PRAGMA_CLANG(diagnostic ignored "-Wbit-int-extension")
|
||||
template <int N> using bitint = _BitInt(N);
|
||||
template <int N> using ubitint = unsigned _BitInt(N);
|
||||
#else
|
||||
template <int N> struct bitint {};
|
||||
template <int N> struct ubitint {};
|
||||
#endif // FMT_USE_BITINT
|
||||
|
||||
#if FMT_CPP_LIB_FILESYSTEM
|
||||
|
||||
template <typename Char, typename PathChar>
|
||||
@@ -611,6 +628,30 @@ struct formatter<
|
||||
}
|
||||
};
|
||||
|
||||
template <int N, typename Char>
|
||||
struct formatter<detail::bitint<N>, Char> : formatter<long long, Char> {
|
||||
static_assert(N <= 64, "unsupported _BitInt");
|
||||
static auto format_as(detail::bitint<N> x) -> long long {
|
||||
return static_cast<long long>(x);
|
||||
}
|
||||
template <typename Context>
|
||||
auto format(detail::bitint<N> x, Context& ctx) const -> decltype(ctx.out()) {
|
||||
return formatter<long long, Char>::format(format_as(x), ctx);
|
||||
}
|
||||
};
|
||||
|
||||
template <int N, typename Char>
|
||||
struct formatter<detail::ubitint<N>, Char> : formatter<ullong, Char> {
|
||||
static_assert(N <= 64, "unsupported _BitInt");
|
||||
static auto format_as(detail::ubitint<N> x) -> ullong {
|
||||
return static_cast<ullong>(x);
|
||||
}
|
||||
template <typename Context>
|
||||
auto format(detail::ubitint<N> x, Context& ctx) const -> decltype(ctx.out()) {
|
||||
return formatter<ullong, Char>::format(format_as(x), ctx);
|
||||
}
|
||||
};
|
||||
|
||||
// We can't use std::vector<bool, Allocator>::reference and
|
||||
// std::bitset<N>::reference because the compiler can't deduce Allocator and N
|
||||
// in partial specialization.
|
||||
|
||||
Reference in New Issue
Block a user