mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-03 00:26:19 +08:00
revert change of F&& to const F&
This commit is contained in:
@@ -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)), ...);
|
||||
};
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user