small_vector's initializer list constructor was not implemented and tested.

This commit is contained in:
Ion Gaztañaga
2015-02-28 00:17:46 +01:00
parent 6332a9f0bb
commit 8db0f4ad64
2 changed files with 11 additions and 3 deletions

View File

@@ -445,6 +445,7 @@ class small_vector : public small_vector_base<T, Allocator>
typedef typename base_type::allocator_type allocator_type;
typedef typename base_type::size_type size_type;
typedef typename base_type::value_type value_type;
static std::size_t internal_capacity()
{ return (sizeof(small_vector) - storage_test::s_start)/sizeof(T); }
@@ -485,6 +486,14 @@ class small_vector : public small_vector_base<T, Allocator>
: base_type(initial_capacity_t(), internal_capacity(), a)
{ this->move_construct_impl(other, a); }
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
small_vector(std::initializer_list<value_type> il, const allocator_type& a = allocator_type())
: base_type(initial_capacity_t(), internal_capacity(), a)
{
this->assign(il.begin(), il.end());
}
#endif
small_vector& operator=(BOOST_COPY_ASSIGN_REF(small_vector) other)
{ return static_cast<small_vector&>(this->base_type::operator=(static_cast<base_type const&>(other))); }

View File

@@ -167,9 +167,8 @@ int main()
////////////////////////////////////
// Initializer lists testing
////////////////////////////////////
if(!boost::container::test::test_vector_methods_with_initializer_list_as_argument_for<
boost::container::vector<int>
>()) {
if(!boost::container::test::test_vector_methods_with_initializer_list_as_argument_for
< boost::container::small_vector<int, 5> >()) {
return 1;
}