Repository navigation
Description
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.
Activity
hsutter commentedon Jul 1, 2023
First: I love the title just as much now as when I first saw Nina and Daveed use it :)
Can you elaborate on what the proposal is though? Cpp2 currently doesn't use
typename, and if I discover any places where it would be needed my first thought would be to fix the grammar so it's unambiguous.The first line should not be allowed now, and the second is unambiguously a variable.
isis interesting:Dependent types: That
x is T::typeshould work but doesn't yet, thanks for the bug report. It ought to emittypenamefor a dependent type... in this case it should generatecpp2::is<typename T::type>(x). But currently it emitscpp2::is<T::type>(x)which fails the Cpp1 compiler. I'll need to fix that.Dependent (static) values:
a) Currently
x is (T::value)works, and requires()which makes it unambiguous.b) Note that to test this you have to write the type in Cpp1, because I haven't yet provided a way to author static values in Cpp2. I probably will allow them, but require them to be
constinitorconstexpr.Here's a working test program:
hsutter commentedon Jul 5, 2023
Ack: You beat me to it -- I've been out of computer range but was going to reply saying I expected it would be the same as
x is typeandx is (value). The parens aren't needed for things like literals, of course.I hope to finally be back in reliable computer range again on Friday...