aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/is_nothrow_constructible1.C
blob: 472acf9f88f132f98109dfc7e7b5d3046e0fbdbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// { dg-do compile { target c++11 } }

struct A { };
struct B { B(); operator int(); };
struct C {
  C() = default;
  C(const C&);
  C(C&&) = default;
  C& operator=(C&&);
  C& operator= (const C&) = default;
};
struct D { ~D() noexcept(false) {} };

#define SA(X) static_assert((X),#X)

SA(__is_nothrow_constructible(A));
SA(__is_nothrow_constructible(A,A));
SA(!__is_nothrow_constructible(B));
SA(__is_nothrow_constructible(B,B));

SA(!__is_nothrow_constructible(A,B));
SA(!__is_nothrow_constructible(B,A));

SA(__is_nothrow_constructible(C));
SA(__is_nothrow_constructible(C,C));
SA(!__is_nothrow_constructible(C,C&));
SA(__is_nothrow_assignable(C,C&));
SA(!__is_nothrow_assignable(C,C));
SA(!__is_nothrow_assignable(C,C&&));
SA(!__is_nothrow_assignable(void,int));
SA(!__is_nothrow_assignable(const void,int));
SA(!__is_nothrow_assignable(volatile void,int));
SA(!__is_nothrow_assignable(const volatile void,int));

SA(__is_nothrow_constructible(int,int));
SA(__is_nothrow_constructible(int,double));
SA(!__is_nothrow_constructible(int,B));
SA(!__is_nothrow_constructible(void,int));
SA(!__is_nothrow_constructible(const void,int));
SA(!__is_nothrow_constructible(volatile void,int));
SA(!__is_nothrow_constructible(const volatile void,int));
SA(!__is_nothrow_constructible(int, void*));
SA(!__is_nothrow_constructible(int, int*));
SA(!__is_nothrow_constructible(int, const int*));
SA(!__is_nothrow_constructible(int*, void*));
SA(!__is_nothrow_constructible(int*, const int*));

SA(!__is_nothrow_constructible(D));