Draft
Conversation
…ypes into dev-jbcoe-deduction-guides
ebe5483 to
569e4a3
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #558 +/- ##
=======================================
Coverage 99.60% 99.60%
=======================================
Files 11 11
Lines 750 750
Branches 76 76
=======================================
Hits 747 747
Misses 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
569e4a3 to
eb9ce5e
Compare
eb9ce5e to
4554ce7
Compare
Owner
|
Thanks @Quuxplusone we don't want to be doing things differently to I've been recovering from a cold so will be slow to properly respond to this. On a first look, a minor nit is that we try to make indirect.h and polymorphic.h work as stand-alone single-include headers (for godbolt). I think your PR lightly couples them to feature_check.h. It would, however, be easy to clean up post-merge. |
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
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.
Posting as a PR just so that the CI will run (I hope). This all works on my local machine.
I see now the problem with not-constraining the less specific deduction guide.
Before we can do overload resolution between this deduction guide and the more specific one, we must fully evaluate this one's type... which requires evaluating
std::allocator_traits<Alloc>::template rebind_alloc<Value>, which explodes because the deduced typeAllocis not actually an allocator type. So, even though the other deduction guide would have been the better match, this one explodes before we even get to the overload-resolution step.Here's a reduced example of what I'm talking about: https://godbolt.org/z/jWzn5PGn6
It looks to me as if the STL currently doesn't try to rebind allocators in deduction guides at all, with the sole exception of
flat_set/flat_map, which rebind specifically in theirfrom_range_tconstructors and nowhere else. Thefrom_range_tconstructors (unlike the allocator-extended copy constructor) cannot deduce the allocator type in any other way, so it would be a hard error to pass in a non-allocator type there anyway.So I think there would be good precedent for adopting an approach like the one in this PR. But I do recognize that this reduces the surface area of the library a little bit: I had to change some unit tests to avoid testing the pattern that will no longer work after this patch. However, notice that the analogous tests wouldn't pass for
std::vectororstd::flat_set, either!