From Introduction to the C++11 feature: trailing return types
The article claims
template <class T> class tmp {
public:
int i;
};
auto foo()->auto(*)()->tmp<int>(*)(){
return 0;
}
is equivalent to
template <class T> class tmp{
public:
int i;
};
tmp<int> (*(*foo())())() {
return 0;
}
I don't understand the complex function in the second code example. Where should I look at in the beginning? I guess is foo
. But the stat right next to foo
is going to define foo
as a pointer...
Based on the first code example, I will convert the piece as
tmp<int> (*)() (*)() foo(){ return 0;}
So foo is a function, which returns 0, but the return type is tricky: its return type is functional pointer whose return type is again a function pointer whose return type is tmp<int>
.