-
Notifications
You must be signed in to change notification settings - Fork 14
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
[DRAFT] One idea for the deduction guides #558
base: main
Are you sure you want to change the base?
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. |
569e4a3
to
eb9ce5e
Compare
eb9ce5e
to
4554ce7
Compare
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. |
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 typeAlloc
is 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_t
constructors and nowhere else. Thefrom_range_t
constructors (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::vector
orstd::flat_set
, either!