getml / reflect-cpp

A C++20 library for fast serialization, deserialization and validation using reflection. Supports JSON, BSON, CBOR, flexbuffers, msgpack, TOML, XML, YAML / msgpack.org[C++20]
https://getml.github.io/reflect-cpp/
MIT License
900 stars 76 forks source link

Serialization of std::reference_wrapper #31

Closed ecatmur closed 8 months ago

ecatmur commented 8 months ago

Only for serialization - similarly to pointers, this should not be used for deserialization.

As discussed https://github.com/getml/reflect-cpp/pull/20#issuecomment-1857491501 this requires changing the implementation of bind_to_tuple, since std::ref() collapses on a std::reference_wrapper.

Checked tests run under g++ 11.4.0 Formatted additions with clang-format 16.0.0

liuzicheng1987 commented 8 months ago

This looks like it makes a lot of sense. I‘m going to test it on clang, gcc and MSVC and if that checks out, I‘ll merge.

Thank you for this contribution.

ChemiCalChems commented 8 months ago

Thank for the contribution!

liuzicheng1987 commented 8 months ago

By the way, @zerolfx is in the process of building up a Github Actions pipeline...I really look forward to that. It is going to make testing and approving PRs a lot easier.

liuzicheng1987 commented 8 months ago

Tests compile and run on gcc, clang and MSVC. And you have even added a test for std::ref. Great contribution. Thank you so much.