![]() |
Home | Libraries | People | FAQ | More |
boost::container::pmr::polymorphic_allocator
// In header: <boost/container/pmr/polymorphic_allocator.hpp> template<typename T> class polymorphic_allocator { public: // types typedef ; // public member functions () ; (memory_resource *) ; (polymorphic_allocator &) ; template<typename U> (polymorphic_allocator< ) ; polymorphic_allocator & (polymorphic_allocator &) ; (); (, ) ; template<typename U, Args> (, ); template<typename U> (); polymorphic_allocator () ; memory_resource * () ; };
A specialization of class template polymorphic_allocator
conforms to the Allocator requirements. Constructed with different memory resources, different instances of the same specialization of polymorphic_allocator
can exhibit entirely different allocation behavior. This runtime polymorphism allows objects that use polymorphic_allocator to behave as if they used different allocator types at run time even though they use the same static allocator type.
polymorphic_allocator
public member functions() ;
Effects: Sets m_resource to get_default_resource()
.
(memory_resource * r) ;
Requires: r is non-null.
Effects: Sets m_resource to r.
Throws: Nothing
Notes: This constructor provides an implicit conversion from memory_resource*.
(polymorphic_allocator & other) ;
Effects: Sets m_resource to other.resource().
template<typename U> (polymorphic_allocator< other) ;
Effects: Sets m_resource to other.resource().
polymorphic_allocator & (polymorphic_allocator & other) ;
Effects: Sets m_resource to other.resource().
( n);
Returns: Equivalent to static_cast<T*>(m_resource->allocate(n * sizeof(T), alignof(T)))
.
( p, n) ;
Requires: p was allocated from a memory resource, x, equal to *m_resource, using x.allocate(n * sizeof(T), alignof(T))
.
Effects: Equivalent to m_resource->deallocate(p, n * sizeof(T), alignof(T)).
Throws: Nothing.
template<typename U, Args> ( p, args);
Requires: Uses-allocator construction of T with allocator *this
and constructor arguments std::forward<Args>(args)...
is well-formed. [Note: uses-allocator construction is always well formed for types that do not use allocators. - end note]
Effects: Construct a T object at p by uses-allocator construction with allocator *this
and constructor arguments std::forward<Args>(args)...
.
Throws: Nothing unless the constructor for T throws.
template<typename U> ( p);
Effects: p->~U().
polymorphic_allocator () ;
Returns: Equivalent to polymorphic_allocator()
.
memory_resource * () ;
Returns: m_resource.