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

Add ext_iterator_interface_compat, a portable alternative to iterator_interface. #13

Merged
merged 4 commits into from
Nov 7, 2024

Conversation

camio
Copy link
Member

@camio camio commented Oct 18, 2024

The iterator_interface class template requires deducing *this support which came in C++23 and is not yet widely available. This PR introduces an alternative class template ext_iterator_interface_compat which requires an additional template argument (for RAII support), but otherwise has the same functionality of iterator_interface without the deducing *this dependency.

  • The new class was prefixed with ext_ to make it clear that this is an extension to the iterator_interface paper. It may be interesting to adopt this as a convention for Beman libraries in general.
  • Added a build option, BEMAN_ITERATOR_INTERFACE26_USE_DEDUCING_THIS, that
    indicates whether deducing *this is available. 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.
  • If deducing *this is available, ext_iterator_interface_compat is implemented with iterator_interface. If it is not available, instantiation of iterator_interface results in a helpful error message and ext_interator_interface_compat is implemented using an in-source copy of Boost.Stl_Interfaces with the following modifications:
    • It was relicenced to "Apache-2.0 WITH LLVM-exception" per permission from Zach Laine
    • It uses beman::iterator_interface26::iterator_interface_access for access control for consistency.
  • Testing support was modified to follow the pattern described in Do only include(CTest) if dashboard is needed exemplar#60 (comment)

The intent is to add documentation in a separate PR once this gets moved in.

Fixes #10.

@camio camio changed the title add cpp20 support Add stl_interfaces fallback when deducing this is unavailable. Oct 18, 2024
@neatudarius neatudarius self-requested a review October 21, 2024 14:34
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 bemanproject#10 and depends on bemanproject#12.
@camio camio force-pushed the add-cpp20-support branch from 843054c to 8cf8b53 Compare October 21, 2024 15:30
camio added 3 commits November 1, 2024 18:16
This fixes an issue where testing wasn't enabled by default. I followed
the suggestion made at bemanproject/exemplar#60 (comment)
This is more ergonomic than having two different versions of
interator_interface without having different names.
@camio camio changed the title Add stl_interfaces fallback when deducing this is unavailable. Add ext_iterator_interface_compat for a portable alternative to iterator_interface. Nov 6, 2024
@camio camio changed the title Add ext_iterator_interface_compat for a portable alternative to iterator_interface. Add ext_iterator_interface_compat, a portable alternative to iterator_interface. Nov 6, 2024
@camio camio changed the title Add ext_iterator_interface_compat, a portable alternative to iterator_interface. Add ext_iterator_interface_compat, a portable alternative to iterator_interface. Nov 6, 2024
@camio camio changed the title Add ext_iterator_interface_compat, a portable alternative to iterator_interface. Add ext_iterator_interface_compat, a portable alternative to iterator_interface. Nov 6, 2024
@camio camio marked this pull request as ready for review November 6, 2024 23:44
@camio camio requested a review from steve-downey as a code owner November 6, 2024 23:44
@camio camio requested a review from neatudarius November 6, 2024 23:44
Copy link
Member

@steve-downey steve-downey left a comment

Choose a reason for hiding this comment

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

I don't think this was part of this change, but
https://github.com/beman-project/iterator_interface/pull/13/files#diff-7d7f79f7e81b3a5127eb407b43c39c90befb00593ef4d6721ee28edf4e87f9f9R179-R184
is now generating a dangling temporary warning?

@camio
Copy link
Member Author

camio commented Nov 7, 2024

is now generating a dangling temporary warning?

Added #15 to address this. I couldn't figure out the cause with an initial look.

@camio camio merged commit 2a3c0e4 into bemanproject:main Nov 7, 2024
4 checks passed
@camio camio deleted the add-cpp20-support branch November 7, 2024 21:57
Copy link
Member

@neatudarius neatudarius left a comment

Choose a reason for hiding this comment

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

LGTM+

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.

Address deducing *this dependency
3 participants