Shafik Yaghmour

Compiler Engineer at Intel. This is a personal blog. The opinions stated here are my own, not those of my company.

This is not well formed code, this is another variation on the maximal munch problem which is also present in this Stack Overflow question.

We can see this is not well-formed from [temp.param]p15 which says:

When parsing a default template-argument for a non-type template-parameter, the first non-nested > is taken as the end of the template-parameter-list rather than a greater-than operator. [ Example:

 template<int i = 3 > 4 >        // syntax error
  class X { /* ... */ };

 template<int i = (3 > 4) >      // OK
  class Y { /* ... */ };

— end example]

Obligatory godbolt