text
stringlengths 0
2.2M
|
---|
// 'bsl::is_trivially_copyable::value'
|
// Ensure the 'bsl::is_trivially_copyable' meta-function
|
// returns the correct value for intrinsically supported types.
|
//
|
// Concerns:
|
//: 1 The meta-function returns 'true' for fundamental types.
|
//:
|
//: 2 The meta-function returns 'true' for enumerated types.
|
//:
|
//: 3 The meta-function returns 'true' for pointer to member types.
|
//:
|
//: 4 The meta-function returns 'false' for cv-qualified 'void' types.
|
//:
|
//: 5 The meta-function returns 'false' for function types.
|
//
|
//: 6 The meta-function returns 'true' for pointer types.
|
//:
|
//: 7 The meta-function returns 'false' for reference types.
|
//:
|
//: 8 The meta-function returns the same result for array types as it
|
//: would for the array's element type.
|
//:
|
//: 9 The meta-function returns the same result for cv-qualified
|
//: types that it would return 'true' for the corresponding
|
//: cv-unqualified type.
|
//:
|
//: 10 That 'is_trivially_copyable<T>::value' has the same value as
|
//: 'is_trivially_copyable_v<T>' for a variety of template parameter
|
//: types.
|
//
|
// Plan:
|
//: 1 Create a set of macros that will generate an 'ASSERT' test for
|
//: all variants of a type: (C6-9)
|
//: o reference and pointer types
|
//: o all cv-qualified combinations
|
//: o arrays, of fixed and runtime bounds, and multiple dimensions
|
//:
|
//: 2 For each category of type in concerns 1-5, use the appropriate
|
//: test macro for confirm the correct result for a representative
|
//: sample of types.
|
//
|
// Testing:
|
// bsl::is_trivially_copyable::value
|
// bsl::is_trivially_copyable_v
|
// --------------------------------------------------------------------
|
if (verbose)
|
printf("\n'bsl::is_trivially_copyable::value'"
|
"\n===================================\n");
|
// C-1, (partial 6, 7, 8, 9)
|
ASSERT_IS_TRIVIALLY_COPYABLE_OBJECT_TYPE(bool, true);
|
ASSERT_IS_TRIVIALLY_COPYABLE_OBJECT_TYPE(char, true);
|
ASSERT_IS_TRIVIALLY_COPYABLE_OBJECT_TYPE(int, true);
|
ASSERT_IS_TRIVIALLY_COPYABLE_OBJECT_TYPE(long double, true);
|
ASSERT_IS_TRIVIALLY_COPYABLE_OBJECT_TYPE(bsl::nullptr_t, true);
|
#if defined(BSLS_COMPILERFEATURES_SUPPORT_UNICODE_CHAR_TYPES)
|
ASSERT_IS_TRIVIALLY_COPYABLE_OBJECT_TYPE(char16_t, true);
|
#endif
|
// C-2 (partial 6, 7, 8, 9)
|
ASSERT_IS_TRIVIALLY_COPYABLE_OBJECT_TYPE(EnumTestType, true);
|
#if defined(BSLS_COMPILERFEATURES_SUPPORT_ENUM_CLASS)
|
ASSERT_IS_TRIVIALLY_COPYABLE_OBJECT_TYPE(EnumClassType, true);
|
#endif
|
// C-3 (complete 6, 7, 8, 9)
|
ASSERT_IS_TRIVIALLY_COPYABLE_OBJECT_TYPE(DataMemberPtrTestType, true);
|
ASSERT_IS_TRIVIALLY_COPYABLE_OBJECT_TYPE(MethodPtrTestType, true);
|
// C-4 : 'void' is not an object type, and although it can be
|
// cv-qualified, there are no references to 'void' so we must drop to
|
// the most primitive test macro:
|
ASSERT_IS_TRIVIALLY_COPYABLE(void, false);
|
ASSERT_IS_TRIVIALLY_COPYABLE(const void, false);
|
ASSERT_IS_TRIVIALLY_COPYABLE(volatile void, false);
|
ASSERT_IS_TRIVIALLY_COPYABLE(const volatile void, false);
|
// Pointers to void are perfectly good object types:
|
ASSERT_IS_TRIVIALLY_COPYABLE_OBJECT_TYPE(void*, true);
|
ASSERT_IS_TRIVIALLY_COPYABLE_OBJECT_TYPE(const void*, true);
|
ASSERT_IS_TRIVIALLY_COPYABLE_OBJECT_TYPE(volatile void*, true);
|
ASSERT_IS_TRIVIALLY_COPYABLE_OBJECT_TYPE(const volatile void*, true);
|
// C-5 : Function types are not object types, nor cv-qualifiable.
|
ASSERT_IS_TRIVIALLY_COPYABLE_TYPE(void(), false);
|
ASSERT_IS_TRIVIALLY_COPYABLE_TYPE(int(float,double...), false);
|
#ifndef BSLMF_ISTRIVIALLYCOPYABLE_NO_NESTED_FOR_ABOMINABLE_FUNCTIONS
|
ASSERT_IS_TRIVIALLY_COPYABLE(void() const, false);
|
ASSERT_IS_TRIVIALLY_COPYABLE(int(float,double...) const, false);
|
#endif
|
} break;
|
default: {
|
fprintf(stderr, "WARNING: CASE `%d' NOT FOUND.\n", test);
|
testStatus = -1;
|
}
|
}
|
if (testStatus > 0) {
|
fprintf(stderr, "Error, non-zero test status = %d.\n", testStatus);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.