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)
27 CHECK_DECLTYPE(decltype(a), int);
28 CHECK_DECLTYPE(decltype(this->a), int);
29 CHECK_DECLTYPE(decltype((*this).a), int);
30 CHECK_DECLTYPE(decltype(b), int&);
31 CHECK_DECLTYPE(decltype(c), int);
34 CHECK_DECLTYPE(decltype(a), int);
35 CHECK_DECLTYPE(decltype(b), int&);
36 CHECK_DECLTYPE(decltype(c), int);
43 CHECK_DECLTYPE(decltype(aa.a), int);
44 CHECK_DECLTYPE(decltype(aa.b), int&);
45 CHECK_DECLTYPE(decltype(caa.a), int);
52 decltype(a) foo() { return 0; }
53 decltype(b) enums_are_in_scope() { return b; } // ok
56 CHECK_DECLTYPE(decltype(aa.*&A::a), int&);
57 decltype(aa.*&A::b) zz; // { dg-error "18:cannot create pointer to reference member" "cannot" }
59 CHECK_DECLTYPE(decltype(caa.*&A::a), const int&);
63 CHECK_DECLTYPE(decltype(this), X*);
64 CHECK_DECLTYPE(decltype(*this), X&);
67 CHECK_DECLTYPE(decltype(this), const X*);
68 CHECK_DECLTYPE(decltype(*this), const X&);