Skip to content

Conversation

@danielmohansahu
Copy link
Contributor

Minor change required to locally build with -DREFLECTCPP_USE_STD_EXPECTED=ON.

Addresses #570 .

Signed-off-by: Daniel M. Sahu <dan@overland.ai>
@gemini-code-assist
Copy link

Summary of Changes

Hello @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 -DREFLECTCPP_USE_STD_EXPECTED=ON flag. The change involves a minor syntax adjustment in a template function signature to ensure broader C++ standard compatibility, allowing the project to build successfully under the specified configuration.

Highlights

  • C++ Standard Compatibility: Removed the C++23 explicit object parameter this from the error method signature in rfl::Result.hpp to ensure compatibility with older C++ standards when REFLECTCPP_USE_STD_EXPECTED is enabled, resolving a local build issue.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 {

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.

@liuzicheng1987
Copy link
Contributor

@danielmohansahu , I am replacing this with #572

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants