top | item 44591496

(no title)

eMSF | 7 months ago

While it is true that only class types have member functions in C++, that does not mean that objects of other types demand the use of macros. C++ also supports non-member functions, and the standard library contains a fair amount of these; including `std::size` that can be used to "get" the length of an array.

(C++ arrays are different from arrays in many other programming languages, though not necessarily Rust, in that their type specifies their length, so in a way this is something you already "have" but certainly there are cases where it is convenient to "get" this information from an object.)

discuss

order

WD-42|7 months ago

Ah, std::size, since c++17. No wonder nobody knows about it, that’s after we all started switching to rust.