boostorg / endian

Boost Endian library
45 stars 49 forks source link

std::array #55

Open parchinskiy opened 1 month ago

parchinskiy commented 1 month ago

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

pdimov commented 1 month ago

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.

parchinskiy commented 1 month ago

@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.

pdimov commented 1 month ago

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?