Cleanup core.h

This commit is contained in:
Victor Zverovich 2022-12-26 07:36:34 -08:00
parent 3e762fdf5c
commit a921a596e7
2 changed files with 28 additions and 32 deletions

View File

@ -152,8 +152,7 @@
# endif # endif
#endif #endif
// [[noreturn]] is disabled on MSVC and NVCC because of bogus unreachable code // Disable [[noreturn]] on MSVC/NVCC because of bogus unreachable code warnings.
// warnings.
#if FMT_EXCEPTIONS && FMT_HAS_CPP_ATTRIBUTE(noreturn) && !FMT_MSC_VERSION && \ #if FMT_EXCEPTIONS && FMT_HAS_CPP_ATTRIBUTE(noreturn) && !FMT_MSC_VERSION && \
!defined(__NVCC__) !defined(__NVCC__)
# define FMT_NORETURN [[noreturn]] # define FMT_NORETURN [[noreturn]]
@ -308,18 +307,6 @@ template <typename T> using type_identity_t = typename type_identity<T>::type;
template <typename T> template <typename T>
using underlying_t = typename std::underlying_type<T>::type; using underlying_t = typename std::underlying_type<T>::type;
template <typename...> struct disjunction : std::false_type {};
template <typename P> struct disjunction<P> : P {};
template <typename P1, typename... Pn>
struct disjunction<P1, Pn...>
: conditional_t<bool(P1::value), P1, disjunction<Pn...>> {};
template <typename...> struct conjunction : std::true_type {};
template <typename P> struct conjunction<P> : P {};
template <typename P1, typename... Pn>
struct conjunction<P1, Pn...>
: conditional_t<bool(P1::value), conjunction<Pn...>, P1> {};
struct monostate { struct monostate {
constexpr monostate() {} constexpr monostate() {}
}; };
@ -1682,9 +1669,8 @@ FMT_CONSTEXPR auto copy_str(R&& rng, OutputIt out) -> OutputIt {
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 500 #if FMT_GCC_VERSION && FMT_GCC_VERSION < 500
// A workaround for gcc 4.8 to make void_t work in a SFINAE context. // A workaround for gcc 4.8 to make void_t work in a SFINAE context.
template <typename... Ts> struct void_t_impl { using type = void; }; template <typename...> struct void_t_impl { using type = void; };
template <typename... Ts> template <typename... T> using void_t = typename void_t_impl<T...>::type;
using void_t = typename detail::void_t_impl<Ts...>::type;
#else #else
template <typename...> using void_t = void; template <typename...> using void_t = void;
#endif #endif
@ -1699,13 +1685,12 @@ struct is_output_iterator<
decltype(*std::declval<It>() = std::declval<T>())>> decltype(*std::declval<It>() = std::declval<T>())>>
: std::true_type {}; : std::true_type {};
template <typename OutputIt> template <typename It> struct is_back_insert_iterator : std::false_type {};
struct is_back_insert_iterator : std::false_type {};
template <typename Container> template <typename Container>
struct is_back_insert_iterator<std::back_insert_iterator<Container>> struct is_back_insert_iterator<std::back_insert_iterator<Container>>
: std::true_type {}; : std::true_type {};
template <typename OutputIt> template <typename It>
struct is_contiguous_back_insert_iterator : std::false_type {}; struct is_contiguous_back_insert_iterator : std::false_type {};
template <typename Container> template <typename Container>
struct is_contiguous_back_insert_iterator<std::back_insert_iterator<Container>> struct is_contiguous_back_insert_iterator<std::back_insert_iterator<Container>>
@ -1749,10 +1734,9 @@ FMT_CONSTEXPR FMT_INLINE auto make_value(T&& val) -> value<Context> {
!std::is_same<decltype(arg), const unformattable_const&>::value; !std::is_same<decltype(arg), const unformattable_const&>::value;
static_assert(formattable_const, "Cannot format a const argument."); static_assert(formattable_const, "Cannot format a const argument.");
// Formatting of arbitrary pointers is disallowed. If you want to output // Formatting of arbitrary pointers is disallowed. If you want to format a
// a pointer cast it to "void *" or "const void *". In particular, this // pointer cast it to `void*` or `const void*`. In particular, this forbids
// forbids formatting of "[const] volatile char *" which is printed as bool // formatting of `[const] volatile char*` printed as bool by iostreams.
// by iostreams.
constexpr bool formattable_pointer = constexpr bool formattable_pointer =
!std::is_same<decltype(arg), const unformattable_pointer&>::value; !std::is_same<decltype(arg), const unformattable_pointer&>::value;
static_assert(formattable_pointer, static_assert(formattable_pointer,
@ -1769,7 +1753,7 @@ FMT_CONSTEXPR FMT_INLINE auto make_value(T&& val) -> value<Context> {
template <typename Context, typename T> template <typename Context, typename T>
FMT_CONSTEXPR auto make_arg(T&& value) -> basic_format_arg<Context> { FMT_CONSTEXPR auto make_arg(T&& value) -> basic_format_arg<Context> {
basic_format_arg<Context> arg; auto arg = basic_format_arg<Context>();
arg.type_ = mapped_type_constant<T, Context>::value; arg.type_ = mapped_type_constant<T, Context>::value;
arg.value_ = make_value<Context>(value); arg.value_ = make_value<Context>(value);
return arg; return arg;
@ -1793,10 +1777,6 @@ FMT_END_DETAIL_NAMESPACE
// Formatting context. // Formatting context.
template <typename OutputIt, typename Char> class basic_format_context { template <typename OutputIt, typename Char> class basic_format_context {
public:
/** The character type for the output. */
using char_type = Char;
private: private:
OutputIt out_; OutputIt out_;
basic_format_args<basic_format_context> args_; basic_format_args<basic_format_context> args_;
@ -1806,7 +1786,10 @@ template <typename OutputIt, typename Char> class basic_format_context {
using iterator = OutputIt; using iterator = OutputIt;
using format_arg = basic_format_arg<basic_format_context>; using format_arg = basic_format_arg<basic_format_context>;
using parse_context_type = basic_format_parse_context<Char>; using parse_context_type = basic_format_parse_context<Char>;
template <typename T> using formatter_type = formatter<T, char_type>; template <typename T> using formatter_type = formatter<T, Char>;
/** The character type for the output. */
using char_type = Char;
basic_format_context(basic_format_context&&) = default; basic_format_context(basic_format_context&&) = default;
basic_format_context(const basic_format_context&) = delete; basic_format_context(const basic_format_context&) = delete;
@ -1821,10 +1804,10 @@ template <typename OutputIt, typename Char> class basic_format_context {
: out_(out), args_(ctx_args), loc_(loc) {} : out_(out), args_(ctx_args), loc_(loc) {}
constexpr auto arg(int id) const -> format_arg { return args_.get(id); } constexpr auto arg(int id) const -> format_arg { return args_.get(id); }
FMT_CONSTEXPR auto arg(basic_string_view<char_type> name) -> format_arg { FMT_CONSTEXPR auto arg(basic_string_view<Char> name) -> format_arg {
return args_.get(name); return args_.get(name);
} }
FMT_CONSTEXPR auto arg_id(basic_string_view<char_type> name) -> int { FMT_CONSTEXPR auto arg_id(basic_string_view<Char> name) -> int {
return args_.get_id(name); return args_.get_id(name);
} }
auto args() const -> const basic_format_args<basic_format_context>& { auto args() const -> const basic_format_args<basic_format_context>& {

View File

@ -241,6 +241,19 @@ FMT_END_NAMESPACE
#endif #endif
FMT_BEGIN_NAMESPACE FMT_BEGIN_NAMESPACE
template <typename...> struct disjunction : std::false_type {};
template <typename P> struct disjunction<P> : P {};
template <typename P1, typename... Pn>
struct disjunction<P1, Pn...>
: conditional_t<bool(P1::value), P1, disjunction<Pn...>> {};
template <typename...> struct conjunction : std::true_type {};
template <typename P> struct conjunction<P> : P {};
template <typename P1, typename... Pn>
struct conjunction<P1, Pn...>
: conditional_t<bool(P1::value), conjunction<Pn...>, P1> {};
namespace detail { namespace detail {
FMT_CONSTEXPR inline void abort_fuzzing_if(bool condition) { FMT_CONSTEXPR inline void abort_fuzzing_if(bool condition) {