1 // { dg-do compile { target c++11 } }
3 template<typename T, typename U>
6 static const bool value = false;
12 static const bool value = true;
15 #define CHECK_DECLTYPE(DECLTYPE,RESULT) \
16 static_assert(is_same< DECLTYPE , RESULT >::value, #DECLTYPE " should be " #RESULT)
25 CHECK_DECLTYPE(decltype(&A::x), int A::*);
26 decltype(&A::y) Ay; // { dg-error "cannot create pointer to reference member|invalid type" }
27 CHECK_DECLTYPE(decltype(&A::foo), int (A::*) (char));
28 CHECK_DECLTYPE(decltype(&A::bar), int& (A::*) () const);
30 CHECK_DECLTYPE(decltype("decltype"), const char(&)[9]);
31 CHECK_DECLTYPE(decltype(1), int);
37 CHECK_DECLTYPE(decltype(i)&, int&);
38 CHECK_DECLTYPE(const decltype(j), const int);
41 CHECK_DECLTYPE(decltype(foo()), int);
43 CHECK_DECLTYPE(decltype (bar(1)), float&);
45 CHECK_DECLTYPE(decltype (bar()), const A);
47 CHECK_DECLTYPE(decltype (bar2()), const A&);
50 CHECK_DECLTYPE(decltype(1+2), int);
52 CHECK_DECLTYPE(decltype(*p), int&);
54 CHECK_DECLTYPE(decltype(a[3]), int&);
56 CHECK_DECLTYPE(decltype (i = 5), int&);
57 CHECK_DECLTYPE(decltype (j = 5), int&);
59 CHECK_DECLTYPE(decltype (++i), int&);
60 CHECK_DECLTYPE(decltype (i++), int);
64 B () : bit(), cbit() {}
70 CHECK_DECLTYPE(decltype(bit), int);
71 CHECK_DECLTYPE(decltype((bit)), int&);
72 CHECK_DECLTYPE(decltype(cbit), const int);
73 CHECK_DECLTYPE(decltype((cbit)), const int&);
79 CHECK_DECLTYPE(decltype(b.bit), int);
80 CHECK_DECLTYPE(decltype(bc.bit), int);
81 CHECK_DECLTYPE(decltype((b.bit)), int&);
82 CHECK_DECLTYPE(decltype((bc.bit)), const int&);