-
Notifications
You must be signed in to change notification settings - Fork 155
Hotfix -DREFLECTCPP_USE_STD_EXPECTED=ON #571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hotfix -DREFLECTCPP_USE_STD_EXPECTED=ON #571
Conversation
Signed-off-by: Daniel M. Sahu <[email protected]>
Summary of ChangesHello @danielmohansahu, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request provides a hotfix to address a compilation error that occurs when building with the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request aims to resolve a build issue when REFLECTCPP_USE_STD_EXPECTED=ON is enabled. However, the proposed change to the error method in std::bad_expected_access is incorrect. Removing the this keyword from the C++23 deducing this syntax without providing a valid alternative results in an invalid function signature, which will likely lead to a compilation error. If the compiler does not support C++23's deducing this feature, a more comprehensive fix involving explicit const&, &, and && overloads for the error() method would be required.
| template <typename Self> | ||
| [[nodiscard]] | ||
| auto error(this Self&& self) noexcept { | ||
| auto error(Self&& self) noexcept { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 {There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
@danielmohansahu , I am replacing this with #572 |
Minor change required to locally build with
-DREFLECTCPP_USE_STD_EXPECTED=ON.Addresses #570 .