-
Notifications
You must be signed in to change notification settings - Fork 32
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 default_sequence_traits #207
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add flux::default_sequence_traits, a base class containing sensible default implementations of (at the moment) read_at_unchecked, move_at and move_at_unchecked. Also, change the sequence concept definition to require that these customisation points are implemented (or in practise, that sequence_traits<T> inherits from default_sequence_traits)
We now always use the version that the sequence impl provides
Temporarily, at least
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #207 +/- ##
=======================================
Coverage 98.30% 98.30%
=======================================
Files 70 71 +1
Lines 2479 2485 +6
=======================================
+ Hits 2437 2443 +6
Misses 42 42 ☔ View full report in Codecov by Sentry. |
This is annoying
MSVC is complaining that `using default_sequence_traits::for_each_while` in `drop_adaptor::sequence_traits` references an unknown base class, which doesn't make a lot of sense as it very definitely does inherit from it... but never mind, we'll work around it anyway
Strangely, GCC and Clang didn't complain about this, and neither did MSVC when building locally -- only in CI. But it definitely looks wrong.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
sequence
concept has several optional customisation points, for exampleread_at_unchecked()
andfor_each_while()
, for which we can provide a reasonable default if the sequence implementation does not.Previously this was handled by the wrapper functions (
flux::read_at_unchecked
etc) examining thesequence_traits<T>
struct and using the customised function if it existed, otherwise falling back to their default implementation.This PR changes the arrangement somewhat. Rather than being strictly optional, the
sequence
concept now requires that all customisation points are implemented. We can still provide default implementations, but this is now handled by havingsequence_traits<T>
inherit from a new base classdefault_sequence_traits
. (In principle using this base class is not required by the sequence concept, but in practise everyone will want to use it.)This has the advantage that user-defined customisations can now be concept-checked; that is, if a user provides an incompatible signature for e.g.
for_each_while
in theirsequence_traits
, it will hide the default implementation, and result in a compile error; previously, the incompatible signature would just have been ignored and the default impl would silently have been used.For complicated sequence implementations (e.g. the
zip
andcartesian_product
families), this means that we also need to be explicit about when we're using the default impls vs using customised versions. This is a good thing.