1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // UNSUPPORTED: c++98, c++03 11 12 // <utility> 13 14 // template <class T1, class T2> struct pair 15 16 // pair(const T1& x, const T2& y); 17 18 #include <utility> 19 20 21 struct ExplicitT { 22 constexpr explicit ExplicitT(int x) : value(x) {} 23 constexpr explicit ExplicitT(ExplicitT const& o) : value(o.value) {} 24 int value; 25 }; 26 27 struct ImplicitT { 28 constexpr ImplicitT(int x) : value(x) {} 29 constexpr ImplicitT(ImplicitT const& o) : value(o.value) {} 30 int value; 31 }; 32 33 struct ExplicitNothrowT { 34 explicit ExplicitNothrowT(ExplicitNothrowT const&) noexcept {} 35 }; 36 37 struct ImplicitNothrowT { 38 ImplicitNothrowT(ImplicitNothrowT const&) noexcept {} 39 }; 40 41 int main() { 42 { // explicit noexcept test 43 static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitT>, 44 ExplicitT const&, ExplicitT const&>::value, ""); 45 static_assert(!std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitT>, 46 ExplicitNothrowT const&, ExplicitT const&>::value, ""); 47 static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitNothrowT>, 48 ExplicitT const&, ExplicitNothrowT const&>::value, ""); 49 static_assert( std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitNothrowT>, 50 ExplicitNothrowT const&, ExplicitNothrowT const&>::value, ""); 51 } 52 { // implicit noexcept test 53 static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitT>, 54 ImplicitT const&, ImplicitT const&>::value, ""); 55 static_assert(!std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitT>, 56 ImplicitNothrowT const&, ImplicitT const&>::value, ""); 57 static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitNothrowT>, 58 ImplicitT const&, ImplicitNothrowT const&>::value, ""); 59 static_assert( std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitNothrowT>, 60 ImplicitNothrowT const&, ImplicitNothrowT const&>::value, ""); 61 } 62 } 63