From 24f349839fac72b1368ecd5d7ca7f2ef2ea8055b Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sun, 16 Dec 2012 18:45:23 +0000 Subject: [PATCH] Added templated versions of static_vector copy ctor and assignment. GCC compile error fixed in test. [SVN r82028] --- .../extensions/index/static_vector.hpp | 19 ++++++++++++++++++- test/static_vector.cpp | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/extensions/index/static_vector.hpp b/include/boost/geometry/extensions/index/static_vector.hpp index ec7ebafbf..706e240ef 100644 --- a/include/boost/geometry/extensions/index/static_vector.hpp +++ b/include/boost/geometry/extensions/index/static_vector.hpp @@ -75,7 +75,15 @@ public: static_vector(static_vector const& other) : m_size(other.m_size) { - //BOOST_ASSERT_MSG(other.m_size <= Capacity, "size can't exceed the capacity"); + this->uninitialized_copy(other.begin(), other.end(), this->begin()); // may throw + } + + // strong + template + static_vector(static_vector const& other) + : m_size(other.m_size) + { + BOOST_ASSERT_MSG(other.m_size <= Capacity, "size can't exceed the capacity"); //if ( Capacity <= other.m_size ) throw std::bad_alloc(); this->uninitialized_copy(other.begin(), other.end(), this->begin()); // may throw @@ -97,6 +105,15 @@ public: return *this; } + // basic + template + static_vector & operator=(static_vector const& other) + { + assign(other.begin(), other.end()); // may throw + + return *this; + } + // nothrow ~static_vector() { diff --git a/test/static_vector.cpp b/test/static_vector.cpp index bc97dda9f..b45ed1a03 100644 --- a/test/static_vector.cpp +++ b/test/static_vector.cpp @@ -426,7 +426,7 @@ void test_insert_nd(T const& val) for ( size_t i = 0 ; i <= h ; ++i ) { static_vector s1(s); - std::list::iterator it = l.begin(); + typename std::list::iterator it = l.begin(); std::advance(it, n); s1.insert(s1.begin() + i, l.begin(), it); BOOST_CHECK(s1.size() == h+n);