forked from boostorg/container
Add conditional noexcept forwarding from free to member swap functions.
This allows std::is_nothrow_swappable{,_with} to work properly.
This only touches user-facing classes, with the following exceptions:
- map,set: only doc changes (with a drive-by missing semicolon fix),
detail::tree which they derive from already forwards noexcept for swap.
- flat_set: only doc changes for flat_set and a change for
detail::flat_tree, which it derives from to get swap.
- static_vector: while this adds the forwarding, member static_vector::swap
is currently never noexcept, although it could be for noexcept-swappable
and noexcept-move-constructible elements.
- small_vector: there is no free swap, and member swap is never noexcept,
although it could be for noexcept-swappable and noexcept-move-
constructible elements. Swapping small_vectors of exact same type goes
through std::swap, which seems to get noexcept right, and small_vectors
of different sizes use swap for boost::container::vector, which fails
to detect when such swap could be noexcept. This patch doesn't touch
small_vector.
- scoped_allocator: neither member nor free swap are noexcept, although
they should be, and all other constructions/assignments/comparisons too,
as they only forward these operations to underlying allocators, which
are required to not throw exceptions for them. Only static_vector's
static_storage_allocator might throw for these and it shouldn't appear
in scoped_allocator. Unsure of the scope of changes needed or whether it
is even worth it, this patch doesn't touch scoped_allocator.
This commit is contained in:
1 parent
b17dabf47a
commit
cb1e6af53d
13 files changed
+34
-8
No files matched your search
@@ -1169,6 +1169,7 @@ public:
|
||||
#else
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE friend void swap(static_vector &x, static_vector &y)
|
||||
BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT(x.swap(y)))
|
||||
{
|
||||
x.swap(y);
|
||||
}
|
||||
@@ -1275,13 +1276,15 @@ bool operator>= (static_vector<V, C1, O1> const& x, static_vector<V, C2, O2> con
|
||||
//! @par Complexity
|
||||
//! Linear O(N).
|
||||
template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
|
||||
inline void swap(static_vector<V, C1, O1> & x, static_vector<V, C2, O2> & y);
|
||||
inline void swap(static_vector<V, C1, O1> & x, static_vector<V, C2, O2> & y)
|
||||
BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT(x.swap(y)));
|
||||
|
||||
#else
|
||||
|
||||
template<typename V, std::size_t C1, std::size_t C2, class O1, class O2>
|
||||
inline void swap(static_vector<V, C1, O1> & x, static_vector<V, C2, O2> & y
|
||||
, typename dtl::enable_if_c< C1 != C2>::type * = 0)
|
||||
BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT(x.swap(y)))
|
||||
{
|
||||
x.swap(y);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user