BDE 4.14.0 Production release
|
Provide a class for testing that allocates with standard allocator
This component provides a single, unconstrained (value-semantic) attribute class, StdAllocTestType
, that takes a standard allocator type as a template argument and uses an object of that type to allocate memory. Note that this class does NOT set the trait bslma::UsesBslmaAllocator
, but the trait will automatically be true
if ALLOC
is convertible from bslma::Allocator *
(e.g., if it is an instantiation of bsl::allocator
). Furthermore, this class is not bitwise-moveable, and will assert on destruction if it has been moved. This class is primarily provided to facilitate testing of templates by defining a simple type representative of user-defined types using a standard allocator.
data
: representation of the object's valueThis section illustrates intended use of this component.
Suppose we wanted to print the supported traits of this test type.
First, we create a function template printTypeTraits
with a parameterized TYPE
:
Next, we create an STL-style allocator:
Now, we invoke the printTypeTraits
function template using AllocTestType
as the parameterized TYPE
, using both bsl::allocator
and StlAllocator
as the ALLOC
parameter:
Finally, we observe the console output: