Re:Bastion of the Turbofish (2020)
by vbarrielle on Friday February 05, 2021 @10:18AM
(#26037207)
C++ has a rule similar to the turbofish though:
[ Parent
| on HN ]
I'm sure you know better, but at first glance this seems wrong. Reason: `main` is not itself a template, so `cast` is not a dependent name.
C++ compilers used to be liberal about accepting unnecessary instances of the `typename` keyword so lots of people would just sprinkle them everywhere. Modern versions of both Clang and GCC call this out.
The actual rule: https://en.cppreference.com/w/cpp/language/dependent_name#Th...
Re:Bastion of the Turbofish (2020)
by vbarrielle on Saturday February 06, 2021 @03:40PM
(#26049729)
You're right, since I'm frequently using templated functions I encounter this issue quite often, but here when I wanted to give an example I forgot I needed to be in a dependent context. I guess I'd better test my example next time I want to give one...
And I have never internalized it! This is me, but for `typename` and `template` in expressions: https://xkcd.com/1168/