Documentation of memory

( foonathan/memory)

is_shared_allocator< RawAllocator > Struct Template Reference

Detailed Description

template<class RawAllocator>
struct foonathan::memory::is_shared_allocator< RawAllocator >

Specifies whether or not a RawAllocator has shared semantics.

It is shared, if - like allocator_reference - if multiple objects refer to the same internal allocator and if it can be copied. This sharing is stateful, however, stateless allocators are not considered shared in the meaning of this traits.
If a RawAllocator is shared, it will be directly embedded inside reference_storage since it already provides allocator_reference like semantics, so there is no need to add them manually,
Specialize it for your own types, if they provide sharing semantics and can be copied. They also must provide an operator== to check whether two allocators refer to the same shared one.

Note
This makes no guarantess about the lifetime of the shared object, the sharing allocators can either own or refer to a shared object.