using decltype in template arguments of initialization of base class fails to compile

Viewed 120

See the code below. Why is parenthesis needed? Is it defined by standard?

Live demo: 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() {
}
0 Answers
Related