class
vs typename
#2288
-
Any reason to prefer Sure I mean the context where they are equivalent. In my code I take advantage of both keyword available: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It's both historical, and reflects the Standard's editorial convention. We don't feel super strongly about it - I personally prefer Using |
Beta Was this translation helpful? Give feedback.
It's both historical, and reflects the Standard's editorial convention. We don't feel super strongly about it - I personally prefer
typename
(which is why it's common in the tests, which have been less strict about following the same conventions as product code), but I don't think it's worth converting the whole codebase over (unlike clang-format, braces everywhere, etc.).Using
class
versustypename
to express a connotation of "only class types" versus "literally any type" could be reasonable for certain codebases that are very strict about it, but because that isn't a widespread convention, I personally don't view the keywords as carrying that connotation (whereasstruct
versusclass
ca…