Im just re reading through some material and im wondering, is the sizeof operator useful in modern C++? I could see how it could probably be useful back in the day when data was limited and you needed to know the sizes of things, but nowadays computers have SO much memory that those concerns are pretty much non existent.
It could still be useful for some things (e.g. when writing and reading binary data) but it's a relatively low-level feature and like the bitwise operators it's not at all strange if you don't have a use for them very often.
Apart from usage in binary data, another common usage of sizeof prior to C++17 was to determine the number of elements in a c-style array. However since C++17 there has been std::size() (and std::ssize() since C++20).
sizeof arr provides the total number of bytes in the arr array and sizeof arr[0] the number of bytes in the first element. Simple division gives the number of elements.
PS.
I could see how it could probably be useful back in the day when data was limited and you needed to know the sizes of things, but nowadays computers have SO much memory that those concerns are pretty much non existent.
sizeof has nothing to do with available memory. It usage is for the size of types and variables.