aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2022-12-14 19:36:20 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2022-12-15 10:44:53 +0300
commit5fef9aadd206dce1d0faa984e66a0c3eb12154dd (patch)
tree4fad170647d74e0a590e640b2d47c0782f3a0b26
parent3891eb7aed225ac9f2961c953634682af6f57906 (diff)
Add noexcept to move constructors and move assignment operators
-rw-r--r--odb/database.hxx2
-rw-r--r--odb/details/transfer-ptr.hxx2
-rw-r--r--odb/details/unique-ptr.hxx4
-rw-r--r--odb/lazy-ptr-impl.hxx8
-rw-r--r--odb/lazy-ptr-impl.ixx8
-rw-r--r--odb/lazy-ptr.hxx8
-rw-r--r--odb/lazy-ptr.ixx8
-rw-r--r--odb/vector-impl.hxx4
-rw-r--r--odb/vector-impl.ixx11
-rw-r--r--odb/vector.hxx8
10 files changed, 39 insertions, 24 deletions
diff --git a/odb/database.hxx b/odb/database.hxx
index 485cf52..e18e8ee 100644
--- a/odb/database.hxx
+++ b/odb/database.hxx
@@ -48,6 +48,8 @@ namespace odb
#ifdef ODB_CXX11
//database (database&&) = default; // VC 2013
+ // Note: noexcept is not specified since *_map_ (std::map) can throw.
+ //
database (database&& d)
: id_ (d.id_),
tracer_ (d.tracer_),
diff --git a/odb/details/transfer-ptr.hxx b/odb/details/transfer-ptr.hxx
index 2ee0752..4b63df6 100644
--- a/odb/details/transfer-ptr.hxx
+++ b/odb/details/transfer-ptr.hxx
@@ -49,7 +49,7 @@ namespace odb
transfer_ptr& operator= (const transfer_ptr&);
public:
- transfer_ptr (transfer_ptr&& p): p_ (p.transfer ()) {}
+ transfer_ptr (transfer_ptr&& p) noexcept: p_ (p.transfer ()) {}
#endif
~transfer_ptr () {delete p_;}
diff --git a/odb/details/unique-ptr.hxx b/odb/details/unique-ptr.hxx
index 6663c30..06b2c76 100644
--- a/odb/details/unique-ptr.hxx
+++ b/odb/details/unique-ptr.hxx
@@ -22,8 +22,8 @@ namespace odb
~unique_ptr () {delete p_;}
#ifdef ODB_CXX11
- unique_ptr (unique_ptr&& p): p_ (p.p_) {p.p_ = 0;}
- unique_ptr& operator= (unique_ptr&& p)
+ unique_ptr (unique_ptr&& p) noexcept: p_ (p.p_) {p.p_ = 0;}
+ unique_ptr& operator= (unique_ptr&& p) noexcept
{
if (this != &p)
{
diff --git a/odb/lazy-ptr-impl.hxx b/odb/lazy-ptr-impl.hxx
index 83d6011..89fe798 100644
--- a/odb/lazy-ptr-impl.hxx
+++ b/odb/lazy-ptr-impl.hxx
@@ -44,10 +44,10 @@ namespace odb
//
public:
#ifdef ODB_CXX11
- lazy_ptr_base (lazy_ptr_base&&);
+ lazy_ptr_base (lazy_ptr_base&&) noexcept;
lazy_ptr_base&
- operator= (lazy_ptr_base&&);
+ operator= (lazy_ptr_base&&) noexcept;
#endif
public:
@@ -139,13 +139,13 @@ namespace odb
//
public:
#ifdef ODB_CXX11
- lazy_ptr_impl (lazy_ptr_impl&&);
+ lazy_ptr_impl (lazy_ptr_impl&&) noexcept;
template <typename Y>
lazy_ptr_impl (lazy_ptr_impl<Y>&&);
lazy_ptr_impl&
- operator= (lazy_ptr_impl&&);
+ operator= (lazy_ptr_impl&&) noexcept;
template <typename Y>
lazy_ptr_impl&
diff --git a/odb/lazy-ptr-impl.ixx b/odb/lazy-ptr-impl.ixx
index 7843dc9..9ab0471 100644
--- a/odb/lazy-ptr-impl.ixx
+++ b/odb/lazy-ptr-impl.ixx
@@ -31,7 +31,7 @@ namespace odb
#ifdef ODB_CXX11
inline lazy_ptr_base::
- lazy_ptr_base (lazy_ptr_base&& r)
+ lazy_ptr_base (lazy_ptr_base&& r) noexcept
: id_ (r.id_), db_ (r.db_), loader_ (r.loader_),
free_ (r.free_), copy_ (r.copy_)
{
@@ -78,7 +78,7 @@ namespace odb
#ifdef ODB_CXX11
inline lazy_ptr_base& lazy_ptr_base::
- operator= (lazy_ptr_base&& r)
+ operator= (lazy_ptr_base&& r) noexcept
{
if (id_ != r.id_)
{
@@ -272,7 +272,7 @@ namespace odb
#ifdef ODB_CXX11
template <typename T>
inline lazy_ptr_impl<T>::
- lazy_ptr_impl (lazy_ptr_impl&& r)
+ lazy_ptr_impl (lazy_ptr_impl&& r) noexcept
: lazy_ptr_base (std::move (r))
{
}
@@ -287,7 +287,7 @@ namespace odb
template <typename T>
inline lazy_ptr_impl<T>& lazy_ptr_impl<T>::
- operator= (lazy_ptr_impl&& r)
+ operator= (lazy_ptr_impl&& r) noexcept
{
lazy_ptr_base& b (*this);
b = std::move (r);
diff --git a/odb/lazy-ptr.hxx b/odb/lazy-ptr.hxx
index ae2b43c..ab31dfc 100644
--- a/odb/lazy-ptr.hxx
+++ b/odb/lazy-ptr.hxx
@@ -246,14 +246,14 @@ namespace odb
lazy_unique_ptr (pointer, const deleter_type&) /*noexcept*/;
lazy_unique_ptr (pointer, deleter_type&&) /*noexcept*/;
- lazy_unique_ptr (lazy_unique_ptr&&) /*noexcept*/;
+ lazy_unique_ptr (lazy_unique_ptr&&) noexcept;
template <class T1, class D1> lazy_unique_ptr (lazy_unique_ptr<T1, D1>&&) /*noexcept*/;
//template <class T1> lazy_unique_ptr (std::auto_ptr<T1>&&) /*noexcept*/;
#ifdef ODB_CXX11_NULLPTR
lazy_unique_ptr& operator= (std::nullptr_t) /*noexcept*/;
#endif
- lazy_unique_ptr& operator= (lazy_unique_ptr&&) /*noexcept*/;
+ lazy_unique_ptr& operator= (lazy_unique_ptr&&) noexcept;
template <class T1, class D1> lazy_unique_ptr& operator= (lazy_unique_ptr<T1, D1>&&) /*noexcept*/;
T& operator* () const;
@@ -407,7 +407,7 @@ namespace odb
lazy_shared_ptr (const lazy_shared_ptr&) /*noexcept*/;
template <class Y> lazy_shared_ptr (const lazy_shared_ptr<Y>&) /*noexcept*/;
- lazy_shared_ptr (lazy_shared_ptr&&) /*noexcept*/;
+ lazy_shared_ptr (lazy_shared_ptr&&) noexcept;
template <class Y> lazy_shared_ptr (lazy_shared_ptr<Y>&&) /*noexcept*/;
template <class Y> explicit lazy_shared_ptr (const lazy_weak_ptr<Y>&);
//template <class Y> explicit lazy_shared_ptr (std::auto_ptr<Y>&&);
@@ -417,7 +417,7 @@ namespace odb
lazy_shared_ptr& operator= (const lazy_shared_ptr&) /*noexcept*/;
template <class Y> lazy_shared_ptr& operator= (const lazy_shared_ptr<Y>&) /*noexcept*/;
- lazy_shared_ptr& operator= (lazy_shared_ptr&&) /*noexcept*/;
+ lazy_shared_ptr& operator= (lazy_shared_ptr&&) noexcept;
template <class Y> lazy_shared_ptr& operator= (lazy_shared_ptr<Y>&&) /*noexcept*/;
//template <class Y> lazy_shared_ptr& operator= (std::auto_ptr<Y>&&);
template <class Y, class D> lazy_shared_ptr& operator= (std::unique_ptr<Y, D>&&);
diff --git a/odb/lazy-ptr.ixx b/odb/lazy-ptr.ixx
index 647db83..a2d72f5 100644
--- a/odb/lazy-ptr.ixx
+++ b/odb/lazy-ptr.ixx
@@ -519,7 +519,7 @@ namespace odb
template <class T, class D>
lazy_unique_ptr<T, D>::
- lazy_unique_ptr (lazy_unique_ptr&& r)
+ lazy_unique_ptr (lazy_unique_ptr&& r) noexcept
: p_ (std::move (r.p_)), i_ (std::move (r.i_)) {}
template <class T, class D>
@@ -545,7 +545,7 @@ namespace odb
template <class T, class D>
lazy_unique_ptr<T, D>& lazy_unique_ptr<T, D>::
- operator= (lazy_unique_ptr&& r)
+ operator= (lazy_unique_ptr&& r) noexcept
{
p_ = std::move (r.p_);
i_ = std::move (r.i_);
@@ -922,7 +922,7 @@ namespace odb
template <class T>
inline lazy_shared_ptr<T>::
- lazy_shared_ptr (lazy_shared_ptr&& r)
+ lazy_shared_ptr (lazy_shared_ptr&& r) noexcept
: p_ (std::move (r.p_)), i_ (std::move (r.i_)) {}
template <class T>
@@ -979,7 +979,7 @@ namespace odb
template <class T>
inline lazy_shared_ptr<T>& lazy_shared_ptr<T>::
- operator= (lazy_shared_ptr&& r)
+ operator= (lazy_shared_ptr&& r) noexcept
{
p_ = std::move (r.p_);
i_ = std::move (r.i_);
diff --git a/odb/vector-impl.hxx b/odb/vector-impl.hxx
index 5189395..9f2ea7c 100644
--- a/odb/vector-impl.hxx
+++ b/odb/vector-impl.hxx
@@ -45,7 +45,7 @@ namespace odb
vector_impl (const vector_impl&);
#ifdef ODB_CXX11
- vector_impl (vector_impl&&);
+ vector_impl (vector_impl&&) noexcept;
#endif
void
@@ -195,7 +195,7 @@ namespace odb
vector_base (const vector_base&);
#ifdef ODB_CXX11
- vector_base (vector_base&&);
+ vector_base (vector_base&&) noexcept;
#endif
void
diff --git a/odb/vector-impl.ixx b/odb/vector-impl.ixx
index 3377cb8..1c0ee90 100644
--- a/odb/vector-impl.ixx
+++ b/odb/vector-impl.ixx
@@ -20,7 +20,7 @@ namespace odb
#ifdef ODB_CXX11
inline vector_impl::
- vector_impl (vector_impl&& x)
+ vector_impl (vector_impl&& x) noexcept
: state_ (state_not_tracking),
size_ (0), tail_ (0), capacity_ (0), data_ (0)
{
@@ -167,12 +167,19 @@ namespace odb
#ifdef ODB_CXX11
inline vector_base::
- vector_base (vector_base&& x)
+ vector_base (vector_base&& x) noexcept
: impl_ (std::move (x.impl_)), tran_ (0)
{
if (x.tran_ != 0)
{
x.tran_->callback_unregister (&x);
+
+ // Note that _arm() can potentially throw bad_alloc while adding a new
+ // callback to the callbacks list of the transaction object. However, we
+ // assume that this will not happen since the new callback should be
+ // saved into an existing slot, freed by the above callback_unregister()
+ // call.
+ //
_arm (*x.tran_);
}
}
diff --git a/odb/vector.hxx b/odb/vector.hxx
index ac75ef1..3fe7d8a 100644
--- a/odb/vector.hxx
+++ b/odb/vector.hxx
@@ -91,10 +91,16 @@ namespace odb
{return v_.get_allocator ();}
#ifdef ODB_CXX11
- vector(vector&& x): vector_base (std::move (x)), v_ (std::move (x.v_)) {}
+ vector(vector&& x) noexcept
+ : vector_base (std::move (x)), v_ (std::move (x.v_)) {}
+
vector(const vector& x, const A& a): vector_base (x), v_ (x.v_, a) {}
vector(vector&& x, const A& a)
: vector_base (std::move (x)), v_ (std::move (x.v_), a) {}
+
+ // Note: noexcept is not specified since it can throw while reallocating
+ // impl_.
+ //
vector& operator=(vector&&);
#ifdef ODB_CXX11_INITIALIZER_LIST
vector(std::initializer_list<T> il, const A& a = A()): v_ (il, a) {}