Ticket #7227: boost-container.patch

File boost-container.patch, 7.0 KB (added by Francois Duranleau <xiao.bai.xiong@…>, 10 years ago)

Fix for more try/catch -> BOOST_TRY/BOOST_CATCH

  • boost/container/detail/tree.hpp

    old new  
    262262         if(NodePtr p = m_icont.unlink_leftmost_without_rebalance()){
    263263            //First recycle a node (this can't throw)
    264264            //NodePtr p = m_icont.unlink_leftmost_without_rebalance();
    265             try{
     265            BOOST_TRY{
    266266               //This can throw
    267267               *p = other;
    268268               return p;
    269269            }
    270             catch(...){
     270            BOOST_CATCH(...){
    271271               //If there is an exception destroy the whole source
    272272               m_holder.destroy_node(p);
    273273               while((p = m_icont.unlink_leftmost_without_rebalance())){
    274274                  m_holder.destroy_node(p);
    275275               }
    276                throw;
     276               BOOST_RETHROW;
    277277            }
     278                        BOOST_CATCH_END
    278279         }
    279280         else{
    280281            return m_holder.create_node(other);
  • boost/container/detail/node_pool_impl.hpp

    old new  
    302302      size_type blocksize =
    303303         get_rounded_size(m_real_node_size*m_nodes_per_block, (size_type)alignment_of<node_t>::value);
    304304
    305       try{
     305      BOOST_TRY{
    306306         for(size_type i = 0; i != num_blocks; ++i){
    307307            //We allocate a new NodeBlock and put it as first
    308308            //element in the free Node list
     
    318318            }
    319319         }
    320320      }
    321       catch(...){
     321      BOOST_CATCH(...){
    322322         //to-do: if possible, an efficient way to deallocate allocated blocks
    323          throw;
     323                 BOOST_RETHROW;
    324324      }
     325          BOOST_CATCH_END
    325326   }
    326327
    327328   //!Deprecated, use deallocate_free_blocks
  • boost/container/detail/advanced_insert_int.hpp

    old new  
    1616#endif
    1717
    1818#include "config_begin.hpp"
     19#include <boost/detail/no_exceptions_support.hpp>
    1920#include <boost/container/detail/workaround.hpp>
    2021#include <boost/move/move.hpp>
    2122#include <iterator>  //std::iterator_traits
     
    101102      BOOST_ASSERT(n <= count_);
    102103      Iterator orig_p = p;
    103104      SizeType i = 0;
    104       try{
     105      BOOST_TRY{
    105106         for(; i < n; ++i, ++p){
    106107            new(containers_detail::get_pointer(&*p))T();
    107108         }
    108109      }
    109       catch(...){
     110      BOOST_CATCH(...){
    110111         while(i--){
    111112            containers_detail::get_pointer(&*orig_p++)->~T();
    112113         }
    113          throw;
     114         BOOST_RETHROW;
    114115      }
     116          BOOST_CATCH_END
    115117      count_ -= n;
    116118   }
    117119
  • boost/container/detail/adaptive_node_pool_impl.hpp

    old new  
    1616#endif
    1717
    1818#include "config_begin.hpp"
     19#include <boost/detail/no_exceptions_support.hpp>
    1920#include <boost/container/container_fwd.hpp>
    2021#include <boost/container/detail/workaround.hpp>
    2122#include <boost/container/detail/utilities.hpp>
     
    254255   {
    255256      multiallocation_chain chain;
    256257      size_type i = 0;
    257       try{
     258      BOOST_TRY{
    258259         priv_invariants();
    259260         while(i != n){
    260261            //If there are no free nodes we allocate all needed blocks
     
    279280            i += num_elems;
    280281         }
    281282      }
    282       catch(...){
     283      BOOST_CATCH(...){
    283284         this->deallocate_nodes(boost::move(chain));
    284          throw;
     285         BOOST_RETHROW;
    285286      }
     287          BOOST_CATCH_END
    286288      priv_invariants();
    287289      return boost::move(chain);
    288290   }
  • boost/container/stable_vector.hpp

    old new  
    14331433   void_ptr new_node(const void_ptr &up, Iter it)
    14341434   {
    14351435      node_type_ptr_t p = this->allocate_one();
    1436       try{
     1436      BOOST_TRY{
    14371437         boost::container::construct_in_place(&*p, it);
    14381438         p->set_pointer(up);
    14391439      }
    1440       catch(...){
     1440      BOOST_CATCH(...){
    14411441         this->deallocate_one(p);
    1442          throw;
     1442         BOOST_RETHROW
    14431443      }
     1444          BOOST_CATCH_END
    14441445      return p;
    14451446   }
    14461447
     
    14991500   void insert_iter_fwd_alloc(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n, allocator_v1)
    15001501   {
    15011502      size_type i=0;
    1502       try{
     1503      BOOST_TRY{
    15031504         while(first!=last){
    15041505            it[i] = this->new_node(void_ptr_ptr(&it[i]), first);
    15051506            ++first;
    15061507            ++i;
    15071508         }
    15081509      }
    1509       catch(...){
     1510      BOOST_CATCH(...){
    15101511         impl_iterator e = impl.erase(it + i, it + n);
    15111512         this->align_nodes(e, get_last_align());
    1512          throw;
     1513         BOOST_RETHROW
    15131514      }
     1515          BOOST_CATCH_END
    15141516   }
    15151517
    15161518   template <class FwdIterator>
     
    15201522
    15211523      size_type i = 0;
    15221524      node_type_ptr_t p = 0;
    1523       try{
     1525      BOOST_TRY{
    15241526         while(first != last){
    15251527            p = mem.front();
    15261528            mem.pop_front();
     
    15321534            ++i;
    15331535         }
    15341536      }
    1535       catch(...){
     1537      BOOST_CATCH(...){
    15361538         get_al().deallocate_one(p);
    15371539         get_al().deallocate_many(boost::move(mem));
    15381540         impl_iterator e = impl.erase(it+i, it+n);
    15391541         this->align_nodes(e, get_last_align());
    1540          throw;
     1542         BOOST_RETHROW
    15411543      }
     1544          BOOST_CATCH_END
    15421545   }
    15431546
    15441547   template <class FwdIterator>
     
    15461549   {
    15471550      size_type i = 0;
    15481551      node_type_ptr_t p = 0;
    1549       try{
     1552      BOOST_TRY{
    15501553         while(first != last){
    15511554            p = get_from_pool();
    15521555            if(!p){
     
    15611564            ++i;
    15621565         }
    15631566      }
    1564       catch(...){
     1567      BOOST_CATCH(...){
    15651568         put_in_pool(p);
    15661569         impl_iterator e = impl.erase(it+i, it+n);
    15671570         this->align_nodes(e, get_last_align());
    1568          throw;
     1571         BOOST_RETHROW
    15691572      }
     1573          BOOST_CATCH_END
    15701574   }
    15711575
    15721576   template <class InputIterator>
  • boost/container/vector.hpp

    old new  
    19321932   {
    19331933      //If n is out of range, throw an out_of_range exception
    19341934      if (n >= size())
    1935          throw std::out_of_range("vector::at");
     1935                 BOOST_THROW_EXCEPTION(std::out_of_range("vector::at"));
    19361936   }
    19371937
    19381938   #ifdef BOOST_CONTAINERS_VECTOR_ALLOC_STATS
  • boost/container/string.hpp

    old new  
    19911991      size_type long_size    = this->priv_long_size();
    19921992      size_type long_storage = this->priv_long_storage();
    19931993      //We can make this nothrow as chars are always NoThrowCopyables
    1994       try{
     1994      BOOST_TRY{
    19951995         std::pair<pointer, bool> ret = this->allocation_command
    19961996               (allocate_new, long_size+1, long_size+1, real_cap, long_addr);
    19971997         //Copy and update
     
    20032003         //And release old buffer
    20042004         this->alloc().deallocate(long_addr, long_storage);
    20052005      }
    2006       catch(...){
     2006      BOOST_CATCH(...){
    20072007         return;
    20082008      }
     2009          BOOST_CATCH_END
    20092010   }
    20102011
    20112012   void priv_shrink_to_fit_dynamic_buffer(allocator_v2)