Consider simple example:
template
struct Foo {
decltype(X()) x;
};
int bar();
int main() {
static_cast(Foo
Yes, auto
may be used inside a compound type ([temp.param]/4.6, [dcl.type.auto.deduct]). I believe that gcc is in error in your second example: your explicitly specified T
of int
is substituted before performing deduction ([temp.deduct]/2.3, /5, and /6, referenced by [dcl.type.auto.deduct]/2.3 and /4).