![]() |
Home | Libraries | People | FAQ | More |
boost::container::uses_allocator
// In header: <boost/container/uses_allocator.hpp> template<typename T, typename AllocArg> struct uses_allocator { };
Remark: Automatically detects whether T has a nested allocator_type that is convertible from AllocArg. Meets the BinaryTypeTrait requirements ([meta.rqmts] 20.4.1). This trait is used to signal if type T supports uses-allocator construction.
uses-allocator construction protocol specifies three conventions of passing an allocator argument alloc_arg of type AllocArg to a constructor of some type T in addition to an arbitrary number of arguments (specified as args... in this explanation):
If T does not use a compatible allocator (uses_allocator<T, AllocArg>::value is false), then alloc_arg is ignored and T is constructed as T(args...)
Otherwise, if uses_allocator<T, AllocArg>::value is true and T is constructible as T(std::allocator_arg, alloc_arg, args...) then uses-allocator construction uses this form.
Otherwise, if T is constructible as T(args..., alloc_arg), then uses-allocator construction uses this form.
Otherwise, as an non-standard extension provided by Boost.Container, alloc_arg is ignored and T(args...) is called. (Note that this extension is provided to enhance backwards compatibility for types created without uses-allocator construction in mind that declare an allocator_type type but are not prepared to be built with an additional allocator argument)
Result: uses_allocator<T, AllocArg>::value == true if a type T::allocator_type exists and either is_convertible<AllocArg, T::allocator_type>::value == true or T::allocator_type is an alias of erased_type. False otherwise.
Note: A program may specialize this type to define uses_allocator<X>::value as true for a T of user-defined type if T does not have a nested allocator_type but is nonetheless constructible using the specified AllocArg where either: the first argument of a constructor has type allocator_arg_t and the second argument has type AllocArg or the last argument of a constructor has type AllocArg.