From 541d12092aba15dae59710a36d9b72dfc28b84d3 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Tue, 8 Sep 2015 18:48:54 -0700 Subject: [PATCH] Drop support for GCC < 4.8 in folly/Conv.h Summary: [Folly] Drop support for GCC < 4.8 in folly/Conv.h. Can't stay indefinitely backcompat with older compilers. Reviewed By: @Gownta, @JoelMarcey Differential Revision: D2422369 --- folly/Conv.h | 93 ----------------------------------------- folly/test/ConvTest.cpp | 5 --- 2 files changed, 98 deletions(-) diff --git a/folly/Conv.h b/folly/Conv.h index 8dd466ae..113a1495 100644 --- a/folly/Conv.h +++ b/folly/Conv.h @@ -547,9 +547,6 @@ estimateSpaceNeeded(Src value) { return estimateSpaceNeeded(static_cast(value)); } -#if defined(__clang__) || __GNUC_PREREQ(4, 7) -// std::underlying_type became available by gcc 4.7.0 - /** * Enumerated values get appended as integers. */ @@ -569,51 +566,6 @@ estimateSpaceNeeded(Src value) { static_cast::type>(value)); } -#else - -/** - * Enumerated values get appended as integers. - */ -template -typename std::enable_if< - std::is_enum::value && IsSomeString::value>::type -toAppend(Src value, Tgt * result) { - /* static */ if (Src(-1) < 0) { - /* static */ if (sizeof(Src) <= sizeof(int)) { - toAppend(static_cast(value), result); - } else { - toAppend(static_cast(value), result); - } - } else { - /* static */ if (sizeof(Src) <= sizeof(int)) { - toAppend(static_cast(value), result); - } else { - toAppend(static_cast(value), result); - } - } -} - -template -typename std::enable_if< - std::is_enum::value, size_t>::type -estimateSpaceNeeded(Src value) { - /* static */ if (Src(-1) < 0) { - /* static */ if (sizeof(Src) <= sizeof(int)) { - return estimateSpaceNeeded(static_cast(value)); - } else { - return estimateSpaceNeeded(static_cast(value)); - } - } else { - /* static */ if (sizeof(Src) <= sizeof(int)) { - return estimateSpaceNeeded(static_cast(value)); - } else { - return estimateSpaceNeeded(static_cast(value)); - } - } -} - -#endif // gcc 4.7 onwards - /******************************************************************************* * Conversions from floating-point types to string types. ******************************************************************************/ @@ -1477,9 +1429,6 @@ to(const Src & value) { * Enum to anything and back ******************************************************************************/ -#if defined(__clang__) || __GNUC_PREREQ(4, 7) -// std::underlying_type became available by gcc 4.7.0 - template typename std::enable_if< std::is_enum::value && !std::is_same::value, Tgt>::type @@ -1494,48 +1443,6 @@ to(const Src & value) { return static_cast(to::type>(value)); } -#else - -template -typename std::enable_if< - std::is_enum::value && !std::is_same::value, Tgt>::type -to(const Src & value) { - /* static */ if (Src(-1) < 0) { - /* static */ if (sizeof(Src) <= sizeof(int)) { - return to(static_cast(value)); - } else { - return to(static_cast(value)); - } - } else { - /* static */ if (sizeof(Src) <= sizeof(int)) { - return to(static_cast(value)); - } else { - return to(static_cast(value)); - } - } -} - -template -typename std::enable_if< - std::is_enum::value && !std::is_same::value, Tgt>::type -to(const Src & value) { - /* static */ if (Tgt(-1) < 0) { - /* static */ if (sizeof(Tgt) <= sizeof(int)) { - return static_cast(to(value)); - } else { - return static_cast(to(value)); - } - } else { - /* static */ if (sizeof(Tgt) <= sizeof(int)) { - return static_cast(to(value)); - } else { - return static_cast(to(value)); - } - } -} - -#endif // gcc 4.7 onwards - } // namespace folly // FOLLY_CONV_INTERNAL is defined by Conv.cpp. Keep the FOLLY_RANGE_CHECK diff --git a/folly/test/ConvTest.cpp b/folly/test/ConvTest.cpp index bf4c68dd..189c96bd 100644 --- a/folly/test/ConvTest.cpp +++ b/folly/test/ConvTest.cpp @@ -699,9 +699,6 @@ TEST(Conv, UnsignedEnum) { } } -#if defined(__clang__) || __GNUC_PREREQ(4, 7) -// to and to(enum class) only supported in gcc 4.7 onwards - TEST(Conv, UnsignedEnumClass) { enum class E : uint32_t { x = 3000000000U }; auto u = to(E::x); @@ -728,8 +725,6 @@ TEST(Conv, EnumClassToString) { EXPECT_EQ("foo.65", to("foo.", A::z)); } -#endif // gcc 4.7 onwards - template void testStr2Bool() { EXPECT_FALSE(to(Src("0"))); -- 2.34.1