]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix handling of arrays in range access customization points
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 31 Oct 2019 13:17:42 +0000 (13:17 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 31 Oct 2019 13:17:42 +0000 (13:17 +0000)
commite62b4a5f321cc7eecfe7103ac84ae843ce4aca96
treed236c984006772b50b0af417599e440fc4027102
parentea75357d39615b09f047892d25619f0e74521ce2
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@277666 138bc75d-0d04-0410-961f-82ee72b054a4
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]