[SUGGESTION] sizeof<T>
vs sizeof(T)
and sizeof(expr)
#586
ntrel
started this conversation in
Suggestions
Replies: 1 comment
-
See also #531 (comment), |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is about consistent concepts rather than just syntax.
From #574 (comment) Herb said:
AFAIU, a constexpr function can't take a type as an argument. E.g. you couldn't implement a function
sizeof
that can be called likesizeof(int)
. So I thinksizeof<T>
is more consistent. Are type parameters ever passed using function call syntax anywhere in cpp2?Obviously, cpp1
sizeof
also takes an expression. I think often this is just a shortcut to having to writesizeof(decltype(expr))
. If that is the only reason, I would suggest it would be simpler not to have the expression parameter form at all and require usingdecltype
for that.No.
It is simpler and more consistent, though it probably doesn't impact teaching much.
Sticking with cpp1 syntax is workable.
Beta Was this translation helpful? Give feedback.
All reactions