slight rework

clang on linux doesn't believe field.name() can be constexpr, so
fall back to Field::name() when constexpr is required.
This commit is contained in:
stu
2024-02-07 13:08:17 +00:00
parent fb0dd371b3
commit 34c36d9b97
3 changed files with 6 additions and 5 deletions
+3 -1
View File
@@ -102,11 +102,13 @@ auto person = rfl::Field<"first_name", std::string>("Bart") *
rfl::Field<"last_name", std::string>("Simpson");
person.apply([](const auto& f) {
constexpr auto field_name = f.name();
auto field_name = f.name();
const auto& value = *f.value();
});
person.apply([]<typename Field>(Field& f) {
// The field name can also be obtained as a compile-time constant.
constexpr auto field_name = Field::name();
using field_pointer_type = typename Field::Type;
field_pointer_type* value = f.value();
});