hachyderm.io is one of the many independent Mastodon servers you can use to participate in the fediverse.
Hachyderm is a safe space, LGBTQIA+ and BLM, primarily comprised of tech industry professionals world wide. Note that many non-user account types have restrictions - please see our About page.

Administered by:

Server stats:

9.4K
active users

Shafik Yaghmour

Retro C++ quiz #25

template<int i = 3 > 4 > // Well-formed?
class X {};

Without checking:

A. Yes
B. No
C: Show answers


@shafik I feel like this is a trick question given it's named "retro"....

@malwareminigun

Retro means that there are my old quizzes I am recycling.

I have been doing this like five years now and some really good once folks have not seen especially since I moved from Twitter.

@shafik ah, but the answer may have changed depending on how old that was 😅

@shafik I guess the edge case I'm thinking of that changed would have required a >> in there somewhere instead of naked >s

@shafik
1) was this meant to refer to the current paragraph 19 of that section?

p19:

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

@shafik

2) i thought the max-munch rule was only a phase 3 thing...?

3) Without [temp.param] p19, we would just follow the grammar like so: if a template-parameter is a parameter-declaration with an initializer-clause, then a '>' in that initializer-clause would be parsed as part of an assignment-expression (as usual for assignment-expressions outside this special context).
...

@shafik
like... if there were a max-munch rule for the parsing in phase 7, wouldn't it be something like, "the next syntactic construct is the longest sequence of tokens that could constitute one of the grammar terms allowed in its context", in which case...

isn't p19 *preventing* max-munch (i.e. matching of the longest possible assignment-expression)?