text
stringlengths
0
2.2M
// Create an object having the same value as the specified
// 'original' object by moving the contents of 'original' to the
// newly-created object.
{
++s_moveConstructorInvocations;
BaseTestType& lvalue = original;
d_def.d_value = lvalue.d_def.d_value;
d_def.d_allocator_p = 0;
}
BaseTestType(bslmf::MovableRef<BaseTestType> original,
bslma::Allocator *alloc)
// Create an object having the same value as the specified 'original'
// object that uses the specified 'alloc' to supply memory by moving
// the contents of 'original' to the newly-created object.
{
++s_moveAllocConstructorInvocations;
BaseTestType& lvalue = original;
d_def.d_value = lvalue.d_def.d_value;
d_def.d_allocator_p = alloc;
}
BaseTestType(bsl::allocator_arg_t ,
bslma::Allocator *alloc,
bslmf::MovableRef<BaseTestType> 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 by moving the contents
// of 'original' to the newly-created object.
{
++s_moveArgTConstructorInvocations;
BaseTestType& lvalue = original;
d_def.d_value = lvalue.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 BaseTestType<T>::s_copyConstructorInvocations = 0;
template <class T>
int BaseTestType<T>::s_moveConstructorInvocations = 0;
template <class T>
int BaseTestType<T>::s_copyAllocConstructorInvocations = 0;
template <class T>
int BaseTestType<T>::s_moveAllocConstructorInvocations = 0;
template <class T>
int BaseTestType<T>::s_copyArgTConstructorInvocations = 0;
template <class T>
int BaseTestType<T>::s_moveArgTConstructorInvocations = 0;
// =====================
// class TrivialTestType
// =====================
typedef BaseTestType<TRIVIAL> TrivialTestType;
// ========================
// class NonTrivialTestType
// ========================
typedef BaseTestType<NON_TRIVIAL> NonTrivialTestType;
// ========================
// class BslmaAllocTestType
// ========================
typedef BaseTestType<BSLMA_ALLOC> BslmaAllocTestType;
// =======================
// class ArgTAllocTestType
// =======================
typedef BaseTestType<ARG_T_ALLOC> ArgTAllocTestType;
// TRAITS
namespace bsl {
template <>
struct is_trivially_copyable< TrivialTestType > : true_type {};
template <>
struct is_trivially_copyable< NonTrivialTestType > : false_type {};
template <>
struct is_trivially_copyable< BslmaAllocTestType > : false_type {};