| 1 |
/* Copyright (C) 2015 Povilas Kanapickas <[email protected]> |
| 2 |
|
| 3 |
This file is part of cppreference-doc |
| 4 |
|
| 5 |
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 |
| 6 |
Unported License. To view a copy of this license, visit |
| 7 |
http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative |
| 8 |
Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. |
| 9 |
|
| 10 |
Permission is granted to copy, distribute and/or modify this document |
| 11 |
under the terms of the GNU Free Documentation License, Version 1.3 or |
| 12 |
any later version published by the Free Software Foundation; with no |
| 13 |
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. |
| 14 |
*/ |
| 15 |
|
| 16 |
#ifndef CPPREFERENCE_SCOPED_ALLOCATOR_H |
| 17 |
#define CPPREFERENCE_SCOPED_ALLOCATOR_H |
| 18 |
|
| 19 |
#if CPPREFERENCE_STDVER>= 2011 |
| 20 |
|
| 21 |
namespace std { |
| 22 |
|
| 23 |
template<class OuterAlloc, class... InnerAlloc> |
| 24 |
class scoped_allocator_adaptor : public OuterAlloc { |
| 25 |
public: |
| 26 |
typedef OuterAlloc outer_allocator_type; |
| 27 |
typedef scoped_allocator_adaptor<OuterAlloc> inner_allocator_type; // SIMPLIFIED |
| 28 |
|
| 29 |
#if CPPREFERENCE_SIMPLIFY_TYPEDEFS |
| 30 |
typedef typename OuterAlloc::value_type value_type; |
| 31 |
typedef typename OuterAlloc::size_type size_type; |
| 32 |
typedef typename OuterAlloc::difference_type difference_type; |
| 33 |
typedef typename OuterAlloc::pointer pointer; |
| 34 |
typedef typename OuterAlloc::const_pointer const_pointer; |
| 35 |
typedef typename OuterAlloc::void_pointer void_pointer; |
| 36 |
typedef typename OuterAlloc::const_void_pointer const_void_pointer; |
| 37 |
#else |
| 38 |
typedef typename allocator_traits<OuterAlloc>::value_type value_type; |
| 39 |
typedef typename allocator_traits<OuterAlloc>::size_type size_type; |
| 40 |
typedef typename allocator_traits<OuterAlloc>::difference_type difference_type; |
| 41 |
typedef typename allocator_traits<OuterAlloc>::pointer pointer; |
| 42 |
typedef typename allocator_traits<OuterAlloc>::const_pointer const_pointer; |
| 43 |
typedef typename allocator_traits<OuterAlloc>::void_pointer void_pointer; |
| 44 |
typedef typename allocator_traits<OuterAlloc>::const_void_pointer const_void_pointer; |
| 45 |
#endif |
| 46 |
|
| 47 |
// SIMPLIFIED: depends on InnerAlloc... and OuterAlloc |
| 48 |
typedef std::true_type propagate_on_container_copy_assignment; |
| 49 |
typedef std::true_type propagate_on_container_move_assignment; |
| 50 |
typedef std::true_type propagate_on_container_swap; |
| 51 |
#if CPPREFERENCE_STDVER>= 2017 |
| 52 |
typedef std::true_type is_always_equal; |
| 53 |
#endif |
| 54 |
|
| 55 |
template<class T> |
| 56 |
struct rebind { |
| 57 |
typedef OuterAlloc other; // SIMPLIFIED |
| 58 |
}; |
| 59 |
|
| 60 |
scoped_allocator_adaptor(); |
| 61 |
|
| 62 |
template<class OuterA2> |
| 63 |
scoped_allocator_adaptor(OuterA2&& outerAlloc, const InnerAllocs& ... innerAllocs); |
| 64 |
|
| 65 |
scoped_allocator_adaptor(const scoped_allocator_adaptor& other); |
| 66 |
|
| 67 |
scoped_allocator_adaptor(scoped_allocator_adaptor&& other); |
| 68 |
|
| 69 |
template<class OuterA2> |
| 70 |
scoped_allocator_adaptor(const scoped_allocator_adaptor<OuterA2, InnerAllocs...>& other); |
| 71 |
|
| 72 |
template<class OuterA2> |
| 73 |
scoped_allocator_adaptor(scoped_allocator_adaptor<OuterA2, InnerAllocs...>&& other); |
| 74 |
|
| 75 |
~scoped_allocator_adaptor(); |
| 76 |
|
| 77 |
inner_allocator_type& inner_allocator(); |
| 78 |
const inner_allocator_type& inner_allocator() const; |
| 79 |
|
| 80 |
outer_allocator_type& outer_allocator(); |
| 81 |
const outer_allocator_type& outer_allocator() const; |
| 82 |
|
| 83 |
pointer allocate(size_type n); |
| 84 |
pointer allocate(size_type n, const_void_pointer hint); |
| 85 |
|
| 86 |
void deallocate(pointer p, size_type n); |
| 87 |
|
| 88 |
size_type max_size() const; |
| 89 |
|
| 90 |
template <class T, class... Args> |
| 91 |
void construct(T* p, Args&& ... args); |
| 92 |
|
| 93 |
template<class T1, class T2, class... Args1, class... Args2> |
| 94 |
void construct(std::pair<T1, T2>* p, |
| 95 |
std::piecewise_construct_t, |
| 96 |
std::tuple<Args1...> x, |
| 97 |
std::tuple<Args2...> y); |
| 98 |
|
| 99 |
template<class T1, class T2> |
| 100 |
void construct(std::pair<T1, T2>* p); |
| 101 |
|
| 102 |
template<class T1, class T2, class U, class V> |
| 103 |
void construct(std::pair<T1, T2>* p, U&& x, V&& y); |
| 104 |
|
| 105 |
template<class T1, class T2, class U, class V> |
| 106 |
void construct(std::pair<T1, T2>* p, const std::pair<U, V>& xy); |
| 107 |
|
| 108 |
template<class T1, class T2, class U, class V> |
| 109 |
void construct(std::pair<T1, T2>* p, std::pair<U, V>&& xy); |
| 110 |
|
| 111 |
template<class T> |
| 112 |
void destroy(T* p); |
| 113 |
|
| 114 |
scoped_allocator_adaptor select_on_container_copy_construction() const; |
| 115 |
|
| 116 |
}; |
| 117 |
|
| 118 |
template<class OuterAlloc1, class OuterAlloc2, class... InnerAllocs> |
| 119 |
bool operator==(const scoped_allocator_adaptor<OuterAlloc1, InnerAllocs...>& lhs, |
| 120 |
const scoped_allocator_adaptor<OuterAlloc2, InnerAllocs...>& rhs); |
| 121 |
|
| 122 |
template<class OuterAlloc1, class OuterAlloc2, class... InnerAllocs> |
| 123 |
bool operator!=(const scoped_allocator_adaptor<OuterAlloc1, InnerAllocs...>& lhs, |
| 124 |
const scoped_allocator_adaptor<OuterAlloc2, InnerAllocs...>& rhs); |
| 125 |
|
| 126 |
} // namespace std |
| 127 |
|
| 128 |
#endif // CPPREFERENCE_STDVER>= 2011 |
| 129 |
|
| 130 |
#endif // CPPREFERENCE_SCOPED_ALLOCATOR_H |