text
stringlengths 0
2.2M
|
---|
// struct is_trivially_copyable<MyTriviallyCopyableType> : bsl::true_type {
|
// // This template specialization for 'is_trivially_copyable' indicates
|
// // that 'MyTriviallyCopyableType' is a trivially copyable type.
|
// };
|
//
|
// } // close namespace bsl
|
//..
|
// Now, we verify whether each type is trivially copyable using
|
// 'bsl::is_trivially_copyable':
|
//..
|
ASSERT(true == bsl::is_trivially_copyable<MyFundamentalType>::value);
|
ASSERT(false == bsl::is_trivially_copyable<
|
MyFundamentalTypeReference>::value);
|
ASSERT(true == bsl::is_trivially_copyable<
|
MyTriviallyCopyableType>::value);
|
ASSERT(false == bsl::is_trivially_copyable<
|
MyNonTriviallyCopyableType>::value);
|
//..
|
// Note that if the current compiler supports the variable templates C++14
|
// feature, then we can re-write the snippet of code above as follows:
|
#ifdef BSLS_COMPILERFEATURES_SUPPORT_VARIABLE_TEMPLATES
|
ASSERT( bsl::is_trivially_copyable_v<MyFundamentalType>);
|
ASSERT(!bsl::is_trivially_copyable_v<MyFundamentalTypeReference>);
|
ASSERT( bsl::is_trivially_copyable_v<MyTriviallyCopyableType>);
|
ASSERT(!bsl::is_trivially_copyable_v<MyNonTriviallyCopyableType>);
|
#endif
|
//..
|
} break;
|
case 5: {
|
// --------------------------------------------------------------------
|
// TESTING: 'typedef struct {} X' ISSUE (AIX BUG, {DRQS 153975424})
|
// Ensure unnamed structs are handled correctly.
|
//
|
// Concerns:
|
//: 1 Ensure that named 'struct's and 'typedef'd anonymous 'struct's
|
// are handled identically.
|
//
|
// Plan:
|
//: 1 Verify 'bsl::is_trivially_copyable<StructWithCtor>' is 'false'.
|
//:
|
//: 2 Verify 'bsl::is_trivially_copyable<NSWNPM>' is 'false'.
|
//:
|
//: 3 Verify 'bsl::is_trivially_copyable<TSWNPM>' is 'false'.
|
//:
|
//: 4 Verify 'bsl::is_trivially_copyable<NSWPM>' is as expected.
|
//:
|
//: 5 Verify 'bsl::is_trivially_copyable<TSWPM>' is as expected (C-1).
|
//
|
// Testing:
|
// 'typedef struct {} X' ISSUE (AIX BUG, {DRQS 153975424})
|
//
|
// --------------------------------------------------------------------
|
if (verbose)
|
printf(
|
"\nTESTING: 'typedef struct {} X' ISSUE (AIX BUG, {DRQS "
|
"153975424})\n"
|
"\n====================================================="
|
"===========\n");
|
// P-1
|
ASSERTV(!bsl::is_trivially_copyable<StructWithCtor>::value,
|
!bsl::is_trivially_copyable<StructWithCtor>::value);
|
// P-2
|
ASSERTV(
|
!bsl::is_trivially_copyable<NamedStructWithNonPodMember>::value,
|
!bsl::is_trivially_copyable<NamedStructWithNonPodMember>::value);
|
// P-3
|
ASSERTV(!bsl::is_trivially_copyable<
|
TypedefedStructWithNonPodMember>::value,
|
!bsl::is_trivially_copyable<
|
TypedefedStructWithNonPodMember>::value);
|
// Native trait checks detect that POD types are trivially copyable,
|
// even without trait info. Our non-native trait check implementation
|
// has to be pessimistic and assume they are not.
|
#ifdef BSLMF_ISTRIVIALLYCOPYABLE_NATIVE_IMPLEMENTATION
|
bool expected_i_t_c_with_pod_member = true;
|
#else
|
bool expected_i_t_c_with_pod_member = false;
|
#endif
|
// P-4
|
ASSERTV(bsl::is_trivially_copyable<NamedStructWithPodMember>::value,
|
expected_i_t_c_with_pod_member,
|
bsl::is_trivially_copyable<NamedStructWithPodMember>::value ==
|
expected_i_t_c_with_pod_member);
|
// P-5
|
ASSERTV(
|
bsl::is_trivially_copyable<TypedefedStructWithPodMember>::value,
|
expected_i_t_c_with_pod_member,
|
bsl::is_trivially_copyable<TypedefedStructWithPodMember>::value ==
|
expected_i_t_c_with_pod_member);
|
} break;
|
case 4: {
|
// --------------------------------------------------------------------
|
// TESTING: 'bsl::is_trivially_copyable<bslmf::Nil>'
|
// Ensure that 'bsl::is_trivially_copyable' meta-function is
|
// specialized correctly for 'bsls::TimeInterval'.
|
//
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.