Skip to content

Commit fe2ac80

Browse files
committed
Backport uses allocator logic for older compilers.
1 parent efebed9 commit fe2ac80

8 files changed

Lines changed: 108 additions & 6 deletions

File tree

include/boost/interprocess/allocators/adaptive_pool.hpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ class adaptive_pool_base
173173
segment_manager* get_segment_manager()const
174174
{ return node_pool<0>::get(ipcdetail::to_raw_pointer(mp_node_pool))->get_segment_manager(); }
175175

176+
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
176177
//! <b>Requires</b>: Uses-allocator construction of T with allocator
177178
//! `segment_manager*` and constructor arguments `std::forward<Args>(args)...`
178179
//! is well-formed. [Note: uses-allocator construction is always well formed for
@@ -191,6 +192,22 @@ class adaptive_pool_base
191192
(atd, this->get_segment_manager(), p, ::boost::forward<Args>(args)...);
192193
}
193194

195+
#else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
196+
197+
#define BOOST_CONTAINER_ALLOCATORS_ADAPTIVE_POOL_CONSTRUCT_CODE(N) \
198+
template < typename U BOOST_MOVE_I##N BOOST_MOVE_CLASSQ##N >\
199+
void construct(U* p BOOST_MOVE_I##N BOOST_MOVE_UREFQ##N)\
200+
{\
201+
boost::container::dtl::allocator_traits_dummy<U> atd;\
202+
boost::container::dtl::dispatch_uses_allocator\
203+
(atd, this->get_segment_manager(), p BOOST_MOVE_I##N BOOST_MOVE_FWDQ##N);\
204+
}\
205+
//
206+
BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_ALLOCATORS_ADAPTIVE_POOL_CONSTRUCT_CODE)
207+
#undef BOOST_CONTAINER_ALLOCATORS_ADAPTIVE_POOL_CONSTRUCT_CODE
208+
209+
#endif //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
210+
194211
//!Swaps allocators. Does not throw. If each allocator is placed in a
195212
//!different memory segment, the result is undefined.
196213
friend void swap(self_t &alloc1, self_t &alloc2)
@@ -413,7 +430,7 @@ class adaptive_pool
413430
//!
414431
//! <b>Throws</b>: Nothing unless the constructor for T throws.
415432
template <typename U, class ...Args>
416-
void construct(U* p, BOOST_FWD_REF(Args)...args);
433+
void construct(U* p, Args&& ...args);
417434

418435
//!Returns maximum the number of objects the previously allocated memory
419436
//!pointed by p can hold. This size only works for memory allocated with

include/boost/interprocess/allocators/allocator.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class allocator
160160
void deallocate(const pointer &ptr, size_type)
161161
{ mp_mngr->deallocate((void*)ipcdetail::to_raw_pointer(ptr)); }
162162

163+
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
163164
//! <b>Requires</b>: Uses-allocator construction of T with allocator
164165
//! `segment_manager*` and constructor arguments `std::forward<Args>(args)...`
165166
//! is well-formed. [Note: uses-allocator construction is always well formed for
@@ -178,6 +179,22 @@ class allocator
178179
(atd, this->get_segment_manager(), p, ::boost::forward<Args>(args)...);
179180
}
180181

182+
#else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
183+
184+
#define BOOST_CONTAINER_ALLOCATORS_ALLOCATOR_CONSTRUCT_CODE(N) \
185+
template < typename U BOOST_MOVE_I##N BOOST_MOVE_CLASSQ##N >\
186+
void construct(U* p BOOST_MOVE_I##N BOOST_MOVE_UREFQ##N)\
187+
{\
188+
boost::container::dtl::allocator_traits_dummy<U> atd;\
189+
boost::container::dtl::dispatch_uses_allocator\
190+
(atd, this->get_segment_manager(), p BOOST_MOVE_I##N BOOST_MOVE_FWDQ##N);\
191+
}\
192+
//
193+
BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_ALLOCATORS_ALLOCATOR_CONSTRUCT_CODE)
194+
#undef BOOST_CONTAINER_ALLOCATORS_ALLOCATOR_CONSTRUCT_CODE
195+
196+
#endif //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
197+
181198
//!Returns the number of elements that could be allocated.
182199
//!Never throws
183200
size_type max_size() const

include/boost/interprocess/allocators/cached_adaptive_pool.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ class cached_adaptive_pool
292292
//!
293293
//! <b>Throws</b>: Nothing unless the constructor for T throws.
294294
template <typename U, class ...Args>
295-
void construct(U* p, BOOST_FWD_REF(Args)...args);
295+
void construct(U* p, Args&& ...args);
296296

297297
//!Returns maximum the number of objects the previously allocated memory
298298
//!pointed by p can hold. This size only works for memory allocated with

include/boost/interprocess/allocators/cached_node_allocator.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ class cached_node_allocator
264264
//!
265265
//! <b>Throws</b>: Nothing unless the constructor for T throws.
266266
template <typename U, class ...Args>
267-
void construct(U* p, BOOST_FWD_REF(Args)...args);
267+
void construct(U* p, Args&& ...args);
268268

269269
//!Destroys object. Throws if object's
270270
//!destructor throws

include/boost/interprocess/allocators/detail/allocator_common.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ class cached_allocator_impl
620620
segment_manager* get_segment_manager()const
621621
{ return m_cache.get_segment_manager(); }
622622

623+
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
623624
//! <b>Requires</b>: Uses-allocator construction of T with allocator
624625
//! `segment_manager*` and constructor arguments `std::forward<Args>(args)...`
625626
//! is well-formed. [Note: uses-allocator construction is always well formed for
@@ -638,6 +639,22 @@ class cached_allocator_impl
638639
(atd, this->get_segment_manager(), p, ::boost::forward<Args>(args)...);
639640
}
640641

642+
#else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
643+
644+
#define BOOST_CONTAINER_ALLOCATORS_ALLOCATOR_COMMON_CONSTRUCT_CODE(N) \
645+
template < typename U BOOST_MOVE_I##N BOOST_MOVE_CLASSQ##N >\
646+
void construct(U* p BOOST_MOVE_I##N BOOST_MOVE_UREFQ##N)\
647+
{\
648+
boost::container::dtl::allocator_traits_dummy<U> atd;\
649+
boost::container::dtl::dispatch_uses_allocator\
650+
(atd, this->get_segment_manager(), p BOOST_MOVE_I##N BOOST_MOVE_FWDQ##N);\
651+
}\
652+
//
653+
BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_ALLOCATORS_ALLOCATOR_COMMON_CONSTRUCT_CODE)
654+
#undef BOOST_CONTAINER_ALLOCATORS_ALLOCATOR_COMMON_CONSTRUCT_CODE
655+
656+
#endif //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
657+
641658
//!Sets the new max cached nodes value. This can provoke deallocations
642659
//!if "newmax" is less than current cached nodes. Never throws
643660
void set_max_cached_nodes(size_type newmax)

include/boost/interprocess/allocators/node_allocator.hpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ class node_allocator_base
172172
segment_manager* get_segment_manager()const
173173
{ return node_pool<0>::get(ipcdetail::to_raw_pointer(mp_node_pool))->get_segment_manager(); }
174174

175+
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
175176
//! <b>Requires</b>: Uses-allocator construction of T with allocator
176177
//! `segment_manager*` and constructor arguments `std::forward<Args>(args)...`
177178
//! is well-formed. [Note: uses-allocator construction is always well formed for
@@ -190,6 +191,22 @@ class node_allocator_base
190191
(atd, this->get_segment_manager(), p, ::boost::forward<Args>(args)...);
191192
}
192193

194+
#else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
195+
196+
#define BOOST_CONTAINER_ALLOCATORS_NODE_ALLOCATOR_CONSTRUCT_CODE(N) \
197+
template < typename U BOOST_MOVE_I##N BOOST_MOVE_CLASSQ##N >\
198+
void construct(U* p BOOST_MOVE_I##N BOOST_MOVE_UREFQ##N)\
199+
{\
200+
boost::container::dtl::allocator_traits_dummy<U> atd;\
201+
boost::container::dtl::dispatch_uses_allocator\
202+
(atd, this->get_segment_manager(), p BOOST_MOVE_I##N BOOST_MOVE_FWDQ##N);\
203+
}\
204+
//
205+
BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_ALLOCATORS_NODE_ALLOCATOR_CONSTRUCT_CODE)
206+
#undef BOOST_CONTAINER_ALLOCATORS_NODE_ALLOCATOR_CONSTRUCT_CODE
207+
208+
#endif //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
209+
193210
//!Swaps allocators. Does not throw. If each allocator is placed in a
194211
//!different memory segment, the result is undefined.
195212
friend void swap(self_t &alloc1, self_t &alloc2)
@@ -398,7 +415,7 @@ class node_allocator
398415
//!
399416
//! <b>Throws</b>: Nothing unless the constructor for T throws.
400417
template <typename U, class ...Args>
401-
void construct(U* p, BOOST_FWD_REF(Args)...args);
418+
void construct(U* p, Args&& ...args);
402419

403420
//!Returns maximum the number of objects the previously allocated memory
404421
//!pointed by p can hold. This size only works for memory allocated with

include/boost/interprocess/allocators/private_adaptive_pool.hpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ class private_adaptive_pool_base
177177
segment_manager* get_segment_manager()const
178178
{ return m_node_pool.get_segment_manager(); }
179179

180+
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
180181
//! <b>Requires</b>: Uses-allocator construction of T with allocator
181182
//! `segment_manager*` and constructor arguments `std::forward<Args>(args)...`
182183
//! is well-formed. [Note: uses-allocator construction is always well formed for
@@ -195,6 +196,22 @@ class private_adaptive_pool_base
195196
(atd, this->get_segment_manager(), p, ::boost::forward<Args>(args)...);
196197
}
197198

199+
#else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
200+
201+
#define BOOST_CONTAINER_ALLOCATORS_PRIVATE_ADAPTIVE_POOL_CONSTRUCT_CODE(N) \
202+
template < typename U BOOST_MOVE_I##N BOOST_MOVE_CLASSQ##N >\
203+
void construct(U* p BOOST_MOVE_I##N BOOST_MOVE_UREFQ##N)\
204+
{\
205+
boost::container::dtl::allocator_traits_dummy<U> atd;\
206+
boost::container::dtl::dispatch_uses_allocator\
207+
(atd, this->get_segment_manager(), p BOOST_MOVE_I##N BOOST_MOVE_FWDQ##N);\
208+
}\
209+
//
210+
BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_ALLOCATORS_PRIVATE_ADAPTIVE_POOL_CONSTRUCT_CODE)
211+
#undef BOOST_CONTAINER_ALLOCATORS_PRIVATE_ADAPTIVE_POOL_CONSTRUCT_CODE
212+
213+
#endif //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
214+
198215
//!Returns the internal node pool. Never throws
199216
node_pool_t* get_node_pool() const
200217
{ return const_cast<node_pool_t*>(&m_node_pool); }
@@ -443,7 +460,7 @@ class private_adaptive_pool
443460
//!
444461
//! <b>Throws</b>: Nothing unless the constructor for T throws.
445462
template <typename U, class ...Args>
446-
void construct(U* p, BOOST_FWD_REF(Args)...args);
463+
void construct(U* p, Args&& ...args);
447464

448465
//!Returns maximum the number of objects the previously allocated memory
449466
//!pointed by p can hold. This size only works for memory allocated with

include/boost/interprocess/allocators/private_node_allocator.hpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ class private_node_allocator_base
167167
segment_manager* get_segment_manager()const
168168
{ return m_node_pool.get_segment_manager(); }
169169

170+
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
170171
//! <b>Requires</b>: Uses-allocator construction of T with allocator
171172
//! `segment_manager*` and constructor arguments `std::forward<Args>(args)...`
172173
//! is well-formed. [Note: uses-allocator construction is always well formed for
@@ -185,6 +186,22 @@ class private_node_allocator_base
185186
(atd, this->get_segment_manager(), p, ::boost::forward<Args>(args)...);
186187
}
187188

189+
#else // #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
190+
191+
#define BOOST_CONTAINER_ALLOCATORS_PRIVATE_NODE_ALLOCATOR_CONSTRUCT_CODE(N) \
192+
template < typename U BOOST_MOVE_I##N BOOST_MOVE_CLASSQ##N >\
193+
void construct(U* p BOOST_MOVE_I##N BOOST_MOVE_UREFQ##N)\
194+
{\
195+
boost::container::dtl::allocator_traits_dummy<U> atd;\
196+
boost::container::dtl::dispatch_uses_allocator\
197+
(atd, this->get_segment_manager(), p BOOST_MOVE_I##N BOOST_MOVE_FWDQ##N);\
198+
}\
199+
//
200+
BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_ALLOCATORS_PRIVATE_NODE_ALLOCATOR_CONSTRUCT_CODE)
201+
#undef BOOST_CONTAINER_ALLOCATORS_PRIVATE_NODE_ALLOCATOR_CONSTRUCT_CODE
202+
203+
#endif //#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
204+
188205
//!Returns the internal node pool. Never throws
189206
node_pool_t* get_node_pool() const
190207
{ return const_cast<node_pool_t*>(&m_node_pool); }
@@ -418,7 +435,7 @@ class private_node_allocator
418435
//!
419436
//! <b>Throws</b>: Nothing unless the constructor for T throws.
420437
template <typename U, class ...Args>
421-
void construct(U* p, BOOST_FWD_REF(Args)...args);
438+
void construct(U* p, Args&& ...args);
422439

423440
//!Returns maximum the number of objects the previously allocated memory
424441
//!pointed by p can hold. This size only works for memory allocated with

0 commit comments

Comments
 (0)