Commit 9328a074 authored by Victor Zverovich's avatar Victor Zverovich

Fix handling of fixed enums in clang (#580)

parent 2c077dd4
...@@ -1405,6 +1405,20 @@ class MakeValue : public Arg { ...@@ -1405,6 +1405,20 @@ class MakeValue : public Arg {
FMT_MAKE_VALUE(unsigned char, uint_value, UINT) FMT_MAKE_VALUE(unsigned char, uint_value, UINT)
FMT_MAKE_VALUE(char, int_value, CHAR) FMT_MAKE_VALUE(char, int_value, CHAR)
#if __cplusplus >= 201103L
template <
typename T,
typename = typename std::enable_if<
std::is_enum<T>::value && ConvertToInt<T>::value>::type>
MakeValue(T value) { int_value = value; }
template <
typename T,
typename = typename std::enable_if<
std::is_enum<T>::value && ConvertToInt<T>::value>::type>
static uint64_t type(T value) { return Arg::INT; }
#endif
#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
MakeValue(typename WCharHelper<wchar_t, Char>::Supported value) { MakeValue(typename WCharHelper<wchar_t, Char>::Supported value) {
int_value = value; int_value = value;
......
...@@ -1681,6 +1681,14 @@ TEST(FormatTest, Enum) { ...@@ -1681,6 +1681,14 @@ TEST(FormatTest, Enum) {
EXPECT_EQ("0", fmt::format("{}", A)); EXPECT_EQ("0", fmt::format("{}", A));
} }
#if __cplusplus >= 201103L
enum TestFixedEnum : short { B };
TEST(FormatTest, FixedEnum) {
EXPECT_EQ("0", fmt::format("{}", B));
}
#endif
class MockArgFormatter : class MockArgFormatter :
public fmt::internal::ArgFormatterBase<MockArgFormatter, char> { public fmt::internal::ArgFormatterBase<MockArgFormatter, char> {
public: public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment