Revised noexcept expressions of default and move constructors in all containers.

This commit is contained in:
Ion Gaztañaga
2016-08-01 23:49:51 +02:00
parent b6d3906895
commit 225e2da77e
15 changed files with 75 additions and 43 deletions

View File

@@ -1220,6 +1220,9 @@ use [*Boost.Container]? There are several reasons for that:
* [@https://svn.boost.org/trac/boost/ticket/12177 Trac #12177: ['"vector::priv_merge uses unqualified uintptr_t"]].
* [@https://svn.boost.org/trac/boost/ticket/12183 Trac #12183: ['"GCC 6.1 thinks boost::container::string violates strict aliasing"]].
* [@https://svn.boost.org/trac/boost/ticket/12286 Trac #12286: ['"PMR flat_map from Boost Container does not compile"]].
* [@https://svn.boost.org/trac/boost/ticket/12286 Trac #12319: ['"boost::container::flat_set` should be nothrow move constructible"]].
* Revised noexcept expressions of default and move constructors in all containers.
[endsect]

View File

@@ -535,7 +535,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: If allocator_type's default constructor throws.
//!
//! <b>Complexity</b>: Constant.
deque()
deque() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value)
: Base()
{}
@@ -707,7 +707,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: If allocator_type's copy constructor throws.
//!
//! <b>Complexity</b>: Constant.
deque(BOOST_RV_REF(deque) x)
deque(BOOST_RV_REF(deque) x) BOOST_NOEXCEPT_OR_NOTHROW
: Base(BOOST_MOVE_BASE(Base, x))
{ this->swap_members(x); }

View File

@@ -221,6 +221,7 @@ class flat_tree
{ }
flat_tree(BOOST_RV_REF(flat_tree) x)
BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible<Compare>::value)
: m_data(boost::move(x.m_data))
{ }
@@ -269,8 +270,9 @@ class flat_tree
{ m_data = x.m_data; return *this; }
flat_tree& operator=(BOOST_RV_REF(flat_tree) x)
BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
&& boost::container::container_detail::is_nothrow_move_assignable<Compare>::value )
BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
allocator_traits_type::is_always_equal::value) &&
boost::container::container_detail::is_nothrow_move_assignable<Compare>::value)
{ m_data = boost::move(x.m_data); return *this; }
public:

View File

@@ -612,6 +612,7 @@ class tree
}
tree(BOOST_RV_REF(tree) x)
BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible<Compare>::value)
: AllocHolder(BOOST_MOVE_BASE(AllocHolder, x), x.value_comp())
{}
@@ -669,8 +670,9 @@ class tree
}
tree& operator=(BOOST_RV_REF(tree) x)
BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
&& boost::container::container_detail::is_nothrow_move_assignable<Compare>::value )
BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
allocator_traits_type::is_always_equal::value) &&
boost::container::container_detail::is_nothrow_move_assignable<Compare>::value)
{
BOOST_ASSERT(this != &x);
NodeAlloc &this_alloc = this->node_alloc();

View File

@@ -183,7 +183,8 @@ class flat_map
//! <b>Effects</b>: Default constructs an empty flat_map.
//!
//! <b>Complexity</b>: Constant.
flat_map()
flat_map() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value &&
container_detail::is_nothrow_default_constructible<Compare>::value)
: m_flat_tree()
{
//A type must be std::pair<Key, T>
@@ -319,6 +320,7 @@ class flat_map
//!
//! <b>Postcondition</b>: x is emptied.
flat_map(BOOST_RV_REF(flat_map) x)
BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible<Compare>::value)
: m_flat_tree(boost::move(x.m_flat_tree))
{
//A type must be std::pair<Key, T>
@@ -362,8 +364,9 @@ class flat_map
//! propagate_on_container_move_assignment is true or
//! this->get>allocator() == x.get_allocator(). Linear otherwise.
flat_map& operator=(BOOST_RV_REF(flat_map) x)
BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
&& boost::container::container_detail::is_nothrow_move_assignable<Compare>::value )
BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
allocator_traits_type::is_always_equal::value) &&
boost::container::container_detail::is_nothrow_move_assignable<Compare>::value)
{ m_flat_tree = boost::move(x.m_flat_tree); return *this; }
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
@@ -1208,7 +1211,8 @@ class flat_multimap
//! <b>Effects</b>: Default constructs an empty flat_map.
//!
//! <b>Complexity</b>: Constant.
flat_multimap()
flat_multimap() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value &&
container_detail::is_nothrow_default_constructible<Compare>::value)
: m_flat_tree()
{
//A type must be std::pair<Key, T>
@@ -1343,6 +1347,7 @@ class flat_multimap
//!
//! <b>Postcondition</b>: x is emptied.
flat_multimap(BOOST_RV_REF(flat_multimap) x)
BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible<Compare>::value)
: m_flat_tree(boost::move(x.m_flat_tree))
{
//A type must be std::pair<Key, T>
@@ -1380,8 +1385,9 @@ class flat_multimap
//!
//! <b>Complexity</b>: Constant.
flat_multimap& operator=(BOOST_RV_REF(flat_multimap) x)
BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
&& boost::container::container_detail::is_nothrow_move_assignable<Compare>::value )
BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
allocator_traits_type::is_always_equal::value) &&
boost::container::container_detail::is_nothrow_move_assignable<Compare>::value)
{ m_flat_tree = boost::move(x.m_flat_tree); return *this; }
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)

View File

@@ -112,7 +112,8 @@ class flat_set
//! <b>Effects</b>: Default constructs an empty container.
//!
//! <b>Complexity</b>: Constant.
explicit flat_set()
explicit flat_set() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value &&
container_detail::is_nothrow_default_constructible<Compare>::value)
: base_t()
{}
@@ -220,6 +221,7 @@ class flat_set
//!
//! <b>Postcondition</b>: x is emptied.
flat_set(BOOST_RV_REF(flat_set) x)
BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible<Compare>::value)
: base_t(BOOST_MOVE_BASE(base_t, x))
{}
@@ -251,8 +253,9 @@ class flat_set
//! propagate_on_container_move_assignment is true or
//! this->get>allocator() == x.get_allocator(). Linear otherwise.
flat_set& operator=(BOOST_RV_REF(flat_set) x)
BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
&& boost::container::container_detail::is_nothrow_move_assignable<Compare>::value )
BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
allocator_traits_type::is_always_equal::value) &&
boost::container::container_detail::is_nothrow_move_assignable<Compare>::value)
{ return static_cast<flat_set&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
@@ -898,7 +901,8 @@ class flat_multiset
typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator;
//! @copydoc ::boost::container::flat_set::flat_set()
explicit flat_multiset()
explicit flat_multiset() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value &&
container_detail::is_nothrow_default_constructible<Compare>::value)
: base_t()
{}
@@ -969,6 +973,7 @@ class flat_multiset
//! @copydoc ::boost::container::flat_set::flat_set(flat_set &&)
flat_multiset(BOOST_RV_REF(flat_multiset) x)
BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible<Compare>::value)
: base_t(boost::move(static_cast<base_t&>(x)))
{}
@@ -988,8 +993,9 @@ class flat_multiset
//! @copydoc ::boost::container::flat_set::operator=(flat_set &&)
flat_multiset& operator=(BOOST_RV_REF(flat_multiset) x)
BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
&& boost::container::container_detail::is_nothrow_move_assignable<Compare>::value )
BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
allocator_traits_type::is_always_equal::value) &&
boost::container::container_detail::is_nothrow_move_assignable<Compare>::value)
{ return static_cast<flat_multiset&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)

View File

@@ -188,7 +188,7 @@ class list
//! <b>Throws</b>: If allocator_type's default constructor throws.
//!
//! <b>Complexity</b>: Constant.
list()
list() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value)
: AllocHolder()
{}
@@ -250,7 +250,7 @@ class list
//! <b>Throws</b>: If allocator_type's copy constructor throws.
//!
//! <b>Complexity</b>: Constant.
list(BOOST_RV_REF(list) x)
list(BOOST_RV_REF(list) x) BOOST_NOEXCEPT_OR_NOTHROW
: AllocHolder(BOOST_MOVE_BASE(AllocHolder, x))
{}

View File

@@ -132,7 +132,8 @@ class map
//! <b>Effects</b>: Default constructs an empty map.
//!
//! <b>Complexity</b>: Constant.
map()
map() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value &&
container_detail::is_nothrow_default_constructible<Compare>::value)
: base_t()
{
//A type must be std::pair<CONST Key, T>
@@ -266,6 +267,7 @@ class map
//!
//! <b>Postcondition</b>: x is emptied.
map(BOOST_RV_REF(map) x)
BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible<Compare>::value)
: base_t(BOOST_MOVE_BASE(base_t, x))
{
//A type must be std::pair<CONST Key, T>
@@ -310,9 +312,9 @@ class map
//! propagate_on_container_move_assignment is true or
//! this->get>allocator() == x.get_allocator(). Linear otherwise.
map& operator=(BOOST_RV_REF(map) x)
BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
&& boost::container::container_detail::is_nothrow_move_assignable<Compare>::value )
BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
allocator_traits_type::is_always_equal::value) &&
boost::container::container_detail::is_nothrow_move_assignable<Compare>::value)
{ return static_cast<map&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
@@ -957,7 +959,8 @@ class multimap
//! <b>Effects</b>: Default constructs an empty multimap.
//!
//! <b>Complexity</b>: Constant.
multimap()
multimap() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value &&
container_detail::is_nothrow_default_constructible<Compare>::value)
: base_t()
{
//A type must be std::pair<CONST Key, T>
@@ -1088,6 +1091,7 @@ class multimap
//!
//! <b>Postcondition</b>: x is emptied.
multimap(BOOST_RV_REF(multimap) x)
BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible<Compare>::value)
: base_t(BOOST_MOVE_BASE(base_t, x))
{
//A type must be std::pair<CONST Key, T>
@@ -1126,8 +1130,9 @@ class multimap
//!
//! <b>Complexity</b>: Constant.
multimap& operator=(BOOST_RV_REF(multimap) x)
BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
&& boost::container::container_detail::is_nothrow_move_assignable<Compare>::value )
BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
allocator_traits_type::is_always_equal::value) &&
boost::container::container_detail::is_nothrow_move_assignable<Compare>::value)
{ return static_cast<multimap&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)

View File

@@ -110,7 +110,8 @@ class set
//! <b>Effects</b>: Default constructs an empty set.
//!
//! <b>Complexity</b>: Constant.
set()
set() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value &&
container_detail::is_nothrow_default_constructible<Compare>::value)
: base_t()
{}
@@ -215,6 +216,7 @@ class set
//!
//! <b>Postcondition</b>: x is emptied.
set(BOOST_RV_REF(set) x)
BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible<Compare>::value)
: base_t(BOOST_MOVE_BASE(base_t, x))
{}
@@ -248,8 +250,9 @@ class set
//! propagate_on_container_move_assignment is true or
//! this->get>allocator() == x.get_allocator(). Linear otherwise.
set& operator=(BOOST_RV_REF(set) x)
BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
&& boost::container::container_detail::is_nothrow_move_assignable<Compare>::value )
BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
allocator_traits_type::is_always_equal::value) &&
boost::container::container_detail::is_nothrow_move_assignable<Compare>::value)
{ return static_cast<set&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
@@ -787,7 +790,8 @@ class multiset
//////////////////////////////////////////////
//! @copydoc ::boost::container::set::set()
multiset()
multiset() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value &&
container_detail::is_nothrow_default_constructible<Compare>::value)
: base_t()
{}
@@ -856,6 +860,7 @@ class multiset
//! @copydoc ::boost::container::set::set(set &&)
multiset(BOOST_RV_REF(multiset) x)
BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible<Compare>::value)
: base_t(BOOST_MOVE_BASE(base_t, x))
{}
@@ -875,8 +880,9 @@ class multiset
//! @copydoc ::boost::container::set::operator=(set &&)
multiset& operator=(BOOST_RV_REF(multiset) x)
BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
&& boost::container::container_detail::is_nothrow_move_assignable<Compare>::value )
BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
allocator_traits_type::is_always_equal::value) &&
boost::container::container_detail::is_nothrow_move_assignable<Compare>::value)
{ return static_cast<multiset&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)

View File

@@ -216,7 +216,7 @@ class slist
//! <b>Throws</b>: If allocator_type's copy constructor throws.
//!
//! <b>Complexity</b>: Constant.
slist()
slist() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value)
: AllocHolder()
{}
@@ -303,7 +303,7 @@ class slist
//! <b>Throws</b>: If allocator_type's copy constructor throws.
//!
//! <b>Complexity</b>: Constant.
slist(BOOST_RV_REF(slist) x)
slist(BOOST_RV_REF(slist) x) BOOST_NOEXCEPT_OR_NOTHROW
: AllocHolder(BOOST_MOVE_BASE(AllocHolder, x))
{}

View File

@@ -504,6 +504,7 @@ class small_vector : public small_vector_base<T, Allocator>
public:
BOOST_CONTAINER_FORCEINLINE small_vector()
BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value)
: base_type(initial_capacity_t(), internal_capacity())
{}
@@ -531,12 +532,12 @@ class small_vector : public small_vector_base<T, Allocator>
: base_type(initial_capacity_t(), internal_capacity())
{ this->resize(n, v); }
small_vector(size_type n, const value_type &v, const allocator_type &a)
BOOST_CONTAINER_FORCEINLINE small_vector(size_type n, const value_type &v, const allocator_type &a)
: base_type(initial_capacity_t(), internal_capacity(), a)
{ this->resize(n, v); }
template <class InIt>
small_vector(InIt first, InIt last
BOOST_CONTAINER_FORCEINLINE small_vector(InIt first, InIt last
BOOST_CONTAINER_DOCIGN(BOOST_MOVE_I typename container_detail::disable_if_c
< container_detail::is_convertible<InIt BOOST_MOVE_I size_type>::value
BOOST_MOVE_I container_detail::nat >::type * = 0)

View File

@@ -540,7 +540,7 @@ class stable_vector
//! <b>Throws</b>: If allocator_type's default constructor throws.
//!
//! <b>Complexity</b>: Constant.
stable_vector()
stable_vector() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value)
: internal_data(), index()
{
STABLE_VECTOR_CHECK_INVARIANT;
@@ -698,7 +698,7 @@ class stable_vector
//! <b>Throws</b>: If allocator_type's copy constructor throws.
//!
//! <b>Complexity</b>: Constant.
stable_vector(BOOST_RV_REF(stable_vector) x)
stable_vector(BOOST_RV_REF(stable_vector) x) BOOST_NOEXCEPT_OR_NOTHROW
: internal_data(boost::move(x.priv_node_alloc())), index(boost::move(x.index))
{
this->priv_swap_members(x);

View File

@@ -276,6 +276,7 @@ public:
//! @par Complexity
//! Linear O(N).
BOOST_CONTAINER_FORCEINLINE static_vector(BOOST_RV_REF(static_vector) other)
BOOST_NOEXCEPT_IF(boost::container::container_detail::is_nothrow_move_constructible<value_type>::value)
: base_t(BOOST_MOVE_BASE(base_t, other))
{}

View File

@@ -591,7 +591,7 @@ class basic_string
//! <b>Effects</b>: Default constructs a basic_string.
//!
//! <b>Throws</b>: If allocator_type's default constructor throws.
basic_string()
basic_string() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value)
: base_t()
{ this->priv_terminate_string(); }

View File

@@ -792,7 +792,7 @@ class vector
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
vector() BOOST_NOEXCEPT_OR_NOTHROW
vector() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value)
: m_holder()
{}