Namespaces
Variants
Views
Actions

std::uses_allocator

From cppreference.com
< cpp‎ | memory
Revision as of 13:53, 2 November 2012 by P12bot (Talk | contribs)

 
 
 
 

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <memory>
</td>

<td></td> <td></td> <tr class="t-dcl ">

<td >
template< class T, class Alloc >
struct uses_allocator
</td>

<td class="t-dcl-nopad"> </td> <td > (since C++11) </td> </tr> Template:ddcl list end

If T has a member typedef allocator_type which is convertible from Alloc, provides the member constant value equal to true. Otherwise value is false.

Contents

Inherited from std::integral_constant

Member constants

value
[static]
true if T uses allocator Alloc, false otherwise
(public static member constant)

Member functions

operator bool
converts the object to bool, returns value
(public member function)
operator()
(C++14)
returns value
(public member function)

Member types

Type Definition
value_type bool
type std::integral_constant<bool, value>
[edit template]

Specializations

Custom specializations of the type trait std::uses_allocator are allowed for types that do not have the member typedef allocator_type but satisfy one of the following two requirements:

1) T has a constructor which takes std::allocator_arg_t as the first argument, and Alloc as the second argument.

2) T has a constructor which takes Alloc as the last argument.

The following specializations are already provided by the standard library:

Template:cpp/container/dcl list uses allocatorTemplate:cpp/container/dcl list uses allocatorTemplate:cpp/container/dcl list uses allocatorTemplate:cpp/thread/promise/dcl list uses allocatorTemplate:cpp/thread/packaged task/dcl list uses allocator
specializes the std::uses_allocator type trait
(class template specialization) [edit]
specializes the std::uses_allocator type trait
(class template specialization) [edit]

Notes

This type trait is used by std::scoped_allocator_adaptor and may be used by custom allocators to determine whether the object being constructed is itself capable of using an allocator (e.g. is a container), in which case an allocator should be passed to its constructor.

See also

Template:cpp/memory/dcl list allocator argTemplate:cpp/memory/dcl list allocator arg tTemplate:cpp/memory/dcl list scoped allocator adaptor