The following code:
struct A
{
int f(int);
auto g(int x) -> decltype(f(x));
};
Fails to compile with the error:
erro
result_of and decltype in combination can give the the return type for a member function
#include
using namespace std;
struct A
{
int f(int i) { return i; }
auto g(int x) -> std::result_of::type
{
return x;
}
};
int main() {
A a;
static_assert(std::is_same::value,
"should be identical");
return 0;
}