annotate gcc/testsuite/g++.dg/cpp0x/decltype12.C @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // { dg-do compile { target c++11 } }
kono
parents:
diff changeset
2 template<typename T, typename U>
kono
parents:
diff changeset
3 struct is_same
kono
parents:
diff changeset
4 {
kono
parents:
diff changeset
5 static const bool value = false;
kono
parents:
diff changeset
6 };
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 template<typename T>
kono
parents:
diff changeset
9 struct is_same<T, T>
kono
parents:
diff changeset
10 {
kono
parents:
diff changeset
11 static const bool value = true;
kono
parents:
diff changeset
12 };
kono
parents:
diff changeset
13
kono
parents:
diff changeset
14 int&& f(const int&) {}
kono
parents:
diff changeset
15 int&& (*fp)(const int&) = f;
kono
parents:
diff changeset
16 int&& (&fr)(const int&) = f;
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 struct X { int&& f(const int&); };
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 int&& (X::*mfp)(const int&) = &X::f;
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 void g(X& xr, X* xp)
kono
parents:
diff changeset
23 {
kono
parents:
diff changeset
24 int i;
kono
parents:
diff changeset
25 static_assert(is_same<decltype(f(i)), int&&>::value, "direct call");
kono
parents:
diff changeset
26 static_assert(is_same<decltype(fp(i)), int&&>::value, "pointer");
kono
parents:
diff changeset
27 static_assert(is_same<decltype((*fp)(i)), int&&>::value,
kono
parents:
diff changeset
28 "dereferenced pointer");
kono
parents:
diff changeset
29 static_assert(is_same<decltype(fr(i)), int&&>::value,
kono
parents:
diff changeset
30 "reference");
kono
parents:
diff changeset
31 static_assert(is_same<decltype(xr.f(i)), int&&>::value,
kono
parents:
diff changeset
32 "member function call");
kono
parents:
diff changeset
33 static_assert(is_same<decltype((xr.*mfp)(i)), int&&>::value,
kono
parents:
diff changeset
34 "member function pointer with .*");
kono
parents:
diff changeset
35 static_assert(is_same<decltype((xp->*mfp)(i)), int&&>::value,
kono
parents:
diff changeset
36 "member function pointer with ->*");
kono
parents:
diff changeset
37 }