libstdc++: LWG 3286 ranges::size is not required to be valid after ...
authorPatrick Palka <ppalka@redhat.com>
Mon, 9 Mar 2020 16:10:16 +0000 (12:10 -0400)
committerPatrick Palka <ppalka@redhat.com>
Wed, 11 Mar 2020 04:40:33 +0000 (00:40 -0400)
commit8f0d8cd852255f9767626b084fc7926cbbea166f
tree3de1722b58635a50bb205d01a322b0066e6d7055
parent5115542a5cc17c5096e6e498c363e75d5bc14276
libstdc++: LWG 3286 ranges::size is not required to be valid after ...

... a call to ranges::begin on an input range.

This implements LWG 3286.  The new wording for the single-argument constructor
for subrange is implemented by splitting the constructor into two delegating
constructors, one constrained by _S_store_size and the other by !_S_store_size.

Tested on x86_64-pc-linux-gnu, both added tests fail before the patch and pass
with the patch.

libstdc++-v3/ChangeLog:

LWG 3286 ranges::size is not required to be valid after a call to
ranges::begin on an input range
* include/std/ranges (subrange::subrange): Split single-argument
constructor into two, one constrained by _S_store_size and another by
!_S_store_size.
(take_view::begin): Call size() before calling ranges::begin(_M_base).
* testsuite/std/ranges/adaptors/lwg3286.cc: New test.
* testsuite/std/ranges/subrange/lwg3286.cc: New test.
libstdc++-v3/ChangeLog
libstdc++-v3/include/std/ranges
libstdc++-v3/testsuite/std/ranges/adaptors/lwg3286.cc [new file with mode: 0644]
libstdc++-v3/testsuite/std/ranges/subrange/lwg3286.cc [new file with mode: 0644]