OSDN Git Service

2012-12-15 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / cpp0x / decltype12.C
1 // { dg-do compile }
2 // { dg-options "-std=c++0x" }
3 template<typename T, typename U>
4 struct is_same
5 {
6   static const bool value = false;
7 };
8
9 template<typename T>
10 struct is_same<T, T>
11 {
12   static const bool value = true;
13 };
14
15 int&& f(const int&) {}
16 int&& (*fp)(const int&) = f;
17 int&& (&fr)(const int&) = f;
18
19 struct X { int&& f(const int&); };
20
21 int&& (X::*mfp)(const int&) = &X::f;
22
23 void g(X& xr, X* xp)
24 {
25   int i;
26   static_assert(is_same<decltype(f(i)), int&&>::value, "direct call");
27   static_assert(is_same<decltype(fp(i)), int&&>::value, "pointer");
28   static_assert(is_same<decltype((*fp)(i)), int&&>::value, 
29                 "dereferenced pointer");
30   static_assert(is_same<decltype(fr(i)), int&&>::value, 
31                 "reference");
32   static_assert(is_same<decltype(xr.f(i)), int&&>::value,
33                 "member function call");
34   static_assert(is_same<decltype((xr.*mfp)(i)), int&&>::value, 
35                 "member function pointer with .*");
36   static_assert(is_same<decltype((xp->*mfp)(i)), int&&>::value, 
37                 "member function pointer with ->*");
38 }