|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81962 - in sandbox-branches/geometry/index: boost/geometry/extensions/index test
From: adam.wulkiewicz_at_[hidden]
Date: 2012-12-14 18:22:17
Author: awulkiew
Date: 2012-12-14 18:22:16 EST (Fri, 14 Dec 2012)
New Revision: 81962
URL: http://svn.boost.org/trac/boost/changeset/81962
Log:
fixed static_vector error related to construction of values with nontrivial default constructor.
tests added.
Text files modified:
sandbox-branches/geometry/index/boost/geometry/extensions/index/static_vector.hpp | 10 +++++-----
sandbox-branches/geometry/index/test/static_vector.cpp | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 5 deletions(-)
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/static_vector.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/static_vector.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/static_vector.hpp 2012-12-14 18:22:16 EST (Fri, 14 Dec 2012)
@@ -325,8 +325,12 @@
ptr->~value_type();
}
- void construct(value_type * first, value_type * last,
+ void construct(value_type * /*first*/, value_type * /*last*/,
boost::true_type const& /*has_trivial_constructor*/)
+ {}
+
+ void construct(value_type * first, value_type * last,
+ boost::false_type const& /*has_trivial_constructor*/)
{
value_type * it = first;
try
@@ -341,10 +345,6 @@
}
}
- void construct(value_type * /*first*/, value_type * /*last*/,
- boost::false_type const& /*has_trivial_constructor*/)
- {}
-
Value * ptr(size_type i)
{
return (reinterpret_cast<Value*>(m_storage.address()) + i);
Modified: sandbox-branches/geometry/index/test/static_vector.cpp
==============================================================================
--- sandbox-branches/geometry/index/test/static_vector.cpp (original)
+++ sandbox-branches/geometry/index/test/static_vector.cpp 2012-12-14 18:22:16 EST (Fri, 14 Dec 2012)
@@ -48,6 +48,20 @@
int aa;
};
+class counting_value
+{
+public:
+ counting_value(int a = 0) : aa(a) { ++c(); }
+ counting_value(counting_value const& v) : aa(v.aa) { ++c(); }
+ counting_value & operator=(counting_value const& v) { aa = v.aa; return *this; }
+ ~counting_value() { --c(); }
+ bool operator==(counting_value const& v) const { return aa == v.aa; }
+ static size_t count() { return c(); }
+private:
+ static size_t & c() { static size_t co = 0; return co; }
+ int aa;
+};
+
template <typename T, size_t N>
void test_ctor_ndc()
{
@@ -215,26 +229,47 @@
int test_main(int, char* [])
{
+ BOOST_CHECK(counting_value::count() == 0);
+
test_ctor_ndc<int, 10>();
test_ctor_ndc<value_ndc, 10>();
+ test_ctor_ndc<counting_value, 10>();
+ BOOST_CHECK(counting_value::count() == 0);
+
test_ctor_nc<int, 10>(5);
test_ctor_nc<value_nc, 10>(5);
+ test_ctor_nc<counting_value, 10>(5);
+ BOOST_CHECK(counting_value::count() == 0);
+
test_ctor_nd<int, 10>(5, 1);
test_ctor_nd<value_nd, 10>(5, 1);
+ test_ctor_nd<counting_value, 10>(5, 1);
+ BOOST_CHECK(counting_value::count() == 0);
test_resize_nc<int, 10>(5);
test_resize_nc<value_nc, 10>(5);
+ test_resize_nc<counting_value, 10>(5);
+ BOOST_CHECK(counting_value::count() == 0);
+
test_resize_nd<int, 10>(5, 1);
test_resize_nd<value_nd, 10>(5, 1);
+ test_resize_nd<counting_value, 10>(5, 1);
+ BOOST_CHECK(counting_value::count() == 0);
test_push_back_nd<int, 10>();
test_push_back_nd<value_nd, 10>();
+ test_push_back_nd<counting_value, 10>();
+ BOOST_CHECK(counting_value::count() == 0);
test_pop_back_nd<int, 10>();
test_pop_back_nd<value_nd, 10>();
+ test_pop_back_nd<counting_value, 10>();
+ BOOST_CHECK(counting_value::count() == 0);
test_copy_and_assign_nd<int, 10>();
test_copy_and_assign_nd<value_nd, 10>();
+ test_copy_and_assign_nd<counting_value, 10>();
+ BOOST_CHECK(counting_value::count() == 0);
return 0;
}
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