BDE 4.14.0 Production release
|
Provide well-behaved move-only type using bslma
allocators.
This component provides a single, unconstrained (value-semantic) attribute class, WellBehavedMoveOnlyAllocTestType
, that uses a bslma::Allocator
to supply memory (defines the type trait bslma::UsesBslmaAllocator
) and provides only a move constructor and move assignment operator (disables copy constructor and copy assignment operator). Furthermore, this class is not bitwise-moveable, and will assert on destruction if it has been bitwise-moved. In addition, in the case of a move where source and destination objects use different allocators, the move acts like a copy and does not modify the source, or mark it as moved-from
, and does not mark the destination as moved-into
. This class is primarily provided to facilitate testing of templates by defining a simple type representative of user-defined types having an allocator that cannot be copied (only moved).
data
: representation of the object's valueThis section illustrates intended use of this component.
First, we observe that the type uses bslma::Allocator
s:
Then, we observe that the type is not copy-constructible:
Next, we observe that the type is not bitwise movable:
Then, we create an instance of our type with the value 5
:
Next, we move-construct another instance from the first:
Now, we observe the salient state of both objects:
And finally, the non-salient state: