From 44ba9a9eebec2ffe202fc5594f76864a56f3730a Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Wed, 23 Jul 2014 17:05:58 -0700 Subject: Enums are not usually integers, sorry --- src/io/cxxstdio.hpp | 85 ++--------------------------------------------------- 1 file changed, 2 insertions(+), 83 deletions(-) (limited to 'src/io/cxxstdio.hpp') 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::value>::type> - typename remove_enum::type decay_for_printf(T v) + T decay_for_printf(T v) { - typedef typename remove_enum::type repr_type; - return repr_type(v); + return v; } template()))> @@ -69,84 +66,6 @@ namespace cxxstdio inline const char *convert_for_printf(const char *) = delete; -#if 0 - template - constexpr - E get_enum_min_value(decltype(E::min_value)) - { - return E::min_value; - } - template - constexpr - E get_enum_min_value(E def) - { - return def; - } - - template - constexpr - E get_enum_max_value(decltype(E::max_value)) - { - return E::max_value; - } - template - constexpr - E get_enum_max_value(E def) - { - return def; - } -#else - template - constexpr - E get_enum_min_value(E) - { - return E::min_value; - } - template - constexpr - E get_enum_max_value(E) - { - return E::max_value; - } -#endif - - template - class EnumConverter - { - E& out; - typedef typename underlying_type::type U; -#if 0 - constexpr static - U min_value = U(get_enum_min_value(E(std::numeric_limits::min()))); - constexpr static - U max_value = U(get_enum_max_value(E(std::numeric_limits::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 PrintFormatter { -- cgit v1.2.3-60-g2f50