endian icon indicating copy to clipboard operation
endian copied to clipboard

std::array

Open parchinskiy opened this issue 1 year ago • 3 comments

Hi, since C++03 is no longer supported, is there any reason not to add an overload for std::array here?

parchinskiy avatar Jul 20 '24 14:07 parchinskiy

I suppose it makes sense. <array> is a surprisingly heavy header to include, though, because it often includes <algorithm>, so this is one possible drawback.

pdimov avatar Jul 20 '24 22:07 pdimov

@pdimov Maybe instead of overloading for an array, it makes sense for functions like big_to_native_in_place, native_to_big_in_place, etc. to add overloads with iterators? Then you will not need to include <array> and the number of supported types will increase.

parchinskiy avatar Jul 21 '24 10:07 parchinskiy

Yes, I was wondering whether supporting just std::array was justified, as I assume std::vector support would also be legitimate. And there are also std::pair and std::tuple, for which reverse in place also makes sense.

It's in principle possible to do what ContainerHash does and support all containers and tuple-likes by default, although that's somewhat outside the current scope of the Endian library. (We can even make described structs work out of the box.)

Out of curiosity, what is you current use case for supporting std::array? Do you need support for other containers, or for pair/tuple?

pdimov avatar Jul 21 '24 10:07 pdimov