Skip to content
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

Generate a CMake-time error if compiler+flags lacks deducing this support #12

Merged
merged 4 commits into from
Oct 21, 2024

Conversation

camio
Copy link
Collaborator

@camio camio commented Oct 18, 2024

This improves the user experience when incompatible flags are used. It
also is a first step toward resolving #10.

…port

This improves the user experience when incompatible flags are used. It
also is a first step toward resolving beman-project#10.
camio added a commit to camio/iterator_interface26 that referenced this pull request Oct 18, 2024
Added a build option, BEMAN_ITERATOR_INTERFACE26_USE_DEDUCING_THIS, that
switches between the deducing this implementation and that used by
stl_interfaces. It defaults to whether the compiler supports deducing this.

This element of configuration is placed in a generated config.hpp. This
was chosen, as opposed to using a define passed as a compiler flag, to
avoid ODR violations with larger projects with incoherent flag usage.

The `iterator_interface_access` struct was moved to its own header since
it is needed by both the deducing this and stl_interfaces implementations.
The stl_interfaces implementation was modifed to use this so it better
conforms to the paper.

Some cleanup is still needed before this gets merged in:

- There are optional26 remnants where stl_interfaces was brought
  in from.
- Documentation is needed to explain when the extra template parameter
  is required. BEMAN_ITERATOR_INTERFACE26_USE_DEDUCING_THIS() should
  probably also be mentioned in that context.

The intent is to address these once the overall approach has
consensus.

Fixes beman-project#10 and depends on beman-project#12.
@neatudarius neatudarius self-requested a review October 21, 2024 14:32
@camio
Copy link
Collaborator Author

camio commented Oct 21, 2024

Weird, it looks like clang18 has deducing this support, but isn't advertising it with the __cpp_explicit_this_parameter define.

@camio
Copy link
Collaborator Author

camio commented Oct 21, 2024

I added a workaround for it and filed a bug report. The build now succeeds on clang 18 and 14 and fails on clang 17 and gcc 13, which is expected.

@camio camio merged commit 88ec881 into beman-project:main Oct 21, 2024
2 of 4 checks passed
@camio camio deleted the cmake-time-deducing-this-error branch October 21, 2024 15:18
camio added a commit to camio/iterator_interface26 that referenced this pull request Oct 21, 2024
Added a build option, BEMAN_ITERATOR_INTERFACE26_USE_DEDUCING_THIS, that
switches between the deducing this implementation and that used by
stl_interfaces. It defaults to whether the compiler supports deducing this.

This element of configuration is placed in a generated config.hpp. This
was chosen, as opposed to using a define passed as a compiler flag, to
avoid ODR violations with larger projects with incoherent flag usage.

The `iterator_interface_access` struct was moved to its own header since
it is needed by both the deducing this and stl_interfaces implementations.
The stl_interfaces implementation was modifed to use this so it better
conforms to the paper.

Some cleanup is still needed before this gets merged in:

- There are optional26 remnants where stl_interfaces was brought
  in from.
- Documentation is needed to explain when the extra template parameter
  is required. BEMAN_ITERATOR_INTERFACE26_USE_DEDUCING_THIS() should
  probably also be mentioned in that context.

The intent is to address these once the overall approach has
consensus.

Fixes beman-project#10 and depends on beman-project#12.
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