diff options
author | Abseil Team <absl-team@google.com> | 2017-12-06 10:36:04 -0800 |
---|---|---|
committer | Alex Strelnikov <strel@google.com> | 2017-12-07 09:51:37 -0500 |
commit | bff94231504bc7456b4aa99b27e22bf239cff47d (patch) | |
tree | e3738b5057194532a29f0808e7215cce04a6a1b0 /absl/meta | |
parent | 1b8dacca622ad547b08bccf523529ef09e2d581f (diff) |
Changes imported from Abseil "staging" branch:
- 221bfcc1d2583d8bdf1f3745fa0496f92338d38a Update type_traits_test to avoid depending on triviality ... by Matt Calabrese <calabrese@google.com>
GitOrigin-RevId: 221bfcc1d2583d8bdf1f3745fa0496f92338d38a
Change-Id: I7db0f32479673d21b6976f43baaf3c18f0b73e47
Diffstat (limited to 'absl/meta')
-rw-r--r-- | absl/meta/type_traits_test.cc | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/absl/meta/type_traits_test.cc b/absl/meta/type_traits_test.cc index 15e1c28b..f0e341f5 100644 --- a/absl/meta/type_traits_test.cc +++ b/absl/meta/type_traits_test.cc @@ -26,6 +26,12 @@ namespace { using ::testing::StaticAssertTypeEq; +template <class T, class U> +struct simple_pair { + T first; + U second; +}; + struct Dummy {}; TEST(VoidTTest, BasicUsage) { @@ -205,9 +211,9 @@ TEST(TypeTraitsTest, TestTrivialDefaultCtor) { EXPECT_TRUE( absl::is_trivially_default_constructible<TrivialDefaultCtor10>::value); - // Verify that std::pair has non-trivial constructors. - EXPECT_FALSE( - (absl::is_trivially_default_constructible<std::pair<int, char*>>::value)); + // Verify that simple_pair has trivial constructors where applicable. + EXPECT_TRUE((absl::is_trivially_default_constructible< + simple_pair<int, char*>>::value)); // Verify that types without trivial constructors are // correctly marked as such. @@ -254,11 +260,11 @@ TEST(TypeTraitsTest, TestTrivialCopyCtor) { // Verify that std pair of such types is trivially copy constructible EXPECT_TRUE( - (absl::is_trivially_copy_constructible<std::pair<int, char*>>::value)); - EXPECT_TRUE( - (absl::is_trivially_copy_constructible<std::pair<int, Trivial>>::value)); + (absl::is_trivially_copy_constructible<simple_pair<int, char*>>::value)); + EXPECT_TRUE(( + absl::is_trivially_copy_constructible<simple_pair<int, Trivial>>::value)); EXPECT_TRUE((absl::is_trivially_copy_constructible< - std::pair<int, TrivialCopyCtor>>::value)); + simple_pair<int, TrivialCopyCtor>>::value)); // Verify that arrays are not typedef int int10[10]; @@ -267,9 +273,9 @@ TEST(TypeTraitsTest, TestTrivialCopyCtor) { // Verify that pairs of types without trivial copy constructors // are not marked as trivial. EXPECT_FALSE((absl::is_trivially_copy_constructible< - std::pair<int, std::string>>::value)); + simple_pair<int, std::string>>::value)); EXPECT_FALSE((absl::is_trivially_copy_constructible< - std::pair<std::string, int>>::value)); + simple_pair<std::string, int>>::value)); // Verify that types without trivial copy constructors are // correctly marked as such. @@ -317,9 +323,9 @@ TEST(TypeTraitsTest, TestTrivialCopyAssign) { typedef int int10[10]; EXPECT_FALSE(absl::is_trivially_copy_assignable<int10>::value); - // Verify that std::pair is not trivially assignable - EXPECT_FALSE( - (absl::is_trivially_copy_assignable<std::pair<int, char*>>::value)); + // Verify that simple_pair is trivially assignable + EXPECT_TRUE( + (absl::is_trivially_copy_assignable<simple_pair<int, char*>>::value)); // Verify that types without trivial copy constructors are // correctly marked as such. @@ -357,10 +363,10 @@ TEST(TypeTraitsTest, TestTrivialDestructor) { EXPECT_TRUE(absl::is_trivially_destructible<TrivialDestructor>::value); EXPECT_FALSE(absl::is_trivially_destructible<NonTrivialDestructor>::value); - // std::pair of such types is trivial - EXPECT_TRUE((absl::is_trivially_destructible<std::pair<int, int>>::value)); + // simple_pair of such types is trivial + EXPECT_TRUE((absl::is_trivially_destructible<simple_pair<int, int>>::value)); EXPECT_TRUE((absl::is_trivially_destructible< - std::pair<Trivial, TrivialDestructor>>::value)); + simple_pair<Trivial, TrivialDestructor>>::value)); // array of such types is trivial typedef int int10[10]; |