This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Re-implement LWG 2770 again: Fix tuple_size to work with structured bindings
ClosedPublic

Authored by EricWF on Jan 2 2017, 8:32 PM.

Details

Summary

This patch attempts to re-implement a fix for LWG 2770, but not the actual specified PR.

The PR for 2770 specifies tuple_size<T const> as only conditionally providing a ::value member. However C++17 structured bindings require tuple_size<T const> to be complete only if tuple_size<T> is also complete. Therefore this patch implements only provides the specialization tuple_size<T CV> iff tuple_size<T> is a complete type.

This fixes http://llvm.org/PR31513.

Diff Detail

Event Timeline

EricWF updated this revision to Diff 82830.Jan 2 2017, 8:32 PM
EricWF updated this revision to Diff 82832.
EricWF retitled this revision from to [libcxx] Re-implement LWG 2770 again: Fix tuple_size to work with structured bindings.
EricWF updated this object.
EricWF added reviewers: mclow.lists, rsmith.
EricWF added a subscriber: cfe-commits.

Use the correct patch file this time.

rsmith accepted this revision.Jan 3 2017, 12:35 AM
rsmith edited edge metadata.

LGTM, but a minor simplification seems possible.

include/__tuple
32

remove_cv looks redundant here, deduction already stripped the cv qualifiers.

This revision is now accepted and ready to land.Jan 3 2017, 12:35 AM
EricWF added inline comments.Jan 3 2017, 12:45 AM
include/__tuple
32

The remove_cv should be redundant, but without it Clang segfaults in clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformTemplateSpecializationType(clang::TypeLocBuilder&, clang::TemplateSpecializationTypeLoc, clang::TemplateName).

I haven't had time to file a Clang bug yet.

EricWF planned changes to this revision.Jan 3 2017, 1:48 AM

I thought this formulation worked for GCC and Clang but it appears it does not. I'll update with another attempt.

EricWF updated this revision to Diff 82850.Jan 3 2017, 1:49 AM
EricWF edited edge metadata.

@rsmith Could you re-review this please? It's a mostly different implementation.

This revision is now accepted and ready to land.Jan 3 2017, 1:49 AM
EricWF updated this revision to Diff 82851.Jan 3 2017, 1:54 AM
  • Remove redundant SFINAE.
EricWF updated this revision to Diff 82867.Jan 3 2017, 4:58 AM
EricWF updated this object.
  • SFINAE the specializations on sizeof(tuple_size<T>) instead of decltype(tuple_size<T>::value).
EricWF added inline comments.Jan 3 2017, 5:28 AM
include/__tuple
29

Without this extra enable_if, GCC will diagnose each of these three specializations as ambiguous.

mpark updated this object.Jan 4 2017, 1:24 AM
mpark accepted this revision.Jan 4 2017, 1:42 AM
mpark added a reviewer: mpark.
mpark added a subscriber: mpark.

That was fun =D

EricWF updated this revision to Diff 83145.Jan 4 2017, 2:48 PM
EricWF edited edge metadata.

Updating with final changes.

EricWF closed this revision.Jan 4 2017, 2:49 PM