• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // template<class U, class V> pair(U&& x, V&& y);
17 
18 #include <utility>
19 
20 
21 struct ExplicitT {
ExplicitTExplicitT22     constexpr explicit ExplicitT(int x) : value(x) {}
23     int value;
24 };
25 
26 struct ImplicitT {
ImplicitTImplicitT27     constexpr ImplicitT(int x) : value(x) {}
28     int value;
29 };
30 
31 struct ExplicitNothrowT {
ExplicitNothrowTExplicitNothrowT32     explicit ExplicitNothrowT(int x) noexcept : value(x) {}
33     int value;
34 };
35 
36 struct ImplicitNothrowT {
ImplicitNothrowTImplicitNothrowT37     ImplicitNothrowT(int x) noexcept : value(x) {}
38     int value;
39 };
40 
main()41 int main() {
42     { // explicit noexcept test
43         static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitT>, int, int>::value, "");
44         static_assert(!std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitT>, int, int>::value, "");
45         static_assert(!std::is_nothrow_constructible<std::pair<ExplicitT, ExplicitNothrowT>, int, int>::value, "");
46         static_assert( std::is_nothrow_constructible<std::pair<ExplicitNothrowT, ExplicitNothrowT>, int, int>::value, "");
47     }
48     { // implicit noexcept test
49         static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitT>, int, int>::value, "");
50         static_assert(!std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitT>, int, int>::value, "");
51         static_assert(!std::is_nothrow_constructible<std::pair<ImplicitT, ImplicitNothrowT>, int, int>::value, "");
52         static_assert( std::is_nothrow_constructible<std::pair<ImplicitNothrowT, ImplicitNothrowT>, int, int>::value, "");
53     }
54 }
55