The following code compiles without any error:
class foo
{
public:
void some_func() {}
};
class bar
{
private:
foo instance;
public:
auto some_func() -> decltype(instance.some_func()) {}
};
int main() {}
While the following code doesn't compile in MSVC-12.0:
class foo
{
public:
void some_func() {}
};
class bar
{
private:
foo instance;
public:
auto some_func() -> decltype(instance.some_func());
};
auto bar::some_func() -> decltype(instance.some_func()) {}
int main() {}
It gives me the following errors:
error C2228: left of '.some_func' must have class/struct/union
error C2556: 'int bar::some_func(void)' : overloaded function differs only by return type from 'void bar::some_func(void)'
: see declaration of 'bar::some_func'
error C2371: 'bar::some_func' : redefinition; different basic types
: see declaration of 'bar::some_func'
What am I doing wrong? How can I fix it?