Debian Codegraph @

gcc/testsuite/g++.dg/ext/is_pod.C

raw
1 // { dg-do run { target c++11 } }
2 // { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } }
3 #include <cassert>
4
5 struct A
6 {
7 double a;
8 double b;
9 };
10
11 struct B
12 {
13 B() { }
14 };
15
16 struct C
17 : public A { };
18
19 template<typename T>
20 bool
21 f()
22 { return __is_pod(T); }
23
24 template<typename T>
25 class My
26 {
27 public:
28 bool
29 f()
30 { return !!__is_pod(T); }
31 };
32
33 template<typename T>
34 class My2
35 {
36 public:
37 static const bool trait = __is_pod(T);
38 };
39
40 template<typename T>
41 const bool My2<T>::trait;
42
43 template<typename T, bool b = __is_pod(T)>
44 struct My3_help
45 { static const bool trait = b; };
46
47 template<typename T, bool b>
48 const bool My3_help<T, b>::trait;
49
50 template<typename T>
51 class My3
52 {
53 public:
54 bool
55 f()
56 { return My3_help<T>::trait; }
57 };
58
59 #define PTEST(T) (__is_pod(T) && f<T>() \
60 && My<T>().f() && My2<T>::trait && My3<T>().f())
61
62 #define NTEST(T) (!__is_pod(T) && !f<T>() \
63 && !My<T>().f() && !My2<T>::trait && !My3<T>().f())
64
65 int main()
66 {
67 assert (PTEST (int));
68 assert (NTEST (void));
69 assert (PTEST (A));
70 assert (PTEST (A[]));
71 assert (NTEST (B));
72 assert (PTEST (C));
73 assert (PTEST (C[]));
74
75 return 0;
76 }