text
stringlengths
0
2.2M
// ==========================
// class CopyOnlyBaseTestType
// ==========================
template <class T>
class CopyOnlyBaseTestType {
// This class, that does not support move constructors, provides a
// mechanism (static variables) to establish exactly which copy or move
// constructor is called.
public:
// PUBLIC CLASS DATA
static int s_copyConstructorInvocations;
static int s_moveConstructorInvocations;
static int s_copyAllocConstructorInvocations;
static int s_moveAllocConstructorInvocations;
static int s_copyArgTConstructorInvocations;
static int s_moveArgTConstructorInvocations;
// DATA
my_ClassDef d_def; // object's value
// CREATORS
explicit CopyOnlyBaseTestType(bslma::Allocator *alloc = 0)
// Create an object having the null value and optionally specified
// 'alloc'.
{
d_def.d_value = 0;
d_def.d_allocator_p = alloc;
}
CopyOnlyBaseTestType(int value, bslma::Allocator *alloc = 0) // IMPLICIT
// Create an object that has the specified 'value' and that uses the
// optionally specified 'alloc' to supply memory.
{
d_def.d_value = value;
d_def.d_allocator_p = alloc;
}
CopyOnlyBaseTestType(const CopyOnlyBaseTestType& original)
// Create an object having the value of the specified 'original'
// object.
{
++s_copyConstructorInvocations;
d_def.d_value = original.d_def.d_value;
d_def.d_allocator_p = 0;
}
CopyOnlyBaseTestType(const CopyOnlyBaseTestType& original,
bslma::Allocator *alloc)
// Create an object that has the value of the specified 'original'
// object and that uses the specified 'alloc' to supply memory.
{
++s_copyAllocConstructorInvocations;
d_def.d_value = original.d_def.d_value;
d_def.d_allocator_p = alloc;
}
CopyOnlyBaseTestType(bsl::allocator_arg_t ,
bslma::Allocator *alloc,
const CopyOnlyBaseTestType& original)
// Following the 'allocator_arg_t' construction protocol create an
// object having the same value as the specified 'original' object that
// uses the specified 'alloc' to supply memory.
{
++s_copyArgTConstructorInvocations;
d_def.d_value = original.d_def.d_value;
d_def.d_allocator_p = alloc;
}
// ACCESSORS
int value() const
// Return the value of this object.
{
return d_def.d_value;
}
bslma::Allocator *allocator() const
// Return the allocator used by this object to supply memory.
{
return d_def.d_allocator_p;
}
};
// CLASS DATA
template <class T>
int CopyOnlyBaseTestType<T>::s_copyConstructorInvocations = 0;
template <class T>
int CopyOnlyBaseTestType<T>::s_moveConstructorInvocations = 0;
template <class T>
int CopyOnlyBaseTestType<T>::s_copyAllocConstructorInvocations = 0;
template <class T>
int CopyOnlyBaseTestType<T>::s_moveAllocConstructorInvocations = 0;
template <class T>
int CopyOnlyBaseTestType<T>::s_copyArgTConstructorInvocations = 0;
template <class T>
int CopyOnlyBaseTestType<T>::s_moveArgTConstructorInvocations = 0;
// =============================