On Monday, 4 September 2023 at 09:41:54 UTC, BoQsc wrote:
I've seen everyone using **datatype**`.sizeof` property.
https://dlang.org/spec/property.html#sizeof
It's great, but I wonder if it differ in any way from the
standard C function `sizeof()`.
Technically speaking, in C, sizeof is not a function, it is an
operator. This is why it is not available in D (replaced by the
.sizeof property).
https://www.geeksforgeeks.org/sizeof-operator-c/
https://en.cppreference.com/w/cpp/language/sizeof
I'm seeking for some speed/performance, so that's why the
question.
Overall I'm alright with continuing using it.
There is absolutely no difference in terms of runtime
performance. In both cases, the compiler replaces it by the size
of the type at compile-time.