在基类初始化的模板参数中使用 decltype 无法编译

Vai*_*Man 7 c++ language-lawyer

请参阅下面的代码。为什么需要括号?它是由标准定义的吗?

现场演示: https: //godbolt.org/z/fbfPPGWc1

template<int I>
struct Base {};

template<int I>
struct Derived: Base<I>
{
  // ERROR
  Derived(int): Base<decltype(0){I}>() {}

  // OK (Note the parenthesis)
  Derived(char): Base<(decltype(0){I})>() {}

  // OK
  Base<decltype(0){I}> x = Base<decltype(0){I}>();
};

int main() {
}
Run Code Online (Sandbox Code Playgroud)