diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2022-12-09 20:00:08 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2022-12-13 14:50:13 +0300 |
commit | c6c224a78715d5e2c532fe318325fbca8e70e701 (patch) | |
tree | dc755313aa482f62ebac15ade66c41a24e908d86 /libbutl/small-list.hxx | |
parent | 8cc86445437e7afc583dee18b36c0e8ba4b6fe12 (diff) |
Add noexcept to move constructors and move assignment operators
Diffstat (limited to 'libbutl/small-list.hxx')
-rw-r--r-- | libbutl/small-list.hxx | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libbutl/small-list.hxx b/libbutl/small-list.hxx index aaeef22..7cb51fd 100644 --- a/libbutl/small-list.hxx +++ b/libbutl/small-list.hxx @@ -4,8 +4,9 @@ #pragma once #include <list> -#include <cstddef> // size_t -#include <utility> // move() +#include <cstddef> // size_t +#include <utility> // move() +#include <type_traits> // is_nothrow_move_constructible #include <libbutl/small-allocator.hxx> @@ -103,14 +104,20 @@ namespace butl return *this; } + // See small_vector for the move-constructor/assignment noexept + // expressions reasoning. + // small_list (small_list&& v) +#if !defined(__GLIBCXX__) && (!defined(_MSC_VER) || _MSC_VER > 1900) + noexcept (std::is_nothrow_move_constructible<T>::value) +#endif : base_type (allocator_type (this)) { *this = std::move (v); // Delegate to operator=(&&). } small_list& - operator= (small_list&& v) + operator= (small_list&& v) noexcept (false) { // libstdc++'s implementation prior to GCC 6 is broken (calls swap()). // Since there is no easy way to determine this library's version, for @@ -122,7 +129,7 @@ namespace butl #if defined(__GLIBCXX__) || (defined(_MSC_VER) && _MSC_VER <= 1900) this->clear (); for (T& x: v) - this->push_back (std::move (x)); + this->push_back (std::move (x)); // Note: can throw bad_alloc. v.clear (); #else // Note: propagate_on_container_move_assignment = false |