Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76262 - in trunk/boost/container: . detail
From: igaztanaga_at_[hidden]
Date: 2012-01-01 13:48:01


Author: igaztanaga
Date: 2012-01-01 13:48:00 EST (Sun, 01 Jan 2012)
New Revision: 76262
URL: http://svn.boost.org/trac/boost/changeset/76262

Log:
Fixes for VC2005 and replaced some remaining placement news/destroys with allocator traits
Text files modified:
   trunk/boost/container/deque.hpp | 36 +++++++++--
   trunk/boost/container/detail/algorithms.hpp | 123 ----------------------------------------
   trunk/boost/container/stable_vector.hpp | 13 ++-
   trunk/boost/container/string.hpp | 38 ++++++++++--
   trunk/boost/container/vector.hpp | 2
   5 files changed, 67 insertions(+), 145 deletions(-)

Modified: trunk/boost/container/deque.hpp
==============================================================================
--- trunk/boost/container/deque.hpp (original)
+++ trunk/boost/container/deque.hpp 2012-01-01 13:48:00 EST (Sun, 01 Jan 2012)
@@ -1069,7 +1069,10 @@
    {
       if (this->members_.m_finish.m_cur != this->members_.m_finish.m_first) {
          --this->members_.m_finish.m_cur;
- container_detail::to_raw_pointer(this->members_.m_finish.m_cur)->~value_type();
+ allocator_traits_type::destroy
+ ( this->alloc()
+ , container_detail::to_raw_pointer(this->members_.m_finish.m_cur)
+ );
       }
       else
          this->priv_pop_back_aux();
@@ -1083,7 +1086,10 @@
    void pop_front() BOOST_CONTAINER_NOEXCEPT
    {
       if (this->members_.m_start.m_cur != this->members_.m_start.m_last - 1) {
- container_detail::to_raw_pointer(this->members_.m_start.m_cur)->~value_type();
+ allocator_traits_type::destroy
+ ( this->alloc()
+ , container_detail::to_raw_pointer(this->members_.m_start.m_cur)
+ );
          ++this->members_.m_start.m_cur;
       }
       else
@@ -1598,14 +1604,22 @@
 
    void priv_destroy_range(iterator p, iterator p2)
    {
- for(;p != p2; ++p)
- container_detail::to_raw_pointer(&*p)->~value_type();
+ for(;p != p2; ++p){
+ allocator_traits_type::destroy
+ ( this->alloc()
+ , container_detail::to_raw_pointer(&*p)
+ );
+ }
    }
 
    void priv_destroy_range(pointer p, pointer p2)
    {
- for(;p != p2; ++p)
- container_detail::to_raw_pointer(&*p)->~value_type();
+ for(;p != p2; ++p){
+ allocator_traits_type::destroy
+ ( this->alloc()
+ , container_detail::to_raw_pointer(&*p)
+ );
+ }
    }
 
    template <class Integer>
@@ -1827,7 +1841,10 @@
       this->priv_deallocate_node(this->members_.m_finish.m_first);
       this->members_.m_finish.priv_set_node(this->members_.m_finish.m_node - 1);
       this->members_.m_finish.m_cur = this->members_.m_finish.m_last - 1;
- container_detail::to_raw_pointer(this->members_.m_finish.m_cur)->~value_type();
+ allocator_traits_type::destroy
+ ( this->alloc()
+ , container_detail::to_raw_pointer(this->members_.m_finish.m_cur)
+ );
    }
 
    // Called only if this->members_.m_start.m_cur == this->members_.m_start.m_last - 1. Note that
@@ -1836,7 +1853,10 @@
    // must have at least two nodes.
    void priv_pop_front_aux()
    {
- container_detail::to_raw_pointer(this->members_.m_start.m_cur)->~value_type();
+ allocator_traits_type::destroy
+ ( this->alloc()
+ , container_detail::to_raw_pointer(this->members_.m_start.m_cur)
+ );
       this->priv_deallocate_node(this->members_.m_start.m_first);
       this->members_.m_start.priv_set_node(this->members_.m_start.m_node + 1);
       this->members_.m_start.m_cur = this->members_.m_start.m_first;

Modified: trunk/boost/container/detail/algorithms.hpp
==============================================================================
--- trunk/boost/container/detail/algorithms.hpp (original)
+++ trunk/boost/container/detail/algorithms.hpp 2012-01-01 13:48:00 EST (Sun, 01 Jan 2012)
@@ -50,130 +50,7 @@
 {
    ei.construct_in_place(a, dest);
 }
-/*
-template<class InIt, class OutIt>
-struct optimize_assign
-{
- static const bool value = false;
-};
-
-template<class T>
-struct optimize_assign<const T*, T*>
-{
- static const bool value = boost::has_trivial_assign<T>::value;
-};
-
-template<class T>
-struct optimize_assign<T*, T*>
- : public optimize_assign<const T*, T*>
-{};
-
-template<class InIt, class OutIt>
-struct optimize_copy
-{
- static const bool value = false;
-};
-
-template<class T>
-struct optimize_copy<const T*, T*>
-{
- static const bool value = boost::has_trivial_copy<T>::value;
-};
-
-template<class T>
-struct optimize_copy<T*, T*>
- : public optimize_copy<const T*, T*>
-{};
-
-template<class InIt, class OutIt> inline
-OutIt copy_n_dispatch(InIt first, typename std::iterator_traits<InIt>::difference_type length, OutIt dest, container_detail::bool_<false>)
-{
- for (; length--; ++dest, ++first)
- *dest = *first;
- return dest;
-}
-
-template<class T> inline
-T *copy_n_dispatch(const T *first, typename std::iterator_traits<const T*>::difference_type length, T *dest, container_detail::bool_<true>)
-{
- std::size_t size = length*sizeof(T);
- return (static_cast<T*>(std::memmove(dest, first, size))) + size;
-}
 
-template<class InIt, class OutIt> inline
-OutIt copy_n(InIt first, typename std::iterator_traits<InIt>::difference_type length, OutIt dest)
-{
- const bool do_optimized_assign = optimize_assign<InIt, OutIt>::value;
- return copy_n_dispatch(first, length, dest, container_detail::bool_<do_optimized_assign>());
-}
-
-template<class InIt, class FwdIt> inline
-FwdIt uninitialized_copy_n_dispatch
- (InIt first,
- typename std::iterator_traits<InIt>::difference_type count,
- FwdIt dest, container_detail::bool_<false>)
-{
- typedef typename std::iterator_traits<FwdIt>::value_type value_type;
- //Save initial destination position
- FwdIt dest_init = dest;
- typename std::iterator_traits<InIt>::difference_type new_count = count+1;
-
- BOOST_TRY{
- //Try to build objects
- for (; --new_count; ++dest, ++first){
- construct_in_place(container_detail::to_raw_pointer(&*dest), first);
- }
- }
- BOOST_CATCH(...){
- //Call destructors
- new_count = count - new_count;
- for (; new_count--; ++dest_init){
- container_detail::to_raw_pointer(&*dest_init)->~value_type();
- }
- BOOST_RETHROW
- }
- BOOST_CATCH_END
- return dest;
-}
-template<class T> inline
-T *uninitialized_copy_n_dispatch(const T *first, typename std::iterator_traits<const T*>::difference_type length, T *dest, container_detail::bool_<true>)
-{
- std::size_t size = length*sizeof(T);
- return (static_cast<T*>(std::memmove(dest, first, size))) + size;
-}
-
-template<class InIt, class FwdIt> inline
-FwdIt uninitialized_copy_n
- (InIt first,
- typename std::iterator_traits<InIt>::difference_type count,
- FwdIt dest)
-{
- const bool do_optimized_copy = optimize_copy<InIt, FwdIt>::value;
- return uninitialized_copy_n_dispatch(first, count, dest, container_detail::bool_<do_optimized_copy>());
-}
-
-// uninitialized_copy_copy
-// Copies [first1, last1) into [result, result + (last1 - first1)), and
-// copies [first2, last2) into
-// [result + (last1 - first1), result + (last1 - first1) + (last2 - first2)).
-template <class InpIt1, class InpIt2, class FwdIt>
-FwdIt uninitialized_copy_copy
- (InpIt1 first1, InpIt1 last1, InpIt2 first2, InpIt2 last2, FwdIt result)
-{
- typedef typename std::iterator_traits<FwdIt>::value_type value_type;
- FwdIt mid = std::uninitialized_copy(first1, last1, result);
- BOOST_TRY {
- return std::uninitialized_copy(first2, last2, mid);
- }
- BOOST_CATCH(...){
- for(;result != mid; ++result){
- container_detail::to_raw_pointer(&*result)->~value_type();
- }
- BOOST_RETHROW
- }
- BOOST_CATCH_END
-}
-*/
 } //namespace container {
 } //namespace boost {
 

Modified: trunk/boost/container/stable_vector.hpp
==============================================================================
--- trunk/boost/container/stable_vector.hpp (original)
+++ trunk/boost/container/stable_vector.hpp 2012-01-01 13:48:00 EST (Sun, 01 Jan 2012)
@@ -446,7 +446,7 @@
    template<class AllocatorVersion>
    node_type_ptr_t allocate_one(AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
- <boost::container::container_detail::is_same<AllocatorVersion, allocator_v2>
+ <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
             ::value>::type * = 0)
    { return node_alloc().allocate_one(); }
 
@@ -463,7 +463,7 @@
    template<class AllocatorVersion>
    void deallocate_one(node_type_ptr_t p, AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
- <boost::container::container_detail::is_same<AllocatorVersion, allocator_v2>
+ <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
             ::value>::type * = 0)
    { node_alloc().deallocate_one(p); }
 
@@ -1316,7 +1316,7 @@
    template<class AllocatorVersion>
    void clear_pool(AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
- <boost::container::container_detail::is_same<AllocatorVersion, allocator_v2>
+ <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
             ::value>::type * = 0)
    {
       if(!impl.empty() && impl.back()){
@@ -1355,7 +1355,7 @@
    template<class AllocatorVersion>
    void add_to_pool(size_type n, AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
- <boost::container::container_detail::is_same<AllocatorVersion, allocator_v2>
+ <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
             ::value>::type * = 0)
    {
       void_ptr &pool_first_ref = impl.end()[-2];
@@ -1473,7 +1473,7 @@
    template<class AllocatorVersion>
    iterator priv_erase(const_iterator first, const_iterator last, AllocatorVersion,
       typename boost::container::container_detail::enable_if_c
- <boost::container::container_detail::is_same<AllocatorVersion, allocator_v2>
+ <!boost::container::container_detail::is_same<AllocatorVersion, allocator_v1>
             ::value>::type * = 0)
    {
       STABLE_VECTOR_CHECK_INVARIANT;
@@ -1542,7 +1542,8 @@
    void delete_node(const void_ptr &p)
    {
       node_type_ptr_t n(node_ptr_cast(p));
- n->~node_type_t();
+ allocator_traits<node_allocator_type>::
+ destroy(this->node_alloc(), container_detail::to_raw_pointer(n));
       this->put_in_pool(n);
    }
 

Modified: trunk/boost/container/string.hpp
==============================================================================
--- trunk/boost/container/string.hpp (original)
+++ trunk/boost/container/string.hpp 2012-01-01 13:48:00 EST (Sun, 01 Jan 2012)
@@ -127,7 +127,10 @@
    {
       if(!this->is_short()){
          this->deallocate_block();
- static_cast<long_t*>(static_cast<void*>(&this->members_.m_repr.r))->~long_t();
+ allocator_traits_type::destroy
+ ( this->alloc()
+ , static_cast<long_t*>(static_cast<void*>(&this->members_.m_repr.r))
+ );
       }
    }
 
@@ -240,10 +243,16 @@
    void is_short(bool yes)
    {
       if(yes && !this->is_short()){
- static_cast<long_t*>(static_cast<void*>(&this->members_.m_repr.r))->~long_t();
+ allocator_traits_type::destroy
+ ( this->alloc()
+ , static_cast<long_t*>(static_cast<void*>(&this->members_.m_repr.r))
+ );
       }
       else{
- new(static_cast<void*>(&this->members_.m_repr.r))long_t();
+ allocator_traits_type::construct
+ ( this->alloc()
+ , static_cast<long_t*>(static_cast<void*>(&this->members_.m_repr.r))
+ );
       }
       this->members_.m_repr.s.h.is_short = yes;
    }
@@ -314,16 +323,31 @@
    }
 
    void construct(pointer p, const value_type &value = value_type())
- { new((void*)container_detail::to_raw_pointer(p)) value_type(value); }
+ {
+ allocator_traits_type::construct
+ ( this->alloc()
+ , container_detail::to_raw_pointer(p)
+ , value
+ );
+ }
 
    void destroy(pointer p, size_type n)
    {
- for(; n--; ++p)
- container_detail::to_raw_pointer(p)->~value_type();
+ for(; n--; ++p){
+ allocator_traits_type::destroy
+ ( this->alloc()
+ , container_detail::to_raw_pointer(p)
+ );
+ }
    }
 
    void destroy(pointer p)
- { container_detail::to_raw_pointer(p)->~value_type(); }
+ {
+ allocator_traits_type::destroy
+ ( this->alloc()
+ , container_detail::to_raw_pointer(p)
+ );
+ }
 
    void allocate_initial_block(size_type n)
    {

Modified: trunk/boost/container/vector.hpp
==============================================================================
--- trunk/boost/container/vector.hpp (original)
+++ trunk/boost/container/vector.hpp 2012-01-01 13:48:00 EST (Sun, 01 Jan 2012)
@@ -1328,7 +1328,7 @@
    template<class AllocVersion>
    void priv_shrink_to_fit(AllocVersion
                           , typename container_detail::enable_if_c<
- container_detail::is_same<AllocVersion, allocator_v2>::value >::type * = 0)
+ !container_detail::is_same<AllocVersion, allocator_v1>::value >::type * = 0)
    {
       if(this->members_.m_capacity){
          if(!size()){


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk