mirror of
https://github.com/shadps4-emu/ext-fmt.git
synced 2024-11-23 09:49:42 +00:00
Add an is_formattable trait
This commit is contained in:
parent
578874033a
commit
835b910e7d
@ -1525,6 +1525,11 @@ using wformat_context = buffer_context<wchar_t>;
|
||||
#define FMT_BUFFER_CONTEXT(Char) \
|
||||
basic_format_context<detail::buffer_appender<Char>, Char>
|
||||
|
||||
template <typename T, typename Char = char>
|
||||
using is_formattable = bool_constant<!std::is_same<
|
||||
decltype(detail::arg_mapper<buffer_context<Char>>().map(std::declval<T>())),
|
||||
detail::unformattable>::value>;
|
||||
|
||||
/**
|
||||
\rst
|
||||
An array of references to arguments. It can be implicitly converted into
|
||||
|
@ -617,6 +617,12 @@ TEST(CoreTest, HasFormatter) {
|
||||
"");
|
||||
}
|
||||
|
||||
TEST(CoreTest, IsFormattable) {
|
||||
static_assert(fmt::is_formattable<enabled_formatter>::value, "");
|
||||
static_assert(!fmt::is_formattable<disabled_formatter>::value, "");
|
||||
static_assert(fmt::is_formattable<disabled_formatter_convertible>::value, "");
|
||||
}
|
||||
|
||||
struct convertible_to_int {
|
||||
operator int() const { return 42; }
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user