From b3b14171766089890b9e1b44935ed5dbc233c5f8 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 13 Dec 2022 22:03:02 +0300 Subject: Add noexcept to move constructors and move assignment operators --- libbuild2/variable.hxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'libbuild2/variable.hxx') diff --git a/libbuild2/variable.hxx b/libbuild2/variable.hxx index 2942f1c..8a0adf8 100644 --- a/libbuild2/variable.hxx +++ b/libbuild2/variable.hxx @@ -358,9 +358,13 @@ namespace build2 value& operator= (nullptr_t) {if (!null) reset (); return *this;} - value (value&&); + // Note that we have the noexcept specification even though copy_ctor() + // could potentially throw (for example, for std::map). + // + value (value&&) noexcept; + explicit value (const value&); - value& operator= (value&&); + value& operator= (value&&); // Note: can throw for untyped RHS. value& operator= (const value&); value& operator= (reference_wrapper); value& operator= (reference_wrapper); @@ -1859,7 +1863,7 @@ namespace build2 variable_map (const variable_map&, const prerequisite&, bool shared = false); variable_map& - operator= (variable_map&& v) {m_ = move (v.m_); return *this;} + operator= (variable_map&& v) noexcept {m_ = move (v.m_); return *this;} variable_map& operator= (const variable_map& v) {m_ = v.m_; return *this;} @@ -1870,6 +1874,8 @@ namespace build2 variable_map (context& c, bool shared) : shared_ (shared), owner_ (owner::context), ctx (&c) {} + // Note: std::map's move constructor can throw. + // variable_map (variable_map&& v) : shared_ (v.shared_), owner_ (v.owner_), ctx (v.ctx), m_ (move (v.m_)) { -- cgit v1.1