Skip to content

Commit d94688e

Browse files
committed
Merge #251: Improved CustomBuildField for std::optional in IPC/libmultiprocess
1977b9f Use std::forward in CustomBuildField for std::optional to allow move semantics, resolves FIXME (Mangoostaa) Pull request description: The function now uses std::forward(value) when building the field, so rvalues are forwarded correctly instead of always being treated as lvalues. This resolves the existing FIXME in that code path. Details Previously, the implementation forced every optional value to be accessed as an lvalue, which meant rvalues were unnecessarily copied. By applying perfect forwarding, the function now preserves the value category and allows moves where appropriate. The FIXME comment was removed since the intended behavior is now implemented ACKs for top commit: ryanofsky: Code review ACK 1977b9f. Thanks for the fix! I'm guessing this change became possible after 3a96cdc from #172 which started to support perfect forwarding Tree-SHA512: ff67a944aa7402f0652d562057f5a16e1190774a48a06e4f2502dbbedda86e40d4df99113e8a97b73d835bac883bad0705a285968ebd8d2e29e7bc96549f5d5f
2 parents 22bec91 + 1977b9f commit d94688e

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

include/mp/type-optional.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ void CustomBuildField(TypeList<std::optional<LocalType>>,
1717
{
1818
if (value) {
1919
output.setHas();
20-
// FIXME: should std::move value if destvalue is rref?
21-
BuildField(TypeList<LocalType>(), invoke_context, output, *value);
20+
BuildField(TypeList<LocalType>(), invoke_context, output, *std::forward<Value>(value));
2221
}
2322
}
2423

0 commit comments

Comments
 (0)