The titular question refers to the design decisions in the C++ standard that introduced templates around 1990.
Why did the designers use instead of, say, (round brackets)? Doing so would have saved lots of programmers from the bit-shift related error
std::vector<std::vector<int>> // does not work until C++11
that got only fixed in C++11. I do not see the rationale of introducing additional syntax like that when, arguably, round brackets would have served the same purpose while keeping the changes minimalist. Insted you could have used
template(typename T) // Define template if round brackets could be used
mytemplate { ... }
...
...
mytemplate(mytemplate(int)) obj; //Instantiate template when round brackets could be used
Can somebody well-versed in the history of C++ dig out the original design rationale for using angle brackets? Alternatively, can you show why other solutions would not have worked as well?
Aucun commentaire:
Enregistrer un commentaire