Commit 93a55057 authored by Mark Santaniello's avatar Mark Santaniello Committed by Facebook GitHub Bot

Declare small_vector move assign noexcept if possible

Summary:
I think swap() is nothrow as long as value_type is_nothrow_move_constructible.  We already do this on the move c'tor.

(Note: this ignores all push blocking failures!)

Reviewed By: yfeldblum

Differential Revision: D21136202

fbshipit-source-id: a5df772c5cafa592fce95bc5ce4149dc738a984c
parent e66b1036
...@@ -539,7 +539,8 @@ class small_vector : public detail::small_vector_base< ...@@ -539,7 +539,8 @@ class small_vector : public detail::small_vector_base<
return *this; return *this;
} }
small_vector& operator=(small_vector&& o) { small_vector& operator=(small_vector&& o) noexcept(
std::is_nothrow_move_constructible<Value>::value) {
// TODO: optimization: // TODO: optimization:
// if both are internal, use move assignment where possible // if both are internal, use move assignment where possible
if (FOLLY_LIKELY(this != &o)) { if (FOLLY_LIKELY(this != &o)) {
...@@ -618,11 +619,10 @@ class small_vector : public detail::small_vector_base< ...@@ -618,11 +619,10 @@ class small_vector : public detail::small_vector_base<
* Usually one of the simplest functions in a Container-like class * Usually one of the simplest functions in a Container-like class
* but a bit more complex here. We have to handle all combinations * but a bit more complex here. We have to handle all combinations
* of in-place vs. heap between this and o. * of in-place vs. heap between this and o.
*
* Basic guarantee only. Provides the nothrow guarantee iff our
* value_type has a nothrow move or copy constructor.
*/ */
void swap(small_vector& o) { void swap(small_vector& o) noexcept(
std::is_nothrow_move_constructible<Value>::value&&
IsNothrowSwappable<Value>::value) {
using std::swap; // Allow ADL on swap for our value_type. using std::swap; // Allow ADL on swap for our value_type.
if (this->isExtern() && o.isExtern()) { if (this->isExtern() && o.isExtern()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment