1 // { dg-do compile { target c++11 } } 2 // { dg-additional-options "-Wno-return-type" } 3 4 template<typename T, typename U> 5 struct is_same 6 { 7 static const bool value = false; 8 }; 9 10 template<typename T> 11 struct is_same<T, T> 12 { 13 static const bool value = true; 14 }; 15 16 int&& f(const int&) {} 17 int&& (*fp)(const int&) = f; 18 int&& (&fr)(const int&) = f; 19 20 struct X { int&& f(const int&); }; 21 22 int&& (X::*mfp)(const int&) = &X::f; 23 24 void g(X& xr, X* xp) 25 { 26 int i; 27 static_assert(is_same<decltype(f(i)), int&&>::value, "direct call"); 28 static_assert(is_same<decltype(fp(i)), int&&>::value, "pointer"); 29 static_assert(is_same<decltype((*fp)(i)), int&&>::value, 30 "dereferenced pointer"); 31 static_assert(is_same<decltype(fr(i)), int&&>::value, 32 "reference"); 33 static_assert(is_same<decltype(xr.f(i)), int&&>::value, 34 "member function call"); 35 static_assert(is_same<decltype((xr.*mfp)(i)), int&&>::value, 36 "member function pointer with .*"); 37 static_assert(is_same<decltype((xp->*mfp)(i)), int&&>::value, 38 "member function pointer with ->*"); 39 } 40