mirror of
https://github.com/fmtlib/fmt.git
synced 2025-11-28 13:19:48 +01:00
Fix #2818: diagnose unformattable arguments in unpacked case
This commit is contained in:
committed by
Victor Zverovich
parent
17ba99c1d2
commit
4ad90578f7
@@ -1260,7 +1260,7 @@ template <typename Context> class value {
|
||||
};
|
||||
|
||||
template <typename Context, typename T>
|
||||
FMT_CONSTEXPR auto make_arg(const T& value) -> basic_format_arg<Context>;
|
||||
FMT_CONSTEXPR auto make_arg(T&& value) -> basic_format_arg<Context>;
|
||||
|
||||
// To minimize the number of types we need to deal with, long is translated
|
||||
// either to int or to long long depending on its size.
|
||||
@@ -1513,7 +1513,7 @@ template <typename Context> class basic_format_arg {
|
||||
detail::type type_;
|
||||
|
||||
template <typename ContextType, typename T>
|
||||
friend FMT_CONSTEXPR auto detail::make_arg(const T& value)
|
||||
friend FMT_CONSTEXPR auto detail::make_arg(T&& value)
|
||||
-> basic_format_arg<ContextType>;
|
||||
|
||||
template <typename Visitor, typename Ctx>
|
||||
@@ -1674,19 +1674,7 @@ constexpr auto encode_types() -> unsigned long long {
|
||||
}
|
||||
|
||||
template <typename Context, typename T>
|
||||
FMT_CONSTEXPR auto make_arg(const T& value) -> basic_format_arg<Context> {
|
||||
basic_format_arg<Context> arg;
|
||||
arg.type_ = mapped_type_constant<T, Context>::value;
|
||||
arg.value_ = arg_mapper<Context>().map(value);
|
||||
return arg;
|
||||
}
|
||||
|
||||
// The type template parameter is there to avoid an ODR violation when using
|
||||
// a fallback formatter in one translation unit and an implicit conversion in
|
||||
// another (not recommended).
|
||||
template <bool IS_PACKED, typename Context, type, typename T,
|
||||
FMT_ENABLE_IF(IS_PACKED)>
|
||||
FMT_CONSTEXPR FMT_INLINE auto make_arg(T&& val) -> value<Context> {
|
||||
FMT_CONSTEXPR FMT_INLINE auto make_value(T&& val) -> value<Context> {
|
||||
const auto& arg = arg_mapper<Context>().map(std::forward<T>(val));
|
||||
|
||||
constexpr bool formattable_char =
|
||||
@@ -1715,9 +1703,26 @@ FMT_CONSTEXPR FMT_INLINE auto make_arg(T&& val) -> value<Context> {
|
||||
return {arg};
|
||||
}
|
||||
|
||||
template <typename Context, typename T>
|
||||
FMT_CONSTEXPR auto make_arg(T&& value) -> basic_format_arg<Context> {
|
||||
basic_format_arg<Context> arg;
|
||||
arg.type_ = mapped_type_constant<T, Context>::value;
|
||||
arg.value_ = make_value<Context>(value);
|
||||
return arg;
|
||||
}
|
||||
|
||||
// The type template parameter is there to avoid an ODR violation when using
|
||||
// a fallback formatter in one translation unit and an implicit conversion in
|
||||
// another (not recommended).
|
||||
template <bool IS_PACKED, typename Context, type, typename T,
|
||||
FMT_ENABLE_IF(IS_PACKED)>
|
||||
FMT_CONSTEXPR FMT_INLINE auto make_arg(T&& val) -> value<Context> {
|
||||
return make_value<Context>(val);
|
||||
}
|
||||
|
||||
template <bool IS_PACKED, typename Context, type, typename T,
|
||||
FMT_ENABLE_IF(!IS_PACKED)>
|
||||
inline auto make_arg(const T& value) -> basic_format_arg<Context> {
|
||||
FMT_CONSTEXPR inline auto make_arg(T&& value) -> basic_format_arg<Context> {
|
||||
return make_arg<Context>(value);
|
||||
}
|
||||
FMT_END_DETAIL_NAMESPACE
|
||||
|
||||
Reference in New Issue
Block a user