From 71744d01c73e0adeeee2b1ed8785e64a83ccc724 Mon Sep 17 00:00:00 2001 From: liuzicheng1987 Date: Wed, 6 Dec 2023 23:00:59 +0100 Subject: [PATCH] Update README.md --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 944079d3..473a4bd9 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,9 @@ Other forms of tagging are supported as well. Refer to the [documentation](https ## Reflective programming -Beyond serialization and deserialization through, reflect-cpp also supports reflective programming in general. For instance: +Beyond serialization and deserialization through, reflect-cpp also supports reflective programming in general. + +For instance: ```cpp struct Person { @@ -211,6 +213,8 @@ const auto maggie = rfl::replace( lisa, rfl::make_field<"first_name">(std::string("Maggie"))); ``` +Or you can create structs from other structs: + ```cpp struct A { std::string f1; @@ -235,6 +239,9 @@ const auto b = B{.f3 = "Hello", .f4 = "World"}; // f1 and f2 are taken from a, f4 is taken from b, f3 is ignored. const auto c = rfl::as(a, b); ``` + +You can also replace fields in structs using fields from other structs: + ```cpp const auto a = A{.f1 = "Hello", .f2 = "World"};