diff --git a/folly/Traits.h b/folly/Traits.h index 9bd8c2769e9..9e89105feef 100644 --- a/folly/Traits.h +++ b/folly/Traits.h @@ -456,10 +456,9 @@ template struct IsRelocatable : std::conditional< traits_detail::has_IsRelocatable::value, traits_detail::has_true_IsRelocatable, - // TODO add this line (and some tests for it) when we - // upgrade to gcc 4.7 - // std::is_trivially_move_constructible::value || - is_trivially_copyable>::type {}; + bool_constant< + std::is_trivially_move_constructible::value || + is_trivially_copyable::value>>::type {}; template struct IsZeroInitializable diff --git a/folly/test/TraitsTest.cpp b/folly/test/TraitsTest.cpp index a31d9b27c6e..b91b8f9adb2 100644 --- a/folly/test/TraitsTest.cpp +++ b/folly/test/TraitsTest.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -98,6 +99,21 @@ TEST(Traits, unset) { EXPECT_TRUE(IsRelocatable::value); } +TEST(Traits, triviallyMoveConstructible) { + FOLLY_PUSH_WARNING + FOLLY_CLANG_DISABLE_WARNING("-Wunneeded-member-function") + struct TriviallyMoveConstructible { + TriviallyMoveConstructible(const TriviallyMoveConstructible&) = delete; + TriviallyMoveConstructible& operator=(const TriviallyMoveConstructible&) = + delete; + TriviallyMoveConstructible(TriviallyMoveConstructible&&) = default; + TriviallyMoveConstructible& operator=(TriviallyMoveConstructible&&) = + delete; + }; + EXPECT_TRUE(IsRelocatable::value); + FOLLY_POP_WARNING +} + TEST(Traits, bitAndInit) { EXPECT_TRUE(IsZeroInitializable::value); EXPECT_FALSE(IsZeroInitializable>::value);