Page MenuHomePhabricator

Implement deduction guides for std::function (P0433).
AbandonedPublic

Authored by Quuxplusone on Jul 15 2019, 9:15 AM.

Details

Summary

P0433 (adopted in C++17) added two deduction guides for std::function.
This patch implements those deduction guides in libc++.

__function_ctad<_Tp> is really tedious. It could be simplified by:

  • using macros to generate the 2x2x2x2 = 16 partial specializations (MSVC does this)
  • using noexcept(_Np) to deduce the noexcept-specification, reducing the number of partial specializations by half (libstdc++ does this)
  • completely ignoring the possibility of volatile-qualified operator() overloads, reducing the number of partial specializations by half (libstdc++ does this)
  • deciding that it would be easier to ask LWG to revert this whole part of P0433, than bother to implement it

Diff Detail

Repository
rCXX libc++

Event Timeline

Quuxplusone created this revision.Jul 15 2019, 9:15 AM

Add the other deduction guide from _Rp(*)(_ArgTypes...). (Uploaded an incomplete diff the first time.)

It's a shame to have duplicated work, but I already have a patch for this: https://reviews.llvm.org/D54410

Quuxplusone abandoned this revision.Wed, Jul 24, 7:39 PM

Superseded by D54410, which has now been landed.