mirror of
https://github.com/shadps4-emu/ext-fmt.git
synced 2024-11-23 09:49:42 +00:00
Formatting of function pointers, member function pointers, member object pointers... (#2610)
This commit is contained in:
parent
19cac63fe4
commit
a3ab36c803
@ -1372,8 +1372,11 @@ template <typename Context> struct arg_mapper {
|
||||
// the C array overload.
|
||||
template <
|
||||
typename T,
|
||||
FMT_ENABLE_IF(std::is_convertible<const T&, const void*>::value &&
|
||||
!std::is_convertible<const T&, const char_type*>::value)>
|
||||
FMT_ENABLE_IF(
|
||||
std::is_member_pointer<T>::value ||
|
||||
std::is_function<typename std::remove_pointer<T>::type>::value ||
|
||||
(std::is_convertible<const T&, const void*>::value &&
|
||||
!std::is_convertible<const T&, const char_type*>::value))>
|
||||
FMT_CONSTEXPR auto map(const T&) -> unformattable_pointer {
|
||||
return {};
|
||||
}
|
||||
|
@ -67,6 +67,12 @@ expect_compile_error("
|
||||
fmt::format(\"{}\", S());
|
||||
")
|
||||
|
||||
# Formatting a function
|
||||
expect_compile_error("
|
||||
void (*f)();
|
||||
fmt::format(\"{}\", f);
|
||||
")
|
||||
|
||||
# Make sure that compiler features detected in the header
|
||||
# match the features detected in CMake.
|
||||
if (SUPPORTS_USER_DEFINED_LITERALS)
|
||||
|
@ -770,6 +770,13 @@ TEST(core_test, is_formattable) {
|
||||
static_assert(!fmt::is_formattable<unsigned char*, wchar_t>::value, "");
|
||||
static_assert(!fmt::is_formattable<const signed char*, wchar_t>::value, "");
|
||||
static_assert(!fmt::is_formattable<const unsigned char*, wchar_t>::value, "");
|
||||
|
||||
static_assert(!fmt::is_formattable<void (*)()>::value, "");
|
||||
|
||||
struct s;
|
||||
|
||||
static_assert(!fmt::is_formattable<int(s::*)>::value, "");
|
||||
static_assert(!fmt::is_formattable<int (s::*)()>::value, "");
|
||||
}
|
||||
|
||||
TEST(core_test, format) { EXPECT_EQ(fmt::format("{}", 42), "42"); }
|
||||
|
Loading…
Reference in New Issue
Block a user