• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>
22 #include <boost/container/container_fwd.hpp>
23 
24 
25 namespace boost {
26 namespace container {
27 namespace dtl {
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    {
37       typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, An...> type;
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    {
44       typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type> type;
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 
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    {
68       typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type> type;
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    {
76       typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0> type;
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    {
84       typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1> type;
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    {
92       typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1, P2> type;
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    {
100       typedef Cont<U, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, P0, P1, P2, P3> type;
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    {
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;
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    {
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;
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    {
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;
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    {
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;
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    {
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;
141    };
142 
143 #endif   //!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
144 
145    //for small_vector,static_vector
146 
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>
149    {
150       typedef small_vector<U, N, typename allocator_traits<typename real_allocator<V, A>::type>::template portable_rebind_alloc<U>::type, O> type;
151    };
152 
153    template <typename V, std::size_t N, typename O, class U>
154    struct container_rebind<static_vector<V, N, O>, U>
155    {
156       typedef static_vector<U, N, O> type;
157    };
158 
159 }  //namespace dtl {
160 }  //namespace container {
161 }  //namespace boost {
162 
163 #endif   //#ifndef BOOST_CONTAINER_DETAIL_CONTAINER_REBIND_HPP
164