diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2014-07-23 17:05:58 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2014-08-05 15:59:36 -0700 |
commit | 44ba9a9eebec2ffe202fc5594f76864a56f3730a (patch) | |
tree | 3788e0507c1a116c45df7a1dd9275784de4d9b5a /src/io/cxxstdio.hpp | |
parent | 738e72ef3b38eef4e0684d49873714a602df53df (diff) | |
download | tmwa-44ba9a9eebec2ffe202fc5594f76864a56f3730a.tar.gz tmwa-44ba9a9eebec2ffe202fc5594f76864a56f3730a.tar.bz2 tmwa-44ba9a9eebec2ffe202fc5594f76864a56f3730a.tar.xz tmwa-44ba9a9eebec2ffe202fc5594f76864a56f3730a.zip |
Enums are not usually integers, sorry
Diffstat (limited to 'src/io/cxxstdio.hpp')
-rw-r--r-- | src/io/cxxstdio.hpp | 85 |
1 files changed, 2 insertions, 83 deletions
diff --git a/src/io/cxxstdio.hpp b/src/io/cxxstdio.hpp index 20d3a33..7312382 100644 --- a/src/io/cxxstdio.hpp +++ b/src/io/cxxstdio.hpp @@ -25,8 +25,6 @@ #include "../compat/cast.hpp" -#include "../generic/enum.hpp" - #include "../diagnostics.hpp" @@ -54,10 +52,9 @@ namespace cxxstdio } template<class T, typename=typename std::enable_if<!std::is_class<T>::value>::type> - typename remove_enum<T>::type decay_for_printf(T v) + T decay_for_printf(T v) { - typedef typename remove_enum<T>::type repr_type; - return repr_type(v); + return v; } template<class T, typename=decltype(decay_for_printf(std::declval<T&&>()))> @@ -69,84 +66,6 @@ namespace cxxstdio inline const char *convert_for_printf(const char *) = delete; -#if 0 - template<class E> - constexpr - E get_enum_min_value(decltype(E::min_value)) - { - return E::min_value; - } - template<class E> - constexpr - E get_enum_min_value(E def) - { - return def; - } - - template<class E> - constexpr - E get_enum_max_value(decltype(E::max_value)) - { - return E::max_value; - } - template<class E> - constexpr - E get_enum_max_value(E def) - { - return def; - } -#else - template<class E> - constexpr - E get_enum_min_value(E) - { - return E::min_value; - } - template<class E> - constexpr - E get_enum_max_value(E) - { - return E::max_value; - } -#endif - - template<class E> - class EnumConverter - { - E& out; - typedef typename underlying_type<E>::type U; -#if 0 - constexpr static - U min_value = U(get_enum_min_value<E>(E(std::numeric_limits<U>::min()))); - constexpr static - U max_value = U(get_enum_max_value<E>(E(std::numeric_limits<U>::max()))); -#else - constexpr static - U min_value = U(get_enum_min_value(E())); - constexpr static - U max_value = U(get_enum_max_value(E())); -#endif - U mid; - public: - EnumConverter(E& e) - : out(e), mid(0) - {} - ~EnumConverter() - { - DIAG_PUSH(); - DIAG_I(type_limits); - if (min_value <= mid && mid <= max_value) - { - DIAG_POP(); - out = E(mid); - } - } - U *operator &() - { - return ∣ - } - }; - template<class Format> class PrintFormatter { |