Mercurial > hg > CbC > CbC_gcc
comparison 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 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 // { dg-do compile { target c++11 } } | |
2 template<typename T, typename U> | |
3 struct is_same | |
4 { | |
5 static const bool value = false; | |
6 }; | |
7 | |
8 template<typename T> | |
9 struct is_same<T, T> | |
10 { | |
11 static const bool value = true; | |
12 }; | |
13 | |
14 int&& f(const int&) {} | |
15 int&& (*fp)(const int&) = f; | |
16 int&& (&fr)(const int&) = f; | |
17 | |
18 struct X { int&& f(const int&); }; | |
19 | |
20 int&& (X::*mfp)(const int&) = &X::f; | |
21 | |
22 void g(X& xr, X* xp) | |
23 { | |
24 int i; | |
25 static_assert(is_same<decltype(f(i)), int&&>::value, "direct call"); | |
26 static_assert(is_same<decltype(fp(i)), int&&>::value, "pointer"); | |
27 static_assert(is_same<decltype((*fp)(i)), int&&>::value, | |
28 "dereferenced pointer"); | |
29 static_assert(is_same<decltype(fr(i)), int&&>::value, | |
30 "reference"); | |
31 static_assert(is_same<decltype(xr.f(i)), int&&>::value, | |
32 "member function call"); | |
33 static_assert(is_same<decltype((xr.*mfp)(i)), int&&>::value, | |
34 "member function pointer with .*"); | |
35 static_assert(is_same<decltype((xp->*mfp)(i)), int&&>::value, | |
36 "member function pointer with ->*"); | |
37 } |