diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-07-17 10:28:00 +0200 |
---|---|---|
committer | Led Mitz <smoothshifter@tuta.io> | 2024-10-19 18:19:49 +0000 |
commit | 27f0a0292803ba109a75e4e3c30d9b1eaaec7980 (patch) | |
tree | 383036da73bad060e3ac46fab6fd9f27afbcafc1 | |
parent | 7df2af70b994abc56f9178128e5d7549f04b712b (diff) | |
download | tmwa-underlying_type.tar.gz tmwa-underlying_type.tar.bz2 tmwa-underlying_type.tar.xz tmwa-underlying_type.zip |
Use std::underlying_typeunderlying_type
Since according to the comment, TMWA already depended on GCC 4.7.
-rw-r--r-- | src/generic/enum.hpp | 14 | ||||
-rw-r--r-- | src/io/extract.hpp | 4 |
2 files changed, 2 insertions, 16 deletions
diff --git a/src/generic/enum.hpp b/src/generic/enum.hpp index d5d50ea..07605fb 100644 --- a/src/generic/enum.hpp +++ b/src/generic/enum.hpp @@ -72,19 +72,7 @@ public: } }; -// std::underlying_type isn't supported until gcc 4.7 -// this is a poor man's emulation -// TODO I'm depending on GCC 4.7 now, this can go away -template<class E> -struct underlying_type -{ - static_assert(std::is_enum<E>::value, "Only enums have underlying type!"); - typedef typename std::conditional< - std::is_signed<E>::value, - typename std::make_signed<E>::type, - typename std::make_unsigned<E>::type - >::type type; -}; +using std::underlying_type; template<class E, bool=std::is_enum<E>::value> struct remove_enum diff --git a/src/io/extract.hpp b/src/io/extract.hpp index 897f50e..3eecf3c 100644 --- a/src/io/extract.hpp +++ b/src/io/extract.hpp @@ -33,8 +33,6 @@ #include "../compat/time_t.hpp" -#include "../generic/enum.hpp" - namespace tmwa { @@ -83,7 +81,7 @@ bool impl_extract(XString str, TimeT *tv) template<class T, typename=typename std::enable_if<std::is_enum<T>::value>::type> bool extract_as_int(XString str, T *iv) { - typedef typename underlying_type<T>::type U; + typedef typename std::underlying_type<T>::type U; U v; // defer to integer version if (!extract(str, &v)) |