Fix handling of arrays in range access customization points
authorJonathan Wakely <jwakely@redhat.com>
Thu, 31 Oct 2019 13:17:42 +0000 (13:17 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 31 Oct 2019 13:17:42 +0000 (13:17 +0000)
commitbeaecb2d6b2f3c48740b7b8749ee2d2468c8dc14
treed236c984006772b50b0af417599e440fc4027102
parentd9a6144c87bd4c15c855785ced57907d66754861
Fix handling of arrays in range access customization points

This combines the overloads for arrays with the non-array overloads,
using if-constexpr to choose between the cases, and also enforces the
following:

- ADL should only be used for class types and enumeration types.
- ranges::begin should be ill-formed for rvalue arrays.
- ranges::end should be ill-formed for rvalue arrays, unbounded
  arrays, and arrays of incomplete type.
- ranges::size should be ill-formed for unbounded arrays.

* include/bits/range_access.h (ranges::begin): Combine array and
non-array overloads into one function template. Only use ADL for
classes and enums
(ranges::end, ranges::size): Likewise. Make unbounded arrays
ill-formed.
(ranges::rbegin, ranges::rend): Only use ADL for classes and enums.
Reformat _S_noexcept() functions to mirror operator() structure.
* testsuite/std/ranges/access/begin.cc: Check incomplete array.
* testsuite/std/ranges/access/end_neg.cc: New test.
* testsuite/std/ranges/access/size.cc: Check array of incomplete type.
* testsuite/std/ranges/access/size_neg.cc: New test.

From-SVN: r277666
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/range_access.h
libstdc++-v3/testsuite/std/ranges/access/begin.cc
libstdc++-v3/testsuite/std/ranges/access/end_neg.cc [new file with mode: 0644]
libstdc++-v3/testsuite/std/ranges/access/size.cc
libstdc++-v3/testsuite/std/ranges/access/size_neg.cc [new file with mode: 0644]