4 ms·
Stroustrup doesn't think so. I don't have a link - it was in some recent conference. He stated that every time he added a new feature everyone would be up in a
by RogerL 12y ago
Stroustrup doesn't think so.
I don't have a link - it was in some recent conference. He stated that every time he added a new feature everyone would be up in arms and demand a really verbose implementation, which he added reluctantly. Now that everyone is used to the features they complain about how ridiculously verbose it all is.
There isn't any reason for the craziness of
template<typename T>
void foo(T a)
vs
void foo(auto a)
Certainly things can become too implicit, but C++'s heritage of verboseness is due to the conservatism of the standards committee, not because anything less would be confusing.
- syncsynchalt 12y agoThe reason for your particular example is path dependency — templates came long before (the redefinition of) auto.
- dllthomas 12y agoBut the expanded form does provide you with more flexibility. Even if the latter is a synonym for the former, there is a difference between: template<typename T> void foo(T a, T b) vs void foo(auto a, auto b)
- kazinator 12y agoIt seems like in the second `foo`, the types of `a` and `b` are not hinged together. So to do it with the template syntax you actually need: template<typename T, typename U> void foo(T a, U b) :)
- dllthomas 12y agoI intended the two to share a type. My point was that you cannot express that constraint with only auto.
- deleted 12y ago[deleted]