diff --git a/doc/html/geometry_index/introduction.html b/doc/html/geometry_index/introduction.html index dd8b1efc4..aea9c9dc7 100644 --- a/doc/html/geometry_index/introduction.html +++ b/doc/html/geometry_index/introduction.html @@ -3,7 +3,7 @@
rtree<Value, Parameters, Translator, Allocator>-
Value - type of object which will be stored in the container.
std::pair<...>,
pointer, iterator or smart pointer.
-Indexable = Point
| Box
diff --git a/doc/html/geometry_index/r_tree/exception_safety.html b/doc/html/geometry_index/r_tree/exception_safety.html
index c0ec24646..0d19fcbb5 100644
--- a/doc/html/geometry_index/r_tree/exception_safety.html
+++ b/doc/html/geometry_index/r_tree/exception_safety.html
@@ -3,7 +3,7 @@
In order to be exception-safe the R-tree requires:
-CoordinateType
- used in the Indexable,
- Value.
Value.
+ CoordinateType.
+ | @@ -138,7 +140,7 @@ | @@ -151,7 +153,7 @@ | @@ -333,19 +335,19 @@ | ||
|
- [a] + [a]
nothrow - if [b] + [b]
nothrow - if [c] + [c]
nothrow - if allocators are equal and - More + MoreMore information about the R-tree implementation, other algorithms and queries diff --git a/doc/html/geometry_index/r_tree/spatial_queries.html b/doc/html/geometry_index/r_tree/spatial_queries.html index 065642608..0262793d6 100644 --- a/doc/html/geometry_index/r_tree/spatial_queries.html +++ b/doc/html/geometry_index/r_tree/spatial_queries.html @@ -3,7 +3,7 @@
diff --git a/doc/rtree/exception_safety.qbk b/doc/rtree/exception_safety.qbk index fe1f3b91a..f98ec3c15 100644 --- a/doc/rtree/exception_safety.qbk +++ b/doc/rtree/exception_safety.qbk @@ -12,8 +12,9 @@ In order to be exception-safe the __rtree__ requires: -* Nonthrowing copy constructor of the `CoordinateType` used in the `__indexable__`, * Nonthrowing destructor of the `__value__`. +* Exception-safe copy constructor of the `__value__`. +* Exception-safe copy constructor of the `CoordinateType`. [table [[Operation] [exception-safety]] diff --git a/include/boost/geometry/extensions/index/pushable_array.hpp b/include/boost/geometry/extensions/index/pushable_array.hpp index d01a82b81..5e9aad018 100644 --- a/include/boost/geometry/extensions/index/pushable_array.hpp +++ b/include/boost/geometry/extensions/index/pushable_array.hpp @@ -133,23 +133,6 @@ public: m_size = 0; } - // IMPORTANT! - // The sequence of elements is NOT preserved - inline void erase(iterator it) - { - BOOST_GEOMETRY_INDEX_ASSERT(0 < m_size, "there are no elements in the container"); - BOOST_GEOMETRY_INDEX_ASSERT(begin() <= it && it < end(), "iterator points on the element outside the container"); - //std::copy(it + 1, end(), it); - // TODO: leave this code or use copy? - // code below may work differently than one might think about erase() - if ( it != (begin() + (m_size - 1)) ) - { - // NOTE: without this condition assignment may call memcpy with the same 2 addresses - *it = back(); - } - --m_size; - } - inline void push_back(Element const& v) { BOOST_GEOMETRY_INDEX_ASSERT(m_size < Capacity, "can't further increase the size of the container"); diff --git a/include/boost/geometry/extensions/index/rtree/node/node.hpp b/include/boost/geometry/extensions/index/rtree/node/node.hpp index f01cbce03..0b87589fb 100644 --- a/include/boost/geometry/extensions/index/rtree/node/node.hpp +++ b/include/boost/geometry/extensions/index/rtree/node/node.hpp @@ -151,6 +151,18 @@ struct clear_node } }; +template R;
- static R apply(int x, int y)
- {
- return std::make_pair(P(x, y), throwing_value(x + y * 100));
- }
-};
-
#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_TEST_RTREE_EXCEPTIONS_HPP
diff --git a/test/rtree/test_throwing.hpp b/test/rtree/test_throwing.hpp
new file mode 100644
index 000000000..08190d18d
--- /dev/null
+++ b/test/rtree/test_throwing.hpp
@@ -0,0 +1,322 @@
+// Boost.Geometry Index
+//
+// Throwing objects implementation
+//
+// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_TEST_THROWING_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_TEST_THROWING_HPP
+
+// value
+
+struct throwing_value_copy_exception : public std::exception
+{
+ const char * what() const throw() { return "value copy failed."; }
+};
+
+struct throwing_value
+{
+ explicit throwing_value(int v = 0)
+ : value(v)
+ {}
+
+ bool operator==(throwing_value const& v) const
+ {
+ return value == v.value;
+ }
+
+ throwing_value(throwing_value const& v)
+ {
+ throw_if_required();
+
+ value = v.value;
+ }
+
+ throwing_value & operator=(throwing_value const& v)
+ {
+ throw_if_required();
+
+ value = v.value;
+ return *this;
+ }
+
+ void throw_if_required()
+ {
+ // throw if counter meets max count
+ if ( get_max_calls_ref() <= get_calls_counter_ref() )
+ throw throwing_value_copy_exception();
+ else
+ ++get_calls_counter_ref();
+ }
+
+ static void reset_calls_counter() { get_calls_counter_ref() = 0; }
+ static void set_max_calls(size_t mc) { get_max_calls_ref() = mc; }
+
+ static size_t & get_calls_counter_ref() { static size_t cc = 0; return cc; }
+ static size_t & get_max_calls_ref() { static size_t mc = (std::numeric_limits R;
+ static R apply(int x, int y)
+ {
+ return std::make_pair(P(x, y), throwing_value(x + y * 100));
+ }
+};
+
+// box
+//
+//#include B;
//typedef bgi::rtree > RT;
//typedef bgi::rtree RT;
- typedef bgi::rtree > RT;
+ //typedef bgi::rtree > RT;
// typedef bgi::rtree RT;
- //typedef bgi::rtree > RT;
+ typedef bgi::rtree > RT;
//typedef bgi::rtree RT;
for ( ;; )
| ||||