felixguendling / cista

Cista is a simple, high-performance, zero-copy C++ serialization & reflection library.
https://cista.rocks
MIT License
1.82k stars 118 forks source link

Tuple fix #126

Closed julianharbarth closed 2 years ago

julianharbarth commented 2 years ago

Fixes cista::get for cista::tuple with identical types. Enables structured bindings for cista::tuple.

Originally, I was trying to make

struct s { cista::tuple<int, int, int> t_; };

serialize by "default". It is not in standard layout due to the tuple implementation, so to_tuple_works always evaluates to false. It should serialize just fine in practice if the static_assert is disabled :). I think there is no possibility to catch this edge case in to_tuple_works, or is there?

felixguendling commented 2 years ago

I think we could add an exception for to_tuple_works and a specialization for cista::to_tuple that creates a std::tie from the tuple elements?

julianharbarth commented 2 years ago

to_tuple_works should fail on this one:

struct unserializable { virtual auto f() { } };

and succeed on this one:

struct serializable { cista::tuple<int, int> t_; };

But you cannot specialize depending on the type of a member for cista::to_tuple, right?

felixguendling commented 2 years ago

superseded by #127