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

Eric Fiselier via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 2 20:32:10 PST 2017


EricWF created this revision.
EricWF added reviewers: mclow.lists, rsmith.
EricWF added a subscriber: cfe-commits.

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 `decltype(tuple_size<T>::value)` is well formed.

Note that the specialization is still provided when `tuple_size<T>::value` is well-formed but not a constant expression, meaning that`tuple_size<T const>` will be ill-formed and generate a diagnostic when used. I believe this behavior is preferable to silently not specializing `tuple_size<T CV>` because it helps diagnose users who provide incorrect `tuple_size` specializations.

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


https://reviews.llvm.org/D28222

Files:
  include/__tuple
  test/libcxx/test/config.py
  test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_structured_bindings.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28222.82830.patch
Type: text/x-patch
Size: 7571 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170103/58fd5d16/attachment.bin>


More information about the cfe-commits mailing list