text
stringlengths
0
2.2M
int MCI = my_Class2a::s_moveConstructorInvocations;
my_Class2a dest = Util::make<my_Class2a>(TA, V2A);
ASSERTV(dest.value(), V2A.value() == dest.value());
ASSERT(TA == dest.allocator());
ASSERT(CCI == my_Class2a::s_copyConstructorInvocations -1);
ASSERT(MCI == my_Class2a::s_moveConstructorInvocations);
}
#endif // defined(BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION)
} break;
case 8: {
// ------------------------------------------------------------------
// TESTING 'make' WITH DEFAULT CONSTRUCTION
//
// Concerns:
//: 1 That 'make' with only an allocator argument will
//: default-construct a type that does not use allocators. The
//: allocator is ignored.
//:
//: 2 That 'make' with only a 'bslma::allocator' pointer argument
//: will pass that argument to the extended default constructor of
//: a type that uses the bslma allocator protocol.
//:
//: 3 That no unnecessary copies are created.
//
// Plan:
//: 1 Construct an object using 'make' method taking only an
//: allocator. Verify that the target object is default
//: constructed.
//:
//: 2 For concern 2, perform step 1 using a target type for which
//: 'UsesBslmaAllocator' is 'false'. Verify that the 'allocator'
//: is ignored.
//:
//: 3 For concern 3, perform step 1 using a target type for which
//: 'UsesBslmaAllocator' is 'true' and a target type for which
//: 'UsesAllocatorArgT' is 'true'. Using an 'allocator' which
//: is a pointer to a class derived from 'bslma::Allocator*',
//: check that the allocator is forwarded to the extended
//: constructor as described above.
//:
//: 4 For concern 4, perform steps 1-3 and verify that no unnecessary
//: copies of the target type are made.
//
// Testing:
// make<TYPE>(bslma::Allocator *a)
// make<TYPE>(void *a)
// ------------------------------------------------------------------
if (verbose) printf("\nTESTING 'make' WITH DEFAULT CONSTRUCTION"
"\n========================================\n");
#if defined(BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION)
bslma::TestAllocator testAllocator(veryVeryVeryVerbose);
bslma::TestAllocator *const TA = &testAllocator;
int dummyAllocator; // not a 'bslma' allocator
int *const XA = &dummyAllocator;
if (veryVerbose)
printf("Testing a non-AA type with a non-'bslma' allocator\n");
{
int CCI = my_Class1::s_copyConstructorInvocations;
int MCI = my_Class1::s_moveConstructorInvocations;
my_Class1 dest = Util::make<my_Class1>(XA);
ASSERTV(dest.value(), 0 == dest.value());
ASSERT(CCI == my_Class1::s_copyConstructorInvocations);
ASSERT(MCI == my_Class1::s_moveConstructorInvocations);
}
if (veryVerbose)
printf("Testing a non-AA type with a 'bslma' allocator\n");
{
int CCI = my_Class1::s_copyConstructorInvocations;
int MCI = my_Class1::s_moveConstructorInvocations;
my_Class1 dest = Util::make<my_Class1>(TA);
ASSERTV(dest.value(), 0 == dest.value());
ASSERT(CCI == my_Class1::s_copyConstructorInvocations);
ASSERT(MCI == my_Class1::s_moveConstructorInvocations);
}
if (veryVerbose) printf("Testing a 'UsesBslmaAllocator' type\n");
{
int CCI = my_Class2::s_copyConstructorInvocations;
int MCI = my_Class2::s_moveConstructorInvocations;
my_Class2 dest = Util::make<my_Class2>(TA);
ASSERTV(dest.value(), 0 == dest.value());
ASSERT(TA == dest.allocator());
ASSERT(CCI == my_Class2::s_copyConstructorInvocations);
ASSERT(MCI == my_Class2::s_moveConstructorInvocations);
}
if (veryVerbose) printf("Testing a 'UsesAllocatorArgT' type\n");
{
int CCI = my_Class2a::s_copyConstructorInvocations;
int MCI = my_Class2a::s_moveConstructorInvocations;
my_Class2a dest = Util::make<my_Class2a>(TA);
ASSERTV(dest.value(), 0 == dest.value());
ASSERT(TA == dest.allocator());
ASSERT(CCI == my_Class2a::s_copyConstructorInvocations);
ASSERT(MCI == my_Class2a::s_moveConstructorInvocations);
}
#endif // defined(BSLS_COMPILERFEATURES_GUARANTEED_COPY_ELISION)
} break;
case 7: {