I don't quite understand the need, other than playing with the syntax. That is precisely what auto
was designed for, and auto
is supported by the same standard that added decltype
...
At any rate, you need to simulate the function call:
decltype(std::declval<A>()[0]) b = 0; // equivalent to `int b = 0;`