mirror of
https://github.com/fmtlib/fmt.git
synced 2026-06-11 11:41:19 +02:00
Cleanup
This commit is contained in:
+6
-13
@@ -73,12 +73,7 @@ class dynamic_arg_list {
|
||||
* into type-erased formatting functions such as `fmt::vformat`.
|
||||
*/
|
||||
template <typename Context>
|
||||
class dynamic_format_arg_store
|
||||
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409
|
||||
// Workaround a GCC template argument substitution bug.
|
||||
: public basic_format_args<Context>
|
||||
#endif
|
||||
{
|
||||
class dynamic_format_arg_store {
|
||||
private:
|
||||
using char_type = typename Context::char_type;
|
||||
|
||||
@@ -97,7 +92,7 @@ class dynamic_format_arg_store
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
using stored_type = conditional_t<
|
||||
using stored_t = conditional_t<
|
||||
std::is_convertible<T, std::basic_string<char_type>>::value &&
|
||||
!detail::is_reference_wrapper<T>::value,
|
||||
std::basic_string<char_type>, T>;
|
||||
@@ -122,10 +117,8 @@ class dynamic_format_arg_store
|
||||
|
||||
template <typename T>
|
||||
void emplace_arg(const detail::named_arg<char_type, T>& arg) {
|
||||
if (named_info_.empty()) {
|
||||
constexpr const detail::named_arg_info<char_type>* zero_ptr{nullptr};
|
||||
data_.insert(data_.begin(), basic_format_arg<Context>(zero_ptr, 0));
|
||||
}
|
||||
if (named_info_.empty())
|
||||
data_.insert(data_.begin(), basic_format_arg<Context>(nullptr, 0));
|
||||
data_.emplace_back(detail::make_arg<Context>(detail::unwrap(arg.value)));
|
||||
auto pop_one = [](std::vector<basic_format_arg<Context>>* data) {
|
||||
data->pop_back();
|
||||
@@ -162,7 +155,7 @@ class dynamic_format_arg_store
|
||||
*/
|
||||
template <typename T> void push_back(const T& arg) {
|
||||
if (detail::const_check(need_copy<T>::value))
|
||||
emplace_arg(dynamic_args_.push<stored_type<T>>(arg));
|
||||
emplace_arg(dynamic_args_.push<stored_t<T>>(arg));
|
||||
else
|
||||
emplace_arg(detail::unwrap(arg));
|
||||
}
|
||||
@@ -198,7 +191,7 @@ class dynamic_format_arg_store
|
||||
dynamic_args_.push<std::basic_string<char_type>>(arg.name).c_str();
|
||||
if (detail::const_check(need_copy<T>::value)) {
|
||||
emplace_arg(
|
||||
fmt::arg(arg_name, dynamic_args_.push<stored_type<T>>(arg.value)));
|
||||
fmt::arg(arg_name, dynamic_args_.push<stored_t<T>>(arg.value)));
|
||||
} else {
|
||||
emplace_arg(fmt::arg(arg_name, arg.value));
|
||||
}
|
||||
|
||||
+9
-12
@@ -140,17 +140,14 @@ FMT_END_NAMESPACE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef FMT_USE_USER_DEFINED_LITERALS
|
||||
#ifndef FMT_USE_USER_LITERALS
|
||||
// EDG based compilers (Intel, NVIDIA, Elbrus, etc), GCC and MSVC support UDLs.
|
||||
//
|
||||
// GCC before 4.9 requires a space in `operator"" _a` which is invalid in later
|
||||
// compiler versions.
|
||||
# if (FMT_HAS_FEATURE(cxx_user_literals) || FMT_GCC_VERSION >= 409 || \
|
||||
# if (FMT_HAS_FEATURE(cxx_user_literals) || FMT_GCC_VERSION || \
|
||||
FMT_MSC_VERSION >= 1900) && \
|
||||
(!defined(__EDG_VERSION__) || __EDG_VERSION__ >= /* UDL feature */ 480)
|
||||
# define FMT_USE_USER_DEFINED_LITERALS 1
|
||||
# define FMT_USE_USER_LITERALS 1
|
||||
# else
|
||||
# define FMT_USE_USER_DEFINED_LITERALS 0
|
||||
# define FMT_USE_USER_LITERALS 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -3775,7 +3772,7 @@ FMT_CONSTEXPR void handle_dynamic_spec(
|
||||
if (kind != arg_id_kind::none) value = get_dynamic_spec(kind, ref, ctx);
|
||||
}
|
||||
|
||||
#if FMT_USE_USER_DEFINED_LITERALS
|
||||
#if FMT_USE_USER_LITERALS
|
||||
# if FMT_USE_NONTYPE_TEMPLATE_ARGS
|
||||
template <typename T, typename Char, size_t N,
|
||||
fmt::detail_exported::fixed_string<Char, N> Str>
|
||||
@@ -3810,8 +3807,8 @@ template <typename Char> struct udl_arg {
|
||||
return {str, std::forward<T>(value)};
|
||||
}
|
||||
};
|
||||
# endif
|
||||
#endif // FMT_USE_USER_DEFINED_LITERALS
|
||||
# endif // FMT_USE_NONTYPE_TEMPLATE_ARGS
|
||||
#endif // FMT_USE_USER_LITERALS
|
||||
|
||||
template <typename Char> struct format_handler {
|
||||
parse_context<Char> parse_ctx;
|
||||
@@ -4294,7 +4291,7 @@ struct formatter<detail::float128, Char>
|
||||
: detail::native_formatter<detail::float128, Char,
|
||||
detail::type::float_type> {};
|
||||
|
||||
#if FMT_USE_USER_DEFINED_LITERALS
|
||||
#if FMT_USE_USER_LITERALS
|
||||
inline namespace literals {
|
||||
/**
|
||||
* User-defined literal equivalent of `fmt::arg`.
|
||||
@@ -4315,7 +4312,7 @@ constexpr auto operator""_a(const char* s, size_t) -> detail::udl_arg<char> {
|
||||
}
|
||||
# endif
|
||||
} // namespace literals
|
||||
#endif // FMT_USE_USER_DEFINED_LITERALS
|
||||
#endif // FMT_USE_USER_LITERALS
|
||||
|
||||
FMT_API auto vformat(string_view fmt, format_args args) -> std::string;
|
||||
|
||||
|
||||
+2
-2
@@ -147,8 +147,8 @@ FMT_API std::system_error vwindows_error(int error_code, string_view format_str,
|
||||
* }
|
||||
*/
|
||||
template <typename... T>
|
||||
std::system_error windows_error(int error_code, string_view message,
|
||||
const T&... args) {
|
||||
auto windows_error(int error_code, string_view message,
|
||||
const T&... args) -> std::system_error {
|
||||
return vwindows_error(error_code, message, vargs<T...>{{args...}});
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ constexpr auto make_wformat_args(T&... args)
|
||||
}
|
||||
|
||||
inline namespace literals {
|
||||
#if FMT_USE_USER_DEFINED_LITERALS && !FMT_USE_NONTYPE_TEMPLATE_ARGS
|
||||
#if FMT_USE_USER_LITERALS && !FMT_USE_NONTYPE_TEMPLATE_ARGS
|
||||
constexpr auto operator""_a(const wchar_t* s, size_t)
|
||||
-> detail::udl_arg<wchar_t> {
|
||||
return {s};
|
||||
|
||||
Reference in New Issue
Block a user