@ -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_FALS E (
( absl : : is_trivially_copy_assignable < std : : pair < int , char * > > : : value ) ) ;
// Verify that simple_pair is trivially assignable
EXPECT_TRU E (
( 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 ] ;