From 3f3a63d92a1a052ff74d6cc89931f2e99e3c4b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Fri, 30 Dec 2011 23:47:03 +0000 Subject: [PATCH] Bugs #6335 & #6336 [SVN r76237] --- doc/container.qbk | 4 +- test/allocator_traits_test.cpp | 68 ++++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/doc/container.qbk b/doc/container.qbk index 54f37c3..9038c53 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -590,7 +590,9 @@ use [*Boost.Container]? There are several reasons for that: * Fixed bugs [@https://svn.boost.org/trac/boost/ticket/6205 #6205], [@https://svn.boost.org/trac/boost/ticket/6287 #6287], - [@https://svn.boost.org/trac/boost/ticket/4383 #4383]. + [@https://svn.boost.org/trac/boost/ticket/4383 #4383], + [@https://svn.boost.org/trac/boost/ticket/6336 #6336], + [@https://svn.boost.org/trac/boost/ticket/6335 #6335]. * Added `allocator_traits` support for both C++11 and C++03 compilers through an internal `allocator_traits` clone. diff --git a/test/allocator_traits_test.cpp b/test/allocator_traits_test.cpp index ed109d4..36e5a9e 100644 --- a/test/allocator_traits_test.cpp +++ b/test/allocator_traits_test.cpp @@ -15,6 +15,7 @@ #include #include #include +#include template class SimpleAllocator @@ -63,7 +64,7 @@ class SimpleSmartPtr T *ptr_; }; -template +template class ComplexAllocator { bool allocate_called_; @@ -76,17 +77,19 @@ class ComplexAllocator public: typedef T value_type; - typedef SimpleSmartPtr pointer; - typedef SimpleSmartPtr const_pointer; - typedef T & reference; - typedef const T & const_reference; - typedef SimpleSmartPtr void_pointer; - typedef SimpleSmartPtr const_void_pointer; - typedef signed short difference_type; - typedef unsigned short size_type; - typedef boost::true_type propagate_on_container_copy_assignment; - typedef boost::true_type propagate_on_container_move_assignment; - typedef boost::true_type propagate_on_container_swap; + typedef SimpleSmartPtr pointer; + typedef SimpleSmartPtr const_pointer; + typedef typename boost::container:: + container_detail::unvoid::type & reference; + typedef const typename boost::container:: + container_detail::unvoid::type & const_reference; + typedef SimpleSmartPtr void_pointer; + typedef SimpleSmartPtr const_void_pointer; + typedef signed short difference_type; + typedef unsigned short size_type; + typedef boost::true_type propagate_on_container_copy_assignment; + typedef boost::true_type propagate_on_container_move_assignment; + typedef boost::true_type propagate_on_container_swap; ComplexAllocator() : allocate_called_(false) @@ -120,10 +123,10 @@ class ComplexAllocator #define BOOST_PP_LOCAL_MACRO(n) \ template \ - void construct(U *p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ + void construct(U *p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ { \ construct_called_ = true; \ - ::new (p) U (BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ + ::new (p) U (BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \ } \ // #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) @@ -187,8 +190,17 @@ class copymovable { return moved_; } }; +void test_void_allocator() +{ + boost::container::allocator_traits > stdtraits; (void)stdtraits; + boost::container::allocator_traits > simtraits; (void)simtraits; + boost::container::allocator_traits > comtraits; (void)comtraits; +} + int main() { + test_void_allocator(); + //SimpleAllocator BOOST_STATIC_ASSERT(( boost::is_same >::value_type, int>::value )); @@ -219,33 +231,33 @@ int main() //ComplexAllocator BOOST_STATIC_ASSERT(( boost::is_same >::value_type, int>::value )); + < ComplexAllocator >::value_type, int>::value )); BOOST_STATIC_ASSERT(( boost::is_same >::pointer, SimpleSmartPtr >::value )); + < ComplexAllocator >::pointer, SimpleSmartPtr >::value )); BOOST_STATIC_ASSERT(( boost::is_same >::const_pointer, SimpleSmartPtr >::value )); + < ComplexAllocator >::const_pointer, SimpleSmartPtr >::value )); BOOST_STATIC_ASSERT(( boost::is_same >::void_pointer, SimpleSmartPtr >::value )); + < ComplexAllocator >::void_pointer, SimpleSmartPtr >::value )); BOOST_STATIC_ASSERT(( boost::is_same >::const_void_pointer, SimpleSmartPtr >::value )); + < ComplexAllocator >::const_void_pointer, SimpleSmartPtr >::value )); BOOST_STATIC_ASSERT(( boost::is_same >::difference_type, signed short>::value )); + < ComplexAllocator >::difference_type, signed short>::value )); BOOST_STATIC_ASSERT(( boost::is_same >::size_type, unsigned short>::value )); + < ComplexAllocator >::size_type, unsigned short>::value )); BOOST_STATIC_ASSERT(( boost::container::allocator_traits - < ComplexAllocator >::propagate_on_container_copy_assignment::value == true )); + < ComplexAllocator >::propagate_on_container_copy_assignment::value == true )); BOOST_STATIC_ASSERT(( boost::container::allocator_traits - < ComplexAllocator >::propagate_on_container_move_assignment::value == true )); + < ComplexAllocator >::propagate_on_container_move_assignment::value == true )); BOOST_STATIC_ASSERT(( boost::container::allocator_traits - < ComplexAllocator >::propagate_on_container_swap::value == true )); + < ComplexAllocator >::propagate_on_container_swap::value == true )); BOOST_STATIC_ASSERT(( boost::is_same >::rebind_traits::allocator_type - , ComplexAllocator >::value )); + < ComplexAllocator >::rebind_traits::allocator_type + , ComplexAllocator >::value )); BOOST_STATIC_ASSERT(( boost::is_same >::rebind_alloc::value_type + < ComplexAllocator >::rebind_alloc::value_type , double >::value )); - typedef ComplexAllocator CAlloc; + typedef ComplexAllocator CAlloc; typedef SimpleAllocator SAlloc; typedef boost::container::allocator_traits CAllocTraits; typedef boost::container::allocator_traits SAllocTraits;