Namespaces
Variants
Views
Actions

std::uses_allocator<std::tuple>

From cppreference.com
< cpp‎ | utility‎ | tuple
Revision as of 11:50, 2 November 2012 by P12bot (Talk | contribs)

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

<td>
Defined in header <tuple>
</td>

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

<tr class="t-dcl ">

<td >
template< class... Types, class Alloc >
struct uses_allocator< std::tuple<Types...>, Alloc > : std::true_type { };
</td>

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

This specialization of std::uses_allocator informs other library components that tuples support uses-allocator construction, even though they do not have a nested allocator_type.

Contents

Inherited from std::integral_constant

Member constants

value
[static]
true
(public static member constant)

Member functions

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

Member types

Type Definition
value_type bool
type std::integral_constant<bool, value>

Example

// myalloc is a stateful Allocator with a single-argument constructor
// that takes an int. It has no default constructor.
 
    typedef std::vector<int, myalloc<int>> innervector_t;
    typedef std::tuple<int, innervector_t> elem_t;
    typedef std::scoped_allocator_adaptor< myalloc<elem_t>, myalloc<int>> Alloc;
    Alloc a(1,2);
    std::vector<elem_t, Alloc> v(a);
    v.resize(1);                  // uses allocator #1 for elements of v
    std::get<1>(v[0]).resize(10); // uses allocator #2 for innervector_t


See also

Template:cpp/memory/dcl list uses allocator