Can auto placeholder be used to deduce function result in non-type template parameter?

后端 未结 1 1368
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-04 21:58

Consider simple example:

template 
struct Foo {
    decltype(X()) x;
};

int bar();

int main() {
    static_cast(Foo

        
1条回答
  •  星月不相逢
    2021-01-04 22:31

    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).

    0 讨论(0)
提交回复
热议问题