Merge 2d529031a8 into 62df6f27cb
This commit is contained in:
commit
850d84cebc
24
fmt/format.h
24
fmt/format.h
@ -1227,6 +1227,20 @@ struct WCharHelper<T, wchar_t> {
|
|||||||
typedef Null<T> Unsupported;
|
typedef Null<T> Unsupported;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// A helper class template to enable or disable overloads taking
|
||||||
|
// characters and strings in MakeValue.
|
||||||
|
template <typename T, typename Char>
|
||||||
|
struct CharHelper {
|
||||||
|
typedef T Supported;
|
||||||
|
typedef Null<T> Unsupported;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct CharHelper<T, wchar_t> {
|
||||||
|
typedef Null<T> Supported;
|
||||||
|
typedef T Unsupported;
|
||||||
|
};
|
||||||
|
|
||||||
typedef char Yes[1];
|
typedef char Yes[1];
|
||||||
typedef char No[2];
|
typedef char No[2];
|
||||||
|
|
||||||
@ -1370,6 +1384,12 @@ class MakeValue : public Arg {
|
|||||||
#endif
|
#endif
|
||||||
MakeValue(typename WCharHelper<WStringRef, Char>::Unsupported);
|
MakeValue(typename WCharHelper<WStringRef, Char>::Unsupported);
|
||||||
|
|
||||||
|
MakeValue(typename CharHelper<const std::string &, Char>::Unsupported);
|
||||||
|
#if FMT_HAS_STRING_VIEW
|
||||||
|
MakeValue(typename CharHelper<const std::string_view &, Char>::Unsupported);
|
||||||
|
#endif
|
||||||
|
MakeValue(typename CharHelper<StringRef, Char>::Unsupported);
|
||||||
|
|
||||||
void set_string(StringRef str) {
|
void set_string(StringRef str) {
|
||||||
string.value = str.data();
|
string.value = str.data();
|
||||||
string.size = str.size();
|
string.size = str.size();
|
||||||
@ -1459,7 +1479,9 @@ class MakeValue : public Arg {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FMT_MAKE_STR_VALUE(Type, TYPE) \
|
#define FMT_MAKE_STR_VALUE(Type, TYPE) \
|
||||||
MakeValue(Type value) { set_string(value); } \
|
MakeValue(typename CharHelper<Type, Char>::Supported value) { \
|
||||||
|
set_string(value); \
|
||||||
|
} \
|
||||||
static uint64_t type(Type) { return Arg::TYPE; }
|
static uint64_t type(Type) { return Arg::TYPE; }
|
||||||
|
|
||||||
FMT_MAKE_VALUE(char *, string.value, CSTRING)
|
FMT_MAKE_VALUE(char *, string.value, CSTRING)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user