Added templated versions of static_vector copy ctor and assignment.

GCC compile error fixed in test.

[SVN r82028]
This commit is contained in:
Adam Wulkiewicz
2012-12-16 18:45:23 +00:00
parent 32fbcf66ed
commit 24f349839f
2 changed files with 19 additions and 2 deletions

View File

@@ -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 <size_t C>
static_vector(static_vector<value_type, C> 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 <size_t C>
static_vector & operator=(static_vector<value_type, C> const& other)
{
assign(other.begin(), other.end()); // may throw
return *this;
}
// nothrow
~static_vector()
{

View File

@@ -426,7 +426,7 @@ void test_insert_nd(T const& val)
for ( size_t i = 0 ; i <= h ; ++i )
{
static_vector<T, N> s1(s);
std::list<T>::iterator it = l.begin();
typename std::list<T>::iterator it = l.begin();
std::advance(it, n);
s1.insert(s1.begin() + i, l.begin(), it);
BOOST_CHECK(s1.size() == h+n);