Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions runtime/core/result.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ class Result final {
/// Value copy constructor.
/* implicit */ Result(const T& val) : value_(val), hasValue_(true) {}

/// Value move constructor.
/* implicit */ Result(T&& val) : value_(std::move(val)), hasValue_(true) {}
/// Value forwarding constructor.
/* implicit */ Result(T&& val)
: value_(std::forward<T>(val)), hasValue_(true) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test that wouldve caught the previous bad behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Where are the tests for this type?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -73 to +75
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misread what was going on here originally. This isn't a template function (though it is a member of a template class), so this really is an rvalue reference. I think that the original code is probably correct; std::forward is for arguments to template functions (https://en.cppreference.com/w/cpp/utility/forward.html).


/// Result move constructor.
/* implicit */ Result(Result&& rhs) noexcept : hasValue_(rhs.hasValue_) {
Expand Down
Loading