-
Notifications
You must be signed in to change notification settings - Fork 14
Generalized type erasure of concept types with or without heap allocation #356
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
Merged
Conversation
This file contains hidden or 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
Use the Fn concepts instead and templatize the Split iterators. This avoids holding a pointer to a possibly-temporary function object.
Generalize Box<DynError>::from(Error auto) to work with any DynConcept type erasure, with Box<DynC>::from(C auto).
The reference may be an rvalue and it may need to be used as an rvalue in order to get the desired type from it.
This can be useful when it lives on the stack in order to extend its lifetime.
Now that everything can be constexpr we can just max_by and min_by in the implementation of them.
…ifiers appear in subdoc
On clang 16 (but not after for some reason) the concept will not match
any type `F` that is pure virtual. This prevented FnMut from matching
against DynFnMut.
More precisely:
```
template <class T>
concept C = requires(T t) { t.foo(); }
```
This won't match a pure virtual `T` with a mutable `foo()` on clang 16.
It works on 17+ and with GCC 13 and MSVC (at least one version).
`requires(T& t)` does the right thing universally, as in:
```
template <class T>
concept C = requires(T& t) { t.foo(); }
```
Add a rule to STYLE.md and update all concepts that wrote a value type
in a rule to be reference types.
Also test it more!
Use Box<DynFn> instead.
These are superceded by the general concept-type-erasure mechanism of DynConcept and the DynFn/Mut/Once type-erasure support types.
Box::with_args() will pass the args to the ctor of T to construct it directly on the heap.
Closed
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
dyn()function requires a template parameter of the type erasure classDynCof conceptCcurrently.Whereas
into()does not, since it constructs a marker type and then uses type deduction to determine what to construct.We should in theory be able to do the same with
Dynand have it defer choosing the reference type until the operator is called, but it may be tricky to maintain const correctness.Here's a test demo envionment in which this could be explored: https://godbolt.org/z/Y5nGe4E16
Filed #358 for this enchancement.