--- boost-orig/boost/container/detail/tree.hpp +++ boost/boost/container/detail/tree.hpp @@ -262,19 +262,20 @@ if(NodePtr p = m_icont.unlink_leftmost_without_rebalance()){ //First recycle a node (this can't throw) //NodePtr p = m_icont.unlink_leftmost_without_rebalance(); - try{ + BOOST_TRY{ //This can throw *p = other; return p; } - catch(...){ + BOOST_CATCH(...){ //If there is an exception destroy the whole source m_holder.destroy_node(p); while((p = m_icont.unlink_leftmost_without_rebalance())){ m_holder.destroy_node(p); } - throw; + BOOST_RETHROW; } + BOOST_CATCH_END } else{ return m_holder.create_node(other); --- boost-orig/boost/container/detail/node_pool_impl.hpp +++ boost/boost/container/detail/node_pool_impl.hpp @@ -302,7 +302,7 @@ size_type blocksize = get_rounded_size(m_real_node_size*m_nodes_per_block, (size_type)alignment_of::value); - try{ + BOOST_TRY{ for(size_type i = 0; i != num_blocks; ++i){ //We allocate a new NodeBlock and put it as first //element in the free Node list @@ -318,10 +318,11 @@ } } } - catch(...){ + BOOST_CATCH(...){ //to-do: if possible, an efficient way to deallocate allocated blocks - throw; + BOOST_RETHROW; } + BOOST_CATCH_END } //!Deprecated, use deallocate_free_blocks --- boost-orig/boost/container/detail/advanced_insert_int.hpp +++ boost/boost/container/detail/advanced_insert_int.hpp @@ -16,6 +16,7 @@ #endif #include "config_begin.hpp" +#include #include #include #include //std::iterator_traits @@ -101,17 +102,18 @@ BOOST_ASSERT(n <= count_); Iterator orig_p = p; SizeType i = 0; - try{ + BOOST_TRY{ for(; i < n; ++i, ++p){ new(containers_detail::get_pointer(&*p))T(); } } - catch(...){ + BOOST_CATCH(...){ while(i--){ containers_detail::get_pointer(&*orig_p++)->~T(); } - throw; + BOOST_RETHROW; } + BOOST_CATCH_END count_ -= n; } --- boost-orig/boost/container/detail/adaptive_node_pool_impl.hpp +++ boost/boost/container/detail/adaptive_node_pool_impl.hpp @@ -16,6 +16,7 @@ #endif #include "config_begin.hpp" +#include #include #include #include @@ -254,7 +255,7 @@ { multiallocation_chain chain; size_type i = 0; - try{ + BOOST_TRY{ priv_invariants(); while(i != n){ //If there are no free nodes we allocate all needed blocks @@ -279,10 +280,11 @@ i += num_elems; } } - catch(...){ + BOOST_CATCH(...){ this->deallocate_nodes(boost::move(chain)); - throw; + BOOST_RETHROW; } + BOOST_CATCH_END priv_invariants(); return boost::move(chain); } --- boost-orig/boost/container/stable_vector.hpp +++ boost/boost/container/stable_vector.hpp @@ -1433,14 +1433,15 @@ void_ptr new_node(const void_ptr &up, Iter it) { node_type_ptr_t p = this->allocate_one(); - try{ + BOOST_TRY{ boost::container::construct_in_place(&*p, it); p->set_pointer(up); } - catch(...){ + BOOST_CATCH(...){ this->deallocate_one(p); - throw; + BOOST_RETHROW } + BOOST_CATCH_END return p; } @@ -1499,18 +1500,19 @@ void insert_iter_fwd_alloc(const impl_iterator it, FwdIterator first, FwdIterator last, difference_type n, allocator_v1) { size_type i=0; - try{ + BOOST_TRY{ while(first!=last){ it[i] = this->new_node(void_ptr_ptr(&it[i]), first); ++first; ++i; } } - catch(...){ + BOOST_CATCH(...){ impl_iterator e = impl.erase(it + i, it + n); this->align_nodes(e, get_last_align()); - throw; + BOOST_RETHROW } + BOOST_CATCH_END } template @@ -1520,7 +1522,7 @@ size_type i = 0; node_type_ptr_t p = 0; - try{ + BOOST_TRY{ while(first != last){ p = mem.front(); mem.pop_front(); @@ -1532,13 +1534,14 @@ ++i; } } - catch(...){ + BOOST_CATCH(...){ get_al().deallocate_one(p); get_al().deallocate_many(boost::move(mem)); impl_iterator e = impl.erase(it+i, it+n); this->align_nodes(e, get_last_align()); - throw; + BOOST_RETHROW } + BOOST_CATCH_END } template @@ -1546,7 +1549,7 @@ { size_type i = 0; node_type_ptr_t p = 0; - try{ + BOOST_TRY{ while(first != last){ p = get_from_pool(); if(!p){ @@ -1561,12 +1564,13 @@ ++i; } } - catch(...){ + BOOST_CATCH(...){ put_in_pool(p); impl_iterator e = impl.erase(it+i, it+n); this->align_nodes(e, get_last_align()); - throw; + BOOST_RETHROW } + BOOST_CATCH_END } template --- boost-orig/boost/container/vector.hpp +++ boost/boost/container/vector.hpp @@ -1932,7 +1932,7 @@ { //If n is out of range, throw an out_of_range exception if (n >= size()) - throw std::out_of_range("vector::at"); + BOOST_THROW_EXCEPTION(std::out_of_range("vector::at")); } #ifdef BOOST_CONTAINERS_VECTOR_ALLOC_STATS --- boost-orig/boost/container/string.hpp +++ boost/boost/container/string.hpp @@ -1991,7 +1991,7 @@ size_type long_size = this->priv_long_size(); size_type long_storage = this->priv_long_storage(); //We can make this nothrow as chars are always NoThrowCopyables - try{ + BOOST_TRY{ std::pair ret = this->allocation_command (allocate_new, long_size+1, long_size+1, real_cap, long_addr); //Copy and update @@ -2003,9 +2003,10 @@ //And release old buffer this->alloc().deallocate(long_addr, long_storage); } - catch(...){ + BOOST_CATCH(...){ return; } + BOOST_CATCH_END } void priv_shrink_to_fit_dynamic_buffer(allocator_v2)