summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-01-19 20:58:41 +0100
committerMarc Mutz <marc.mutz@kdab.com>2015-02-17 15:05:40 +0000
commit1649b973fd2ecd6c2398387f8bb5d0d768142336 (patch)
tree45820b59c8b0d2fdb80e53565eb4b7dc2f499b00
parentddd61b4aec7d17741faffe988b44c7c0a19ce71f (diff)
QPair: add noexcept to ctors and assignment operators
Change-Id: Id201d1f1e7a087083ca6c13ab31c721e672ef566 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r--src/corelib/tools/qpair.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/corelib/tools/qpair.h b/src/corelib/tools/qpair.h
index aa0a53388c..d637067fa8 100644
--- a/src/corelib/tools/qpair.h
+++ b/src/corelib/tools/qpair.h
@@ -45,22 +45,31 @@ struct QPair
typedef T1 first_type;
typedef T2 second_type;
- Q_DECL_CONSTEXPR QPair() : first(), second() {}
- Q_DECL_CONSTEXPR QPair(const T1 &t1, const T2 &t2) : first(t1), second(t2) {}
+ Q_DECL_CONSTEXPR QPair()
+ Q_DECL_NOEXCEPT_EXPR(noexcept(T1()) && noexcept(T2()))
+ : first(), second() {}
+ Q_DECL_CONSTEXPR QPair(const T1 &t1, const T2 &t2)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(T1(t1)) && noexcept(T2(t2)))
+ : first(t1), second(t2) {}
// compiler-generated copy/move ctor/assignment operators are fine!
template <typename TT1, typename TT2>
- Q_DECL_CONSTEXPR QPair(const QPair<TT1, TT2> &p) : first(p.first), second(p.second) {}
+ Q_DECL_CONSTEXPR QPair(const QPair<TT1, TT2> &p)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(T1(p.first)) && noexcept(T2(p.second)))
+ : first(p.first), second(p.second) {}
template <typename TT1, typename TT2>
Q_DECL_RELAXED_CONSTEXPR QPair &operator=(const QPair<TT1, TT2> &p)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(std::declval<T1&>() = p.first) && noexcept(std::declval<T2&>() = p.second))
{ first = p.first; second = p.second; return *this; }
#ifdef Q_COMPILER_RVALUE_REFS
template <typename TT1, typename TT2>
Q_DECL_CONSTEXPR QPair(QPair<TT1, TT2> &&p)
// can't use std::move here as it's not constexpr in C++11:
+ Q_DECL_NOEXCEPT_EXPR(noexcept(T1(static_cast<TT1 &&>(p.first))) && noexcept(T2(static_cast<TT2 &&>(p.second))))
: first(static_cast<TT1 &&>(p.first)), second(static_cast<TT2 &&>(p.second)) {}
template <typename TT1, typename TT2>
Q_DECL_RELAXED_CONSTEXPR QPair &operator=(QPair<TT1, TT2> &&p)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(std::declval<T1&>() = std::move(p.first)) && noexcept(std::declval<T2&>() = std::move(p.second)))
{ first = std::move(p.first); second = std::move(p.second); return *this; }
#endif