Merge pull request #74 from grandseiken/main

This commit is contained in:
liuzicheng1987
2024-03-22 00:14:20 +08:00
committed by GitHub
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -199,7 +199,7 @@ class NamedTuple {
/// Invokes a callable object once for each field in order.
template <typename F>
void apply(const F& _f) {
void apply(F&& _f) {
const auto apply_to_field =
[&_f]<typename... AFields>(AFields&&... fields) {
((_f(std::forward<AFields>(fields))), ...);
@@ -209,7 +209,7 @@ class NamedTuple {
/// Invokes a callable object once for each field in order.
template <typename F>
void apply(const F& _f) const {
void apply(F&& _f) const {
const auto apply_to_field = [&_f](const auto&... fields) {
((_f(fields)), ...);
};
@@ -602,7 +602,7 @@ class NamedTuple<> {
/// Does nothing at all.
template <typename F>
void apply(const F& _f) const {}
void apply(F&& _f) const {}
/// Returns an empty tuple.
auto fields() const { return std::tuple(); }
+1 -1
View File
@@ -38,7 +38,7 @@ void test() {
}
});
rfl::to_view(lisa).apply([](auto field) {
rfl::to_view(lisa).apply([](auto field) mutable {
if constexpr (decltype(field)::name() == "first_name") {
*field.value() = "Bart";
}