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
821 stars 65 forks source link

add rfl::NamedTuple::apply() for convenient compile-time iteration #59

Closed grandseiken closed 5 months ago

grandseiken commented 5 months ago

Adds rfl::NamedTuple::apply() as proposed in https://github.com/getml/reflect-cpp/issues/58.

I made one small design deviation from @liuzicheng1987's proposal which was to implement rfl::Field::name() by way of its rfl::internal::StringLiteral name, rather than via rfl::Literal, so that it can be a compile-time constant. I think that's important, e.g. the simple test I added wouldn't be possible without it.

liuzicheng1987 commented 5 months ago

I think the compile-time name is a great idea!