Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84045 - in trunk/boost/geometry/index/detail: . rtree/linear rtree/node rtree/quadratic rtree/rstar rtree/visitors
From: adam.wulkiewicz_at_[hidden]
Date: 2013-04-25 09:55:21


Author: awulkiew
Date: 2013-04-25 09:55:19 EDT (Thu, 25 Apr 2013)
New Revision: 84045
URL: http://svn.boost.org/trac/boost/changeset/84045

Log:
geometry.index: supported environments with disabled exceptions (BOOST_NO_EXCEPTIONS)
Added:
   trunk/boost/geometry/index/detail/exception.hpp (contents, props changed)
Text files modified:
   trunk/boost/geometry/index/detail/assert.hpp | 4 ++--
   trunk/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp | 7 ++++---
   trunk/boost/geometry/index/detail/rtree/node/node.hpp | 7 -------
   trunk/boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp | 2 +-
   trunk/boost/geometry/index/detail/rtree/node/node_s_mem_dynamic.hpp | 2 +-
   trunk/boost/geometry/index/detail/rtree/quadratic/redistribute_elements.hpp | 7 ++++---
   trunk/boost/geometry/index/detail/rtree/rstar/insert.hpp | 21 ++++++++++++---------
   trunk/boost/geometry/index/detail/rtree/rstar/redistribute_elements.hpp | 7 ++++---
   trunk/boost/geometry/index/detail/rtree/visitors/insert.hpp | 17 +++++++++++------
   trunk/boost/geometry/index/detail/rtree/visitors/remove.hpp | 21 ++++++++++++---------
   trunk/boost/geometry/index/detail/varray.hpp | 22 ++++++++++++----------
   11 files changed, 63 insertions(+), 54 deletions(-)

Modified: trunk/boost/geometry/index/detail/assert.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/assert.hpp (original)
+++ trunk/boost/geometry/index/detail/assert.hpp 2013-04-25 09:55:19 EDT (Thu, 25 Apr 2013)
@@ -6,11 +6,11 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <boost/assert.hpp>
-
 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ASSERT_HPP
 #define BOOST_GEOMETRY_INDEX_DETAIL_ASSERT_HPP
 
+#include <boost/assert.hpp>
+
 #define BOOST_GEOMETRY_INDEX_ASSERT(CONDITION, TEXT_MSG) \
     BOOST_ASSERT_MSG(CONDITION, TEXT_MSG)
 

Added: trunk/boost/geometry/index/detail/exception.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/geometry/index/detail/exception.hpp 2013-04-25 09:55:19 EDT (Thu, 25 Apr 2013)
@@ -0,0 +1,39 @@
+// Boost.Geometry Index
+//
+// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
+//
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_INDEX_DETAIL_EXCEPTION_HPP
+#define BOOST_GEOMETRY_INDEX_DETAIL_EXCEPTION_HPP
+
+#ifndef BOOST_NO_EXCEPTIONS
+#include <stdexcept>
+#else
+#include <cstdlib>
+#endif
+
+namespace boost { namespace geometry { namespace index { namespace detail {
+
+#ifndef BOOST_NO_EXCEPTIONS
+
+inline void throw_runtime_error(const char * str)
+{
+ throw std::runtime_error(str);
+}
+
+#else
+
+inline void throw_runtime_error(const char * str)
+{
+ BOOST_ASSERT_MSG(!"runtime_error thrown", str);
+ std::abort();
+}
+
+#endif
+
+}}}} // namespace boost::geometry::index::detail
+
+#endif // BOOST_GEOMETRY_INDEX_DETAIL_EXCEPTION_HPP

Modified: trunk/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp (original)
+++ trunk/boost/geometry/index/detail/rtree/linear/redistribute_elements.hpp 2013-04-25 09:55:19 EDT (Thu, 25 Apr 2013)
@@ -238,7 +238,7 @@
         elements1.clear();
         BOOST_GEOMETRY_INDEX_ASSERT(elements2.empty(), "unexpected container state");
 
- try
+ BOOST_TRY
         {
             // add seeds
             elements1.push_back(elements_copy[seed1]); // MAY THROW, STRONG (copy)
@@ -314,7 +314,7 @@
                 }
             }
         }
- catch (...)
+ BOOST_CATCH(...)
         {
             elements1.clear();
             elements2.clear();
@@ -322,8 +322,9 @@
             rtree::destroy_elements<Value, Options, Translator, Box, Allocators>::apply(elements_copy, allocators);
             //elements_copy.clear();
 
- throw; // RETHROW, BASIC
+ BOOST_RETHROW // RETHROW, BASIC
         }
+ BOOST_CATCH_END
     }
 };
 

Modified: trunk/boost/geometry/index/detail/rtree/node/node.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/node/node.hpp (original)
+++ trunk/boost/geometry/index/detail/rtree/node/node.hpp 2013-04-25 09:55:19 EDT (Thu, 25 Apr 2013)
@@ -18,13 +18,6 @@
 #include <boost/geometry/index/detail/rtree/node/pairs.hpp>
 #include <boost/geometry/index/detail/rtree/node/auto_deallocator.hpp>
 
-namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree {
-struct node_creation_failed : public std::exception
-{
- const char * what() { return "rtree node creation failed"; }
-};
-}}}}}
-
 #include <boost/geometry/index/detail/rtree/node/dynamic_visitor.hpp>
 #include <boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp>
 #include <boost/geometry/index/detail/rtree/node/node_d_mem_static.hpp>

Modified: trunk/boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp (original)
+++ trunk/boost/geometry/index/detail/rtree/node/node_d_mem_dynamic.hpp 2013-04-25 09:55:19 EDT (Thu, 25 Apr 2013)
@@ -248,7 +248,7 @@
         P p = Al::allocate(alloc_node, 1);
 
         if ( 0 == p )
- throw node_creation_failed();
+ throw_runtime_error("boost::geometry::index::rtree node creation failed");
 
         auto_deallocator<AllocNode> deallocator(alloc_node, p);
 

Modified: trunk/boost/geometry/index/detail/rtree/node/node_s_mem_dynamic.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/node/node_s_mem_dynamic.hpp (original)
+++ trunk/boost/geometry/index/detail/rtree/node/node_s_mem_dynamic.hpp 2013-04-25 09:55:19 EDT (Thu, 25 Apr 2013)
@@ -168,7 +168,7 @@
         P p = Al::allocate(alloc_node, 1);
 
         if ( 0 == p )
- throw node_creation_failed();
+ throw_runtime_error("boost::geometry::index::rtree node creation failed");
 
         auto_deallocator<AllocNode> deallocator(alloc_node, p);
 

Modified: trunk/boost/geometry/index/detail/rtree/quadratic/redistribute_elements.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/quadratic/redistribute_elements.hpp (original)
+++ trunk/boost/geometry/index/detail/rtree/quadratic/redistribute_elements.hpp 2013-04-25 09:55:19 EDT (Thu, 25 Apr 2013)
@@ -125,7 +125,7 @@
         elements1.clear();
         BOOST_GEOMETRY_INDEX_ASSERT(elements2.empty(), "second node's elements container should be empty");
 
- try
+ BOOST_TRY
         {
             // add seeds
             elements1.push_back(elements_copy[seed1]); // MAY THROW, STRONG (copy)
@@ -224,7 +224,7 @@
                 --remaining;
             }
         }
- catch(...)
+ BOOST_CATCH(...)
         {
             //elements_copy.clear();
             elements1.clear();
@@ -233,8 +233,9 @@
             rtree::destroy_elements<Value, Options, Translator, Box, Allocators>::apply(elements_backup, allocators);
             //elements_backup.clear();
 
- throw; // RETHROW, BASIC
+ BOOST_RETHROW // RETHROW, BASIC
         }
+ BOOST_CATCH_END
     }
 
     // TODO: awulkiew - change following function to static member of the pick_next class?

Modified: trunk/boost/geometry/index/detail/rtree/rstar/insert.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/rstar/insert.hpp (original)
+++ trunk/boost/geometry/index/detail/rtree/rstar/insert.hpp 2013-04-25 09:55:19 EDT (Thu, 25 Apr 2013)
@@ -93,7 +93,7 @@
             result_elements.push_back(it->second); // MAY THROW (V, E: copy)
         }
 
- try
+ BOOST_TRY
         {
             // copy remaining elements to the current node
             elements.clear();
@@ -104,7 +104,7 @@
                 elements.push_back(it->second); // MAY THROW (V, E: copy)
             }
         }
- catch(...)
+ BOOST_CATCH(...)
         {
             elements.clear();
 
@@ -114,8 +114,9 @@
                 destroy_element<Value, Options, Translator, Box, Allocators>::apply(it->second, allocators);
             }
 
- throw; // RETHROW
+ BOOST_RETHROW // RETHROW
         }
+ BOOST_CATCH_END
 
         BOOST_GEOMETRY_INDEX_DETAIL_USE_PARAM(parameters)
     }
@@ -285,12 +286,12 @@
         {
             BOOST_GEOMETRY_INDEX_ASSERT(base::m_level == base::m_traverse_data.current_level, "unexpected level");
 
- try
+ BOOST_TRY
             {
                 // push new child node
                 rtree::elements(n).push_back(base::m_element); // MAY THROW, STRONG (E: alloc, copy)
             }
- catch(...)
+ BOOST_CATCH(...)
             {
                 // NOTE: exception-safety
                 // if the insert fails above, the element won't be stored in the tree, so delete it
@@ -298,8 +299,9 @@
                 rtree::visitors::destroy<Value, Options, Translator, Box, Allocators> del_v(base::m_element.second, base::m_allocators);
                 rtree::apply_visitor(del_v, *base::m_element.second);
 
- throw; // RETHROW
+ BOOST_RETHROW // RETHROW
             }
+ BOOST_CATCH_END
 
             // first insert
             if ( 0 == InsertIndex )
@@ -501,17 +503,18 @@
             rstar::level_insert<1, element_type, Value, Options, Translator, Box, Allocators> lins_v(
                 m_root, m_leafs_level, *it, m_parameters, m_translator, m_allocators, relative_level);
 
- try
+ BOOST_TRY
             {
                 rtree::apply_visitor(lins_v, *m_root); // MAY THROW (V, E: alloc, copy, N: alloc)
             }
- catch(...)
+ BOOST_CATCH(...)
             {
                 ++it;
                 for ( ; it != elements.rend() ; ++it)
                     rtree::destroy_element<Value, Options, Translator, Box, Allocators>::apply(*it, m_allocators);
- throw; // RETHROW
+ BOOST_RETHROW // RETHROW
             }
+ BOOST_CATCH_END
 
             BOOST_GEOMETRY_INDEX_ASSERT(relative_level + 1 == lins_v.result_relative_level, "unexpected level");
 

Modified: trunk/boost/geometry/index/detail/rtree/rstar/redistribute_elements.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/rstar/redistribute_elements.hpp (original)
+++ trunk/boost/geometry/index/detail/rtree/rstar/redistribute_elements.hpp 2013-04-25 09:55:19 EDT (Thu, 25 Apr 2013)
@@ -376,7 +376,7 @@
             rstar::partial_sort<max_corner, dimension>
                 ::apply(elements_copy, split_axis, split_index, translator); // MAY THROW, BASIC (copy)
 
- try
+ BOOST_TRY
         {
             // copy elements to nodes
             elements1.assign(elements_copy.begin(), elements_copy.begin() + split_index); // MAY THROW, BASIC
@@ -386,7 +386,7 @@
             box1 = rtree::elements_box<Box>(elements1.begin(), elements1.end(), translator);
             box2 = rtree::elements_box<Box>(elements2.begin(), elements2.end(), translator);
         }
- catch(...)
+ BOOST_CATCH(...)
         {
             //elements_copy.clear();
             elements1.clear();
@@ -395,8 +395,9 @@
             rtree::destroy_elements<Value, Options, Translator, Box, Allocators>::apply(elements_backup, allocators);
             //elements_backup.clear();
 
- throw; // RETHROW, BASIC
+ BOOST_RETHROW // RETHROW, BASIC
         }
+ BOOST_CATCH_END
     }
 };
 

Modified: trunk/boost/geometry/index/detail/rtree/visitors/insert.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/visitors/insert.hpp (original)
+++ trunk/boost/geometry/index/detail/rtree/visitors/insert.hpp 2013-04-25 09:55:19 EDT (Thu, 25 Apr 2013)
@@ -349,14 +349,18 @@
             // create new root and add nodes
             node_auto_ptr new_root(rtree::create_node<Allocators, internal_node>::apply(m_allocators), m_allocators); // MAY THROW, STRONG (N:alloc)
 
- try {
+ BOOST_TRY
+ {
                 rtree::elements(rtree::get<internal_node>(*new_root)).push_back(rtree::make_ptr_pair(n_box, m_root_node)); // MAY THROW, STRONG (E:alloc, copy)
                 rtree::elements(rtree::get<internal_node>(*new_root)).push_back(additional_nodes[0]); // MAY THROW, STRONG (E:alloc, copy)
- } catch (...) {
+ }
+ BOOST_CATCH(...)
+ {
                 // clear new root to not delete in the ~node_auto_ptr() potentially stored old root node
                 rtree::elements(rtree::get<internal_node>(*new_root)).clear();
- throw; // RETHROW
+ BOOST_RETHROW // RETHROW
             }
+ BOOST_CATCH_END
 
             m_root_node = new_root.get();
             ++m_leafs_level;
@@ -431,20 +435,21 @@
         {
             BOOST_GEOMETRY_INDEX_ASSERT(base::m_level == base::m_traverse_data.current_level, "unexpected level");
 
- try
+ BOOST_TRY
             {
                 // push new child node
                 rtree::elements(n).push_back(base::m_element); // MAY THROW, STRONG (E: alloc, copy)
             }
- catch(...)
+ BOOST_CATCH(...)
             {
                 // if the insert fails above, the element won't be stored in the tree
 
                 rtree::visitors::destroy<Value, Options, Translator, Box, Allocators> del_v(base::m_element.second, base::m_allocators);
                 rtree::apply_visitor(del_v, *base::m_element.second);
 
- throw; // RETHROW
+ BOOST_RETHROW // RETHROW
             }
+ BOOST_CATCH_END
         }
 
         base::post_traverse(n); // MAY THROW (E: alloc, copy, N: alloc)

Modified: trunk/boost/geometry/index/detail/rtree/visitors/remove.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/visitors/remove.hpp (original)
+++ trunk/boost/geometry/index/detail/rtree/visitors/remove.hpp 2013-04-25 09:55:19 EDT (Thu, 25 Apr 2013)
@@ -194,16 +194,17 @@
         // move node to the container - store node's relative level as well
         m_underflowed_nodes.push_back(std::make_pair(relative_level, underfl_el_it->second)); // MAY THROW (E: alloc, copy)
 
- try
+ BOOST_TRY
         {
             rtree::move_from_back(elements, underfl_el_it); // MAY THROW (E: copy)
             elements.pop_back();
         }
- catch(...)
+ BOOST_CATCH(...)
         {
             m_underflowed_nodes.pop_back();
- throw; // RETHROW
+ BOOST_RETHROW // RETHROW
         }
+ BOOST_CATCH_END
 
         // calc underflow
         return elements.size() < m_parameters.get_min_elements();
@@ -213,7 +214,7 @@
     {
         typename UnderflowNodes::reverse_iterator it = m_underflowed_nodes.rbegin();
 
- try
+ BOOST_TRY
         {
             // reinsert elements from removed nodes
             // begin with levels closer to the root
@@ -237,7 +238,7 @@
 
             //m_underflowed_nodes.clear();
         }
- catch(...)
+ BOOST_CATCH(...)
         {
             // destroy current and remaining nodes
             for ( ; it != m_underflowed_nodes.rend() ; ++it )
@@ -247,8 +248,9 @@
 
             //m_underflowed_nodes.clear();
 
- throw; // RETHROW
+ BOOST_RETHROW // RETHROW
         }
+ BOOST_CATCH_END
     }
 
     template <typename Node>
@@ -258,7 +260,7 @@
         elements_type & elements = rtree::elements(n);
 
         typename elements_type::iterator it = elements.begin();
- try
+ BOOST_TRY
         {
             for ( ; it != elements.end() ; ++it )
             {
@@ -274,14 +276,15 @@
                 rtree::apply_visitor(insert_v, *m_root_node); // MAY THROW (V, E: alloc, copy, N: alloc)
             }
         }
- catch(...)
+ BOOST_CATCH(...)
         {
             ++it;
             rtree::destroy_elements<Value, Options, Translator, Box, Allocators>
                 ::apply(it, elements.end(), m_allocators);
             elements.clear();
- throw; // RETHROW
+ BOOST_RETHROW // RETHROW
         }
+ BOOST_CATCH_END
     }
 
     Value const& m_value;

Modified: trunk/boost/geometry/index/detail/varray.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/varray.hpp (original)
+++ trunk/boost/geometry/index/detail/varray.hpp 2013-04-25 09:55:19 EDT (Thu, 25 Apr 2013)
@@ -10,7 +10,6 @@
 #define BOOST_GEOMETRY_INDEX_DETAIL_VARRAY_HPP
 
 #include <cstddef>
-#include <stdexcept>
 
 #include <boost/move/move.hpp>
 #include <boost/aligned_storage.hpp>
@@ -531,7 +530,7 @@
     {
         size_type count = 0;
         iterator it = dest;
- try
+ BOOST_TRY
         {
             for ( ; first != last ; ++it, ++first, ++count )
             {
@@ -541,11 +540,12 @@
                 this->uninitialized_fill(it, *first); // may throw
             }
         }
- catch(...)
+ BOOST_CATCH(...)
         {
             this->destroy(dest, it);
- throw;
+ BOOST_RETHROW
         }
+ BOOST_CATCH_END
         return std::make_pair(true, count);
     }
 
@@ -785,16 +785,17 @@
     void uninitialized_move(Iterator first, Iterator last, iterator dst)
     {
         iterator o = dst;
- try
+ BOOST_TRY
         {
             for (; first != last; ++first, ++o )
                 new (boost::addressof(*o)) value_type(boost::move(*first));
         }
- catch(...)
+ BOOST_CATCH(...)
         {
             destroy(dst, o);
- throw;
+ BOOST_RETHROW
         }
+ BOOST_CATCH_END
     }
 
     // construct
@@ -812,16 +813,17 @@
                             boost::false_type const& /*has_trivial_constructor*/)
     {
         iterator it = first;
- try
+ BOOST_TRY
         {
             for ( ; it != last ; ++it )
                 new (&(*it)) value_type(); // may throw
         }
- catch(...)
+ BOOST_CATCH(...)
         {
             this->destroy(first, it);
- throw;
+ BOOST_RETHROW
         }
+ BOOST_CATCH_END
     }
 
     void check_capacity(size_type BOOST_GEOMETRY_INDEX_ASSERT_UNUSED_PARAM(s)) const


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