[libcxx] r348847 - [pair] Mark constructors as conditionally noexcept

Louis Dionne ldionne at apple.com
Tue Dec 11 06:22:28 PST 2018


Author: ldionne
Date: Tue Dec 11 06:22:28 2018
New Revision: 348847

URL: http://llvm.org/viewvc/llvm-project?rev=348847&view=rev
Log:
[pair] Mark constructors as conditionally noexcept

Summary:
std::tuple marks its constructors as noexcept when the corresponding
memberwise constructors are noexcept too -- this commit improves std::pair
so that it behaves the same.

This is a re-application of r348824, which broke the build in C++03 mode
because a test was marked as supported in C++03 when it shouldn't be.

Note:
I did not add support in the explicit and non-explicit `pair(_Tuple&& __p)`
constructors because those are non-standard extensions, and supporting them
properly is tedious (we have to copy the rvalue-referenceness of the deduced
_Tuple&& onto the result of tuple_element).

<rdar://problem/29537079>

Reviewers: mclow.lists, EricWF

Subscribers: christof, llvm-commits

Differential Revision: https://reviews.llvm.org/D48669

Added:
    libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/U_V.pass.cpp
    libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp
    libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp
    libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/default.pass.cpp
    libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp
    libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp
Modified:
    libcxx/trunk/include/utility
    libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp
    libcxx/trunk/test/support/archetypes.hpp
    libcxx/trunk/test/support/archetypes.ipp

Modified: libcxx/trunk/include/utility
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=348847&r1=348846&r2=348847&view=diff
==============================================================================
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Tue Dec 11 06:22:28 2018
@@ -409,13 +409,17 @@ struct _LIBCPP_TEMPLATE_VIS pair
             _CheckArgsDep<_Dummy>::template __enable_default<_T1, _T2>()
     > = false>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-    pair() : first(), second() {}
+    pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value &&
+                      is_nothrow_default_constructible<second_type>::value)
+        : first(), second() {}
 
     template <bool _Dummy = true, _EnableB<
              _CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>()
     > = false>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     explicit pair(_T1 const& __t1, _T2 const& __t2)
+        _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
+                   is_nothrow_copy_constructible<second_type>::value)
         : first(__t1), second(__t2) {}
 
     template<bool _Dummy = true, _EnableB<
@@ -423,6 +427,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
     > = false>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     pair(_T1 const& __t1, _T2 const& __t2)
+        _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value &&
+                   is_nothrow_copy_constructible<second_type>::value)
         : first(__t1), second(__t2) {}
 
     template<class _U1, class _U2, _EnableB<
@@ -430,6 +436,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
     > = false>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     explicit pair(_U1&& __u1, _U2&& __u2)
+        _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
+                    is_nothrow_constructible<second_type, _U2>::value))
         : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {}
 
     template<class _U1, class _U2, _EnableB<
@@ -437,6 +445,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
     > = false>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     pair(_U1&& __u1, _U2&& __u2)
+        _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
+                    is_nothrow_constructible<second_type, _U2>::value))
         : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {}
 
     template<class _U1, class _U2, _EnableB<
@@ -444,6 +454,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
     > = false>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     explicit pair(pair<_U1, _U2> const& __p)
+        _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
+                    is_nothrow_constructible<second_type, _U2 const&>::value))
         : first(__p.first), second(__p.second) {}
 
     template<class _U1, class _U2, _EnableB<
@@ -451,6 +463,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
     > = false>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     pair(pair<_U1, _U2> const& __p)
+        _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
+                    is_nothrow_constructible<second_type, _U2 const&>::value))
         : first(__p.first), second(__p.second) {}
 
     template<class _U1, class _U2, _EnableB<
@@ -458,6 +472,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
     > = false>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     explicit pair(pair<_U1, _U2>&&__p)
+        _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
+                    is_nothrow_constructible<second_type, _U2&&>::value))
         : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {}
 
     template<class _U1, class _U2, _EnableB<
@@ -465,6 +481,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
     > = false>
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
     pair(pair<_U1, _U2>&& __p)
+        _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
+                    is_nothrow_constructible<second_type, _U2&&>::value))
         : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {}
 
     template<class _Tuple, _EnableB<
@@ -487,6 +505,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
     _LIBCPP_INLINE_VISIBILITY
     pair(piecewise_construct_t __pc,
          tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)
+        _NOEXCEPT_((is_nothrow_constructible<first_type, _Args1...>::value &&
+                    is_nothrow_constructible<second_type, _Args2...>::value))
         : pair(__pc, __first_args, __second_args,
                 typename __make_tuple_indices<sizeof...(_Args1)>::type(),
                 typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}

Added: libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/U_V.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/U_V.pass.cpp?rev=348847&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/U_V.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/U_V.pass.cpp Tue Dec 11 06:22:28 2018
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template<class U, class V> pair(U&& x, V&& y);
+
+#include <utility>
+
+
+struct ExplicitT {
+    constexpr explicit ExplicitT(int x) : value(x) {}
+    int value;
+};
+
+struct ImplicitT {
+    constexpr ImplicitT(int x) : value(x) {}
+    int value;
+};
+
+struct ExplicitNothrowT {
+    explicit ExplicitNothrowT(int x) noexcept : value(x) {}
+    int value;
+};
+
+struct ImplicitNothrowT {
+    ImplicitNothrowT(int x) noexcept : value(x) {}
+    int value;
+};
+
+int main() {
+    { // explicit noexcept test
+        static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitT>, int, int>::value, "");
+        static_assert(!std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitT>, int, int>::value, "");
+        static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitNothrowT>, int, int>::value, "");
+        static_assert( std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitNothrowT>, int, int>::value, "");
+    }
+    { // implicit noexcept test
+        static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitT>, int, int>::value, "");
+        static_assert(!std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitT>, int, int>::value, "");
+        static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitNothrowT>, int, int>::value, "");
+        static_assert( std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitNothrowT>, int, int>::value, "");
+    }
+}

Added: libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp?rev=348847&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/const_first_const_second.pass.cpp Tue Dec 11 06:22:28 2018
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// pair(const T1& x, const T2& y);
+
+#include <utility>
+
+
+struct ExplicitT {
+    constexpr explicit ExplicitT(int x) : value(x) {}
+    constexpr explicit ExplicitT(ExplicitT const& o) : value(o.value) {}
+    int value;
+};
+
+struct ImplicitT {
+    constexpr ImplicitT(int x) : value(x) {}
+    constexpr ImplicitT(ImplicitT const& o) : value(o.value) {}
+    int value;
+};
+
+struct ExplicitNothrowT {
+    explicit ExplicitNothrowT(ExplicitNothrowT const&) noexcept {}
+};
+
+struct ImplicitNothrowT {
+    ImplicitNothrowT(ImplicitNothrowT const&) noexcept {}
+};
+
+int main() {
+    { // explicit noexcept test
+        static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitT>,
+                                                     ExplicitT const&, ExplicitT const&>::value, "");
+        static_assert(!std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitT>,
+                                                     ExplicitNothrowT const&, ExplicitT const&>::value, "");
+        static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitNothrowT>,
+                                                     ExplicitT const&, ExplicitNothrowT const&>::value, "");
+        static_assert( std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitNothrowT>,
+                                                     ExplicitNothrowT const&, ExplicitNothrowT const&>::value, "");
+    }
+    { // implicit noexcept test
+        static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitT>,
+                                                     ImplicitT const&, ImplicitT const&>::value, "");
+        static_assert(!std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitT>,
+                                                     ImplicitNothrowT const&, ImplicitT const&>::value, "");
+        static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitNothrowT>,
+                                                     ImplicitT const&, ImplicitNothrowT const&>::value, "");
+        static_assert( std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitNothrowT>,
+                                                     ImplicitNothrowT const&, ImplicitNothrowT const&>::value, "");
+    }
+}

Added: libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp?rev=348847&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/const_pair_U_V.pass.cpp Tue Dec 11 06:22:28 2018
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class U, class V> EXPLICIT constexpr pair(const pair<U, V>& p);
+
+#include <utility>
+
+
+struct ExplicitT {
+    constexpr explicit ExplicitT(int x) : value(x) {}
+    constexpr explicit ExplicitT(ExplicitT const& o) : value(o.value) {}
+    int value;
+};
+
+struct ImplicitT {
+    constexpr ImplicitT(int x) : value(x) {}
+    constexpr ImplicitT(ImplicitT const& o) : value(o.value) {}
+    int value;
+};
+
+struct ExplicitNothrowT {
+    explicit ExplicitNothrowT(int x) noexcept : value(x) {}
+    int value;
+};
+
+struct ImplicitNothrowT {
+    ImplicitNothrowT(int x) noexcept : value(x) {}
+    int value;
+};
+
+int main() {
+    { // explicit noexcept test
+        static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitT>,
+                                                     std::pair<int, int> const&>::value, "");
+        static_assert(!std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitT>,
+                                                     std::pair<int, int> const&>::value, "");
+        static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitNothrowT>,
+                                                     std::pair<int, int> const&>::value, "");
+        static_assert( std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitNothrowT>,
+                                                     std::pair<int, int> const&>::value, "");
+    }
+    { // implicit noexcept test
+        static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitT>,
+                                                     std::pair<int, int> const&>::value, "");
+        static_assert(!std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitT>,
+                                                     std::pair<int, int> const&>::value, "");
+        static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitNothrowT>,
+                                                     std::pair<int, int> const&>::value, "");
+        static_assert( std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitNothrowT>,
+                                                     std::pair<int, int> const&>::value, "");
+    }
+}

Added: libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/default.pass.cpp?rev=348847&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/default.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/default.pass.cpp Tue Dec 11 06:22:28 2018
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// constexpr pair();
+
+#include <utility>
+#include <type_traits>
+
+#include "archetypes.hpp"
+
+
+int main() {
+    using NonThrowingDefault = NonThrowingTypes::DefaultOnly;
+    using ThrowingDefault = NonTrivialTypes::DefaultOnly;
+    static_assert(!std::is_nothrow_default_constructible<std::pair<ThrowingDefault, ThrowingDefault>>::value, "");
+    static_assert(!std::is_nothrow_default_constructible<std::pair<NonThrowingDefault, ThrowingDefault>>::value, "");
+    static_assert(!std::is_nothrow_default_constructible<std::pair<ThrowingDefault, NonThrowingDefault>>::value, "");
+    static_assert( std::is_nothrow_default_constructible<std::pair<NonThrowingDefault, NonThrowingDefault>>::value, "");
+}

Added: libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp?rev=348847&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp Tue Dec 11 06:22:28 2018
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class... Args1, class... Args2>
+//     pair(piecewise_construct_t, tuple<Args1...> first_args,
+//                                 tuple<Args2...> second_args);
+
+#include <tuple>
+#include <type_traits>
+#include <utility>
+
+#include "archetypes.hpp"
+
+
+int main() {
+    using NonThrowingConvert = NonThrowingTypes::ConvertingType;
+    using ThrowingConvert = NonTrivialTypes::ConvertingType;
+    static_assert(!std::is_nothrow_constructible<std::pair<ThrowingConvert, ThrowingConvert>,
+                                                 std::piecewise_construct_t, std::tuple<int, int>, std::tuple<long, long>>::value, "");
+    static_assert(!std::is_nothrow_constructible<std::pair<NonThrowingConvert, ThrowingConvert>,
+                                                 std::piecewise_construct_t, std::tuple<int, int>, std::tuple<long, long>>::value, "");
+    static_assert(!std::is_nothrow_constructible<std::pair<ThrowingConvert, NonThrowingConvert>,
+                                                 std::piecewise_construct_t, std::tuple<int, int>, std::tuple<long, long>>::value, "");
+    static_assert( std::is_nothrow_constructible<std::pair<NonThrowingConvert, NonThrowingConvert>,
+                                                 std::piecewise_construct_t, std::tuple<int, int>, std::tuple<long, long>>::value, "");
+}

Added: libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp?rev=348847&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp (added)
+++ libcxx/trunk/test/libcxx/utilities/utility/pairs/pairs.pair/rv_pair_U_V.pass.cpp Tue Dec 11 06:22:28 2018
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <utility>
+
+// template <class T1, class T2> struct pair
+
+// template <class U, class V> pair(pair<U, V>&& p);
+
+#include <type_traits>
+#include <utility>
+
+
+struct ExplicitT {
+    constexpr explicit ExplicitT(int x) : value(x) {}
+    int value;
+};
+
+struct ImplicitT {
+    constexpr ImplicitT(int x) : value(x) {}
+    int value;
+};
+
+struct ExplicitNothrowT {
+    explicit ExplicitNothrowT(int x) noexcept : value(x) {}
+    int value;
+};
+
+struct ImplicitNothrowT {
+    ImplicitNothrowT(int x) noexcept : value(x) {}
+    int value;
+};
+
+int main() {
+    { // explicit noexcept test
+        static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitT>,
+                                                     std::pair<int, int>&&>::value, "");
+        static_assert(!std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitT>,
+                                                     std::pair<int, int>&&>::value, "");
+        static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitNothrowT>,
+                                                     std::pair<int, int>&&>::value, "");
+        static_assert( std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitNothrowT>,
+                                                     std::pair<int, int>&&>::value, "");
+    }
+    { // implicit noexcept test
+        static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitT>,
+                                                     std::pair<int, int>&&>::value, "");
+        static_assert(!std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitT>,
+                                                     std::pair<int, int>&&>::value, "");
+        static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitNothrowT>,
+                                                     std::pair<int, int>&&>::value, "");
+        static_assert( std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitNothrowT>,
+                                                     std::pair<int, int>&&>::value, "");
+    }
+}

Modified: libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp?rev=348847&r1=348846&r2=348847&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/piecewise.pass.cpp Tue Dec 11 06:22:28 2018
@@ -17,9 +17,10 @@
 //     pair(piecewise_construct_t, tuple<Args1...> first_args,
 //                                 tuple<Args2...> second_args);
 
-#include <utility>
-#include <tuple>
 #include <cassert>
+#include <tuple>
+#include <utility>
+
 
 int main()
 {

Modified: libcxx/trunk/test/support/archetypes.hpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/archetypes.hpp?rev=348847&r1=348846&r2=348847&view=diff
==============================================================================
--- libcxx/trunk/test/support/archetypes.hpp (original)
+++ libcxx/trunk/test/support/archetypes.hpp Tue Dec 11 06:22:28 2018
@@ -225,7 +225,6 @@ namespace ExplicitTypes {
 #include "archetypes.ipp"
 }
 
-
 //============================================================================//
 //
 namespace NonConstexprTypes {
@@ -242,11 +241,17 @@ namespace NonLiteralTypes {
 }
 
 //============================================================================//
+// Non-throwing implicit test types
+namespace NonThrowingTypes {
+#define DEFINE_NOEXCEPT noexcept
+#include "archetypes.ipp"
+}
+
+//============================================================================//
 // Non-Trivially Copyable Implicit Test Types
 namespace NonTrivialTypes {
 #define DEFINE_CTOR {}
 #define DEFINE_ASSIGN { return *this; }
-#define DEFINE_DEFAULT_CTOR = default
 #include "archetypes.ipp"
 }
 

Modified: libcxx/trunk/test/support/archetypes.ipp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/archetypes.ipp?rev=348847&r1=348846&r2=348847&view=diff
==============================================================================
--- libcxx/trunk/test/support/archetypes.ipp (original)
+++ libcxx/trunk/test/support/archetypes.ipp Tue Dec 11 06:22:28 2018
@@ -5,6 +5,9 @@
 #ifndef DEFINE_EXPLICIT
 #define DEFINE_EXPLICIT
 #endif
+#ifndef DEFINE_NOEXCEPT
+#define DEFINE_NOEXCEPT
+#endif
 #ifndef DEFINE_CONSTEXPR
 #ifdef TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
 #define DEFINE_CONSTEXPR
@@ -36,114 +39,114 @@ struct AllCtors : DEFINE_BASE(AllCtors)
   using Base = DEFINE_BASE(AllCtors);
   using Base::Base;
   using Base::operator=;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR AllCtors() DEFINE_DEFAULT_CTOR;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR AllCtors(AllCtors const&) DEFINE_CTOR;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR AllCtors(AllCtors &&) DEFINE_CTOR;
-  DEFINE_ASSIGN_CONSTEXPR AllCtors& operator=(AllCtors const&) DEFINE_ASSIGN;
-  DEFINE_ASSIGN_CONSTEXPR AllCtors& operator=(AllCtors &&) DEFINE_ASSIGN;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR AllCtors() DEFINE_NOEXCEPT DEFINE_DEFAULT_CTOR;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR AllCtors(AllCtors const&) DEFINE_NOEXCEPT DEFINE_CTOR;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR AllCtors(AllCtors &&) DEFINE_NOEXCEPT DEFINE_CTOR;
+  DEFINE_ASSIGN_CONSTEXPR AllCtors& operator=(AllCtors const&) DEFINE_NOEXCEPT DEFINE_ASSIGN;
+  DEFINE_ASSIGN_CONSTEXPR AllCtors& operator=(AllCtors &&) DEFINE_NOEXCEPT DEFINE_ASSIGN;
   DEFINE_DTOR(AllCtors)
 };
 
 struct NoCtors : DEFINE_BASE(NoCtors) {
   using Base = DEFINE_BASE(NoCtors);
-  DEFINE_EXPLICIT NoCtors() = delete;
-  DEFINE_EXPLICIT NoCtors(NoCtors const&) = delete;
-  NoCtors& operator=(NoCtors const&) = delete;
+  DEFINE_EXPLICIT NoCtors() DEFINE_NOEXCEPT = delete;
+  DEFINE_EXPLICIT NoCtors(NoCtors const&) DEFINE_NOEXCEPT = delete;
+  NoCtors& operator=(NoCtors const&) DEFINE_NOEXCEPT = delete;
   DEFINE_DTOR(NoCtors)
 };
 
 struct NoDefault : DEFINE_BASE(NoDefault) {
   using Base = DEFINE_BASE(NoDefault);
   using Base::Base;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR NoDefault() = delete;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR NoDefault() DEFINE_NOEXCEPT = delete;
   DEFINE_DTOR(NoDefault)
 };
 
 struct DefaultOnly : DEFINE_BASE(DefaultOnly) {
   using Base = DEFINE_BASE(DefaultOnly);
   using Base::Base;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR DefaultOnly() DEFINE_DEFAULT_CTOR;
-  DefaultOnly(DefaultOnly const&) = delete;
-  DefaultOnly& operator=(DefaultOnly const&) = delete;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR DefaultOnly() DEFINE_NOEXCEPT DEFINE_DEFAULT_CTOR;
+  DefaultOnly(DefaultOnly const&) DEFINE_NOEXCEPT = delete;
+  DefaultOnly& operator=(DefaultOnly const&) DEFINE_NOEXCEPT = delete;
   DEFINE_DTOR(DefaultOnly)
 };
 
 struct Copyable : DEFINE_BASE(Copyable) {
   using Base = DEFINE_BASE(Copyable);
   using Base::Base;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR Copyable() DEFINE_DEFAULT_CTOR;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR Copyable(Copyable const &) DEFINE_CTOR;
-  Copyable &operator=(Copyable const &) DEFINE_ASSIGN;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR Copyable() DEFINE_NOEXCEPT DEFINE_DEFAULT_CTOR;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR Copyable(Copyable const &) DEFINE_NOEXCEPT DEFINE_CTOR;
+  Copyable &operator=(Copyable const &) DEFINE_NOEXCEPT DEFINE_ASSIGN;
   DEFINE_DTOR(Copyable)
 };
 
 struct CopyOnly : DEFINE_BASE(CopyOnly) {
   using Base = DEFINE_BASE(CopyOnly);
   using Base::Base;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR CopyOnly() DEFINE_DEFAULT_CTOR;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR CopyOnly(CopyOnly const &) DEFINE_CTOR;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR CopyOnly(CopyOnly &&) = delete;
-  CopyOnly &operator=(CopyOnly const &) DEFINE_ASSIGN;
-  CopyOnly &operator=(CopyOnly &&) = delete;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR CopyOnly() DEFINE_NOEXCEPT DEFINE_DEFAULT_CTOR;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR CopyOnly(CopyOnly const &) DEFINE_NOEXCEPT DEFINE_CTOR;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR CopyOnly(CopyOnly &&) DEFINE_NOEXCEPT = delete;
+  CopyOnly &operator=(CopyOnly const &) DEFINE_NOEXCEPT DEFINE_ASSIGN;
+  CopyOnly &operator=(CopyOnly &&) DEFINE_NOEXCEPT = delete;
   DEFINE_DTOR(CopyOnly)
 };
 
 struct NonCopyable : DEFINE_BASE(NonCopyable) {
   using Base = DEFINE_BASE(NonCopyable);
   using Base::Base;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR NonCopyable() DEFINE_DEFAULT_CTOR;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR NonCopyable(NonCopyable const &) = delete;
-  NonCopyable &operator=(NonCopyable const &) = delete;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR NonCopyable() DEFINE_NOEXCEPT DEFINE_DEFAULT_CTOR;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR NonCopyable(NonCopyable const &) DEFINE_NOEXCEPT = delete;
+  NonCopyable &operator=(NonCopyable const &) DEFINE_NOEXCEPT = delete;
   DEFINE_DTOR(NonCopyable)
 };
 
 struct MoveOnly : DEFINE_BASE(MoveOnly) {
   using Base = DEFINE_BASE(MoveOnly);
   using Base::Base;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR MoveOnly() DEFINE_DEFAULT_CTOR;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR MoveOnly(MoveOnly &&) DEFINE_CTOR;
-  MoveOnly &operator=(MoveOnly &&) DEFINE_ASSIGN;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR MoveOnly() DEFINE_NOEXCEPT DEFINE_DEFAULT_CTOR;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR MoveOnly(MoveOnly &&) DEFINE_NOEXCEPT DEFINE_CTOR;
+  MoveOnly &operator=(MoveOnly &&) DEFINE_NOEXCEPT DEFINE_ASSIGN;
   DEFINE_DTOR(MoveOnly)
 };
 
 struct CopyAssignable : DEFINE_BASE(CopyAssignable) {
   using Base = DEFINE_BASE(CopyAssignable);
   using Base::Base;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR CopyAssignable() = delete;
-  CopyAssignable& operator=(CopyAssignable const&) DEFINE_ASSIGN;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR CopyAssignable() DEFINE_NOEXCEPT = delete;
+  CopyAssignable& operator=(CopyAssignable const&) DEFINE_NOEXCEPT DEFINE_ASSIGN;
   DEFINE_DTOR(CopyAssignable)
 };
 
 struct CopyAssignOnly : DEFINE_BASE(CopyAssignOnly) {
   using Base = DEFINE_BASE(CopyAssignOnly);
   using Base::Base;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR CopyAssignOnly() = delete;
-  CopyAssignOnly& operator=(CopyAssignOnly const&) DEFINE_ASSIGN;
-  CopyAssignOnly& operator=(CopyAssignOnly &&) = delete;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR CopyAssignOnly() DEFINE_NOEXCEPT = delete;
+  CopyAssignOnly& operator=(CopyAssignOnly const&) DEFINE_NOEXCEPT DEFINE_ASSIGN;
+  CopyAssignOnly& operator=(CopyAssignOnly &&) DEFINE_NOEXCEPT = delete;
   DEFINE_DTOR(CopyAssignOnly)
 };
 
 struct MoveAssignOnly : DEFINE_BASE(MoveAssignOnly) {
   using Base = DEFINE_BASE(MoveAssignOnly);
   using Base::Base;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR MoveAssignOnly() = delete;
-  MoveAssignOnly& operator=(MoveAssignOnly const&) = delete;
-  MoveAssignOnly& operator=(MoveAssignOnly &&) DEFINE_ASSIGN;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR MoveAssignOnly() DEFINE_NOEXCEPT = delete;
+  MoveAssignOnly& operator=(MoveAssignOnly const&) DEFINE_NOEXCEPT = delete;
+  MoveAssignOnly& operator=(MoveAssignOnly &&) DEFINE_NOEXCEPT DEFINE_ASSIGN;
   DEFINE_DTOR(MoveAssignOnly)
 };
 
 struct ConvertingType : DEFINE_BASE(ConvertingType) {
   using Base = DEFINE_BASE(ConvertingType);
   using Base::Base;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR ConvertingType() DEFINE_DEFAULT_CTOR;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR ConvertingType(ConvertingType const&) DEFINE_CTOR;
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR ConvertingType(ConvertingType &&) DEFINE_CTOR;
-  ConvertingType& operator=(ConvertingType const&) DEFINE_ASSIGN;
-  ConvertingType& operator=(ConvertingType &&) DEFINE_ASSIGN;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR ConvertingType() DEFINE_NOEXCEPT DEFINE_DEFAULT_CTOR;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR ConvertingType(ConvertingType const&) DEFINE_NOEXCEPT DEFINE_CTOR;
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR ConvertingType(ConvertingType &&) DEFINE_NOEXCEPT DEFINE_CTOR;
+  ConvertingType& operator=(ConvertingType const&) DEFINE_NOEXCEPT DEFINE_ASSIGN;
+  ConvertingType& operator=(ConvertingType &&) DEFINE_NOEXCEPT DEFINE_ASSIGN;
   template <class ...Args>
-  DEFINE_EXPLICIT DEFINE_CONSTEXPR ConvertingType(Args&&...) {}
+  DEFINE_EXPLICIT DEFINE_CONSTEXPR ConvertingType(Args&&...) DEFINE_NOEXCEPT {}
   template <class Arg>
-  ConvertingType& operator=(Arg&&) { return *this; }
+  ConvertingType& operator=(Arg&&) DEFINE_NOEXCEPT { return *this; }
   DEFINE_DTOR(ConvertingType)
 };
 
@@ -165,6 +168,7 @@ using ApplyTypes = List<
 
 #undef DEFINE_BASE
 #undef DEFINE_EXPLICIT
+#undef DEFINE_NOEXCEPT
 #undef DEFINE_CONSTEXPR
 #undef DEFINE_ASSIGN_CONSTEXPR
 #undef DEFINE_CTOR




More information about the libcxx-commits mailing list