Namespaces
Variants
Views
Actions

std::uses_allocator

From cppreference.com
< cpp‎ | memory
Revision as of 10:13, 1 February 2017 by 196.217.66.247 (Talk)

 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
Dynamic memory management
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Allocators
uses_allocator
(C++11)
Garbage collection support
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)



 
Defined in header <memory>
template< class T, class Alloc > struct uses_allocator;
(since C++11)

If T has a member typedef allocator_type which is convertible from Alloc or is an alias of std::experimental::erased_type(library fundamentals TS), the member constant value is true. Otherwise value is false.

Contents

Helper variable template

template< class T, class Alloc >
constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value;
(since C++17)

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>

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.

In the above, Alloc is a type that satisfies Template:concept or is a pointer type convertible to std::experimental::pmr::memory_resource*(library fundamentals TS).

The following specializations are already provided by the standard library:

Template:cpp/utility/variant/dsc uses allocator
specializes the std::uses_allocator type trait
(class template specialization) [edit]
specializes the std::uses_allocator type trait
(class template specialization) [edit]
specializes the std::uses_allocator type trait
(class template specialization) [edit]
specializes the std::uses_allocator type trait
(class template specialization) [edit]
specializes the std::uses_allocator type trait
(class template specialization) [edit]
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 std::tuple. It may also be used by custom allocators or wrapper types to determine whether the object or member 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

a tag used to select allocator-aware constructors
(tag)[edit]
tag type used to select allocator-aware constructor overloads
(class) [edit]
implements multi-level allocator for multi-level containers
(class template) [edit]