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
2 changes: 1 addition & 1 deletion include/rfl/Result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ class std::bad_expected_access<rfl::Error> : public bad_expected_access<void> {

template <typename Self>
[[nodiscard]]
auto error(this Self&& self) noexcept {
auto error(Self&& self) noexcept {

Choose a reason for hiding this comment

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

critical

The removal of the this keyword from the error method's signature on this line fundamentally changes its meaning. In C++23, this Self&& self is used for deducing this, where self refers to the object itself. By removing this, Self&& self becomes a regular parameter. This makes the function signature incorrect for a member function intended to return the err_ member of the std::bad_expected_access instance, as Self cannot be deduced from a non-existent parameter, and self.err_ would attempt to access a member of the parameter self, not the class's err_. This will lead to a compilation error. If the compiler does not support C++23's deducing this, the correct approach is to provide explicit const&, &, and && overloads for the error() method, which would also require removing the template <typename Self> line.

auto error(this Self&& self) noexcept {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, perhaps this indicates I'm just not using a sufficiently new version of GCC?

Copy link
Contributor

Choose a reason for hiding this comment

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

@danielmohansahu I think so.

However, I think we don't have to use this feature here. I will take a closer look tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I'll leave this PR open for continuity, but please close it as appropriate.

return std::forward<Self>(self).err_;
}

Expand Down
Loading