]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | ////////////////////////////////////////////////////////////////////////////// |
2 | // | |
3 | // (C) Copyright Ion Gaztanaga 2017-2017. Distributed under the Boost | |
4 | // Software License, Version 1.0. (See accompanying file | |
5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 | // | |
7 | // See http://www.boost.org/libs/container for documentation. | |
8 | // | |
9 | ////////////////////////////////////////////////////////////////////////////// | |
10 | #ifndef BOOST_CONTAINER_DETAIL_CONTAINER_REBIND_HPP | |
11 | #define BOOST_CONTAINER_DETAIL_CONTAINER_REBIND_HPP | |
12 | ||
13 | #ifndef BOOST_CONFIG_HPP | |
14 | # include <boost/config.hpp> | |
15 | #endif | |
16 | ||
17 | #if defined(BOOST_HAS_PRAGMA_ONCE) | |
18 | # pragma once | |
19 | #endif | |
20 | ||
21 | #include <boost/container/allocator_traits.hpp> | |
92f5a8d4 | 22 | #include <boost/container/container_fwd.hpp> |
b32b8144 FG |
23 | |
24 | ||
25 | namespace boost { | |
26 | namespace container { | |
11fdf7f2 | 27 | namespace dtl { |
b32b8144 FG |
28 | |
29 | template <class Cont, class U> | |
30 | struct container_rebind; | |
31 | ||
32 | #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
33 | ||
34 | template <template <class, class, class...> class Cont, typename V, typename A, class... An, class U> | |
35 | struct container_rebind<Cont<V, A, An...>, U> | |
36 | { | |
92f5a8d4 | 37 | typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, An...> type; |
b32b8144 FG |
38 | }; |
39 | ||
40 | //Needed for non-conforming compilers like GCC 4.3 | |
41 | template <template <class, class> class Cont, typename V, typename A, class U> | |
42 | struct container_rebind<Cont<V, A>, U> | |
43 | { | |
92f5a8d4 | 44 | typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type> type; |
b32b8144 FG |
45 | }; |
46 | ||
47 | template <template <class> class Cont, typename V, class U> | |
48 | struct container_rebind<Cont<V>, U> | |
49 | { | |
50 | typedef Cont<U> type; | |
51 | }; | |
52 | ||
b32b8144 FG |
53 | #else //C++03 compilers |
54 | ||
55 | template <template <class> class Cont //0arg | |
56 | , typename V | |
57 | , class U> | |
58 | struct container_rebind<Cont<V>, U> | |
59 | { | |
60 | typedef Cont<U> type; | |
61 | }; | |
62 | ||
63 | template <template <class, class> class Cont //0arg | |
64 | , typename V, typename A | |
65 | , class U> | |
66 | struct container_rebind<Cont<V, A>, U> | |
67 | { | |
92f5a8d4 | 68 | typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type> type; |
b32b8144 FG |
69 | }; |
70 | ||
71 | template <template <class, class, class> class Cont //1arg | |
72 | , typename V, typename A, class P0 | |
73 | , class U> | |
74 | struct container_rebind<Cont<V, A, P0>, U> | |
75 | { | |
92f5a8d4 | 76 | typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0> type; |
b32b8144 FG |
77 | }; |
78 | ||
79 | template <template <class, class, class, class> class Cont //2arg | |
80 | , typename V, typename A, class P0, class P1 | |
81 | , class U> | |
82 | struct container_rebind<Cont<V, A, P0, P1>, U> | |
83 | { | |
92f5a8d4 | 84 | typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1> type; |
b32b8144 FG |
85 | }; |
86 | ||
87 | template <template <class, class, class, class, class> class Cont //3arg | |
88 | , typename V, typename A, class P0, class P1, class P2 | |
89 | , class U> | |
90 | struct container_rebind<Cont<V, A, P0, P1, P2>, U> | |
91 | { | |
92f5a8d4 | 92 | typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1, P2> type; |
b32b8144 FG |
93 | }; |
94 | ||
95 | template <template <class, class, class, class, class, class> class Cont //4arg | |
96 | , typename V, typename A, class P0, class P1, class P2, class P3 | |
97 | , class U> | |
98 | struct container_rebind<Cont<V, A, P0, P1, P2, P3>, U> | |
99 | { | |
92f5a8d4 | 100 | typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1, P2, P3> type; |
b32b8144 FG |
101 | }; |
102 | ||
103 | template <template <class, class, class, class, class, class, class> class Cont //5arg | |
104 | , typename V, typename A, class P0, class P1, class P2, class P3, class P4 | |
105 | , class U> | |
106 | struct container_rebind<Cont<V, A, P0, P1, P2, P3, P4>, U> | |
107 | { | |
92f5a8d4 | 108 | typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1, P2, P3, P4> type; |
b32b8144 FG |
109 | }; |
110 | ||
111 | template <template <class, class, class, class, class, class, class, class> class Cont //6arg | |
112 | , typename V, typename A, class P0, class P1, class P2, class P3, class P4, class P5 | |
113 | , class U> | |
114 | struct container_rebind<Cont<V, A, P0, P1, P2, P3, P4, P5>, U> | |
115 | { | |
92f5a8d4 | 116 | typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1, P2, P3, P4, P5> type; |
b32b8144 FG |
117 | }; |
118 | ||
119 | template <template <class, class, class, class, class, class, class, class, class> class Cont //7arg | |
120 | , typename V, typename A, class P0, class P1, class P2, class P3, class P4, class P5, class P6 | |
121 | , class U> | |
122 | struct container_rebind<Cont<V, A, P0, P1, P2, P3, P4, P5, P6>, U> | |
123 | { | |
92f5a8d4 | 124 | typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1, P2, P3, P4, P5, P6> type; |
b32b8144 FG |
125 | }; |
126 | ||
127 | template <template <class, class, class, class, class, class, class, class, class, class> class Cont //8arg | |
128 | , typename V, typename A, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7 | |
129 | , class U> | |
130 | struct container_rebind<Cont<V, A, P0, P1, P2, P3, P4, P5, P6, P7>, U> | |
131 | { | |
92f5a8d4 | 132 | typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1, P2, P3, P4, P5, P6, P7> type; |
b32b8144 FG |
133 | }; |
134 | ||
135 | template <template <class, class, class, class, class, class, class, class, class, class, class> class Cont //9arg | |
136 | , typename V, typename A, class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8 | |
137 | , class U> | |
138 | struct container_rebind<Cont<V, A, P0, P1, P2, P3, P4, P5, P6, P7, P8>, U> | |
139 | { | |
92f5a8d4 | 140 | typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1, P2, P3, P4, P5, P6, P7, P8> type; |
b32b8144 FG |
141 | }; |
142 | ||
92f5a8d4 | 143 | #endif //!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) |
b32b8144 | 144 | |
92f5a8d4 | 145 | //for small_vector,static_vector |
b32b8144 | 146 | |
20effc67 TL |
147 | template <typename V, std::size_t N, typename A, typename O, class U> |
148 | struct container_rebind<small_vector<V, N, A, O>, U> | |
b32b8144 | 149 | { |
20effc67 | 150 | typedef small_vector<U, N, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, O> type; |
b32b8144 FG |
151 | }; |
152 | ||
92f5a8d4 TL |
153 | template <typename V, std::size_t N, typename O, class U> |
154 | struct container_rebind<static_vector<V, N, O>, U> | |
b32b8144 | 155 | { |
92f5a8d4 | 156 | typedef static_vector<U, N, O> type; |
b32b8144 FG |
157 | }; |
158 | ||
11fdf7f2 | 159 | } //namespace dtl { |
b32b8144 FG |
160 | } //namespace container { |
161 | } //namespace boost { | |
162 | ||
163 | #endif //#ifndef BOOST_CONTAINER_DETAIL_CONTAINER_REBIND_HPP |