I\'m trying to get the return type of an auto
function. This works:
auto foo(int bar)
{
return 0;
}
typedef std::result_of
While the way you have written the code makes it appear possible, the in-class definition of foo()
can only be processed after the class is fully defined. It is as if you wrote this:
struct Foo
{
static auto foo(int bar);
typedef std::result_of foo_t;
};
auto Foo::foo(int bar)
{
return 0;
}
The definition of foo()
is allowed to use types defined in class Foo
, including foo_t
, which would be circular. Therefore, the definition of class Foo
is not allowed to use the definition of its member functions--only their declarations.
In other words, you assume the code is fully evaluated from the top to the bottom. It is not.