Page MenuHomePhabricator

[libc++] Implement CTAD for std::tuple
ClosedPublic

Authored by ldionne on Jul 24 2019, 10:21 AM.

Details

Summary

Apparently all the tests were already there, but the actual deduction
guides weren't in place. The implicitly CTAD does the job given the
current set of constructors, however changing the constructors can
break that.

This commit adds the actual guides specified in the Standard to make
libc++ (1) closer to the Standard and (2) more resistent to changes
in std::tuple's constructors.

Diff Detail

Repository
rL LLVM

Event Timeline

ldionne created this revision.Jul 24 2019, 10:21 AM

Looks plausible to me, but:

IMHO, please rename std/utilities/tuple/tuple.tuple/tuple.cnstr/implicit_deduction_guides.pass.cpp to std/utilities/tuple/tuple.tuple/tuple.cnstr/deduct.pass.cpp for consistency with the other CTAD tests.

The existing tests are completely missing any test cases for construction from pair, e.g. std::tuple t = std::make_pair(std::ref(i), 2); and std::tuple t = std::pair(std::ref(i), 2);; please add some tests involving pair.

The existing tests are missing any deduct.fail.cpp. I guess actually we don't expect std::tuple t(random, args...) to ever fail to compile; but maybe you can imagine a corner case that I haven't.

ldionne updated this revision to Diff 214172.Aug 8 2019, 9:30 AM

Address Arthur's comments

The existing tests are missing any deduct.fail.cpp. I guess actually we don't expect std::tuple t(random, args...) to ever fail to compile; but maybe you can imagine a corner case that I haven't.

I can't think of anything either.

This revision is now accepted and ready to land.Aug 12 2019, 11:21 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2019, 11:29 AM