Fix dangling reference
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
This commit is contained in:
parent
d8973bf16b
commit
ee4a4611b1
@ -1671,27 +1671,26 @@ constexpr auto encode_types() -> unsigned long long {
|
|||||||
|
|
||||||
template <typename Context, typename T>
|
template <typename Context, typename T>
|
||||||
FMT_CONSTEXPR FMT_INLINE auto make_value(T&& val) -> value<Context> {
|
FMT_CONSTEXPR FMT_INLINE auto make_value(T&& val) -> value<Context> {
|
||||||
const auto& arg = arg_mapper<Context>().map(FMT_FORWARD(val));
|
using arg_type = decltype(arg_mapper<Context>().map(FMT_FORWARD(val)));
|
||||||
|
|
||||||
constexpr bool formattable_char =
|
constexpr bool formattable_char =
|
||||||
!std::is_same<decltype(arg), const unformattable_char&>::value;
|
!std::is_same<arg_type, unformattable_char>::value;
|
||||||
static_assert(formattable_char, "Mixing character types is disallowed.");
|
static_assert(formattable_char, "Mixing character types is disallowed.");
|
||||||
|
|
||||||
// Formatting of arbitrary pointers is disallowed. If you want to format a
|
// Formatting of arbitrary pointers is disallowed. If you want to format a
|
||||||
// pointer cast it to `void*` or `const void*`. In particular, this forbids
|
// pointer cast it to `void*` or `const void*`. In particular, this forbids
|
||||||
// formatting of `[const] volatile char*` printed as bool by iostreams.
|
// formatting of `[const] volatile char*` printed as bool by iostreams.
|
||||||
constexpr bool formattable_pointer =
|
constexpr bool formattable_pointer =
|
||||||
!std::is_same<decltype(arg), const unformattable_pointer&>::value;
|
!std::is_same<arg_type, unformattable_pointer>::value;
|
||||||
static_assert(formattable_pointer,
|
static_assert(formattable_pointer,
|
||||||
"Formatting of non-void pointers is disallowed.");
|
"Formatting of non-void pointers is disallowed.");
|
||||||
|
|
||||||
constexpr bool formattable =
|
constexpr bool formattable = !std::is_same<arg_type, unformattable>::value;
|
||||||
!std::is_same<decltype(arg), const unformattable&>::value;
|
|
||||||
static_assert(
|
static_assert(
|
||||||
formattable,
|
formattable,
|
||||||
"Cannot format an argument. To make type T formattable provide a "
|
"Cannot format an argument. To make type T formattable provide a "
|
||||||
"formatter<T> specialization: https://fmt.dev/latest/api.html#udt");
|
"formatter<T> specialization: https://fmt.dev/latest/api.html#udt");
|
||||||
return {arg};
|
return {arg_mapper<Context>().map(FMT_FORWARD(val))};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Context, typename T>
|
template <typename Context, typename T>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user