Skip to content

[SUGGESTION] Down with typename! #531

Closed
@JohelEGP

Description

@JohelEGP

First expressed at #529 (comment) (which occurred to me when working on that PR).

Will your feature suggestion eliminate X% of security vulnerabilities of a given kind in current C++ code? 👌 (zero).

Will your feature suggestion automate or eliminate X% of current C++ guidance literature?

If yes, please be specific about what current good guidance this helps make the default, and/or what guidelines we would no longer need to teach/learn or that would be simplified and how,

  • T.42 would be simplified by reducing the list of cases to which the enforcement can possibly apply.

with an example or two (especially a link to a real "Effective C++" or "C++ Core Guidelines" guideline or two).

Assuming that Cpp2 supports typename for disambiguation, just like Cpp1.

-x: typename T::type = ();
+x: T::type = ();
-x is typename T::type
+x is T::type
  • Please limit suggestions to quantifiable improvements to C++ simplicity, safety, or toolability. Quantifiable means that there is some kind of measurable data that helps motivate the change and measure success. Two of the big ones that will get my attention are eliminating vulnerabilities and eliminating guidance, so use those below please.

For a measure,
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2150r0.html#5.0
proposes to remove 254 uses of typename from the C++ standard library wording
(extracted from the linked section's HTML by counting <del>typename</del>s).

There's 765 occurrences of 'typename ' in the C++ standard library,
not all disambiguating typenames
(extracted from the library sources).
That's a 33% reduction.

Describe alternatives you've considered.
None.
There's nothing better than saying nothing at all when there's no room for another interpretation.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions