diff options
author | Patrick Palka <ppalka@redhat.com> | 2021-10-20 21:34:18 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2021-10-20 21:34:18 -0400 |
commit | a2c2dcc6ca205a8c5c76b04ef2eb4fb097dcb069 (patch) | |
tree | 613a9b16d9b5da3ac11c73b49b5c8532b18dd6b9 | |
parent | 0fac85a24f40ef6098b756e8e8655205f4bfbf3e (diff) | |
download | gcc-a2c2dcc6ca205a8c5c76b04ef2eb4fb097dcb069.tar.gz |
libstdc++: Implement LWG 3481 change to ranges::viewable_range
libstdc++-v3/ChangeLog:
* include/bits/ranges_base.h (viewable_range): Adjust as per
LWG 3481.
* testsuite/std/ranges/adaptors/all.cc (test07): New test.
-rw-r--r-- | libstdc++-v3/include/bits/ranges_base.h | 3 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/std/ranges/adaptors/all.cc | 15 |
2 files changed, 17 insertions, 1 deletions
diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h index 7801b2fd023..43b0b9f7bf3 100644 --- a/libstdc++-v3/include/bits/ranges_base.h +++ b/libstdc++-v3/include/bits/ranges_base.h @@ -688,7 +688,8 @@ namespace ranges /// A range which can be safely converted to a view. template<typename _Tp> concept viewable_range = range<_Tp> - && (borrowed_range<_Tp> || view<remove_cvref_t<_Tp>>); + && ((view<remove_cvref_t<_Tp>> && constructible_from<remove_cvref_t<_Tp>, _Tp>) + || (!view<remove_cvref_t<_Tp>> && borrowed_range<_Tp>)); // [range.iter.ops] range iterator operations diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/all.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/all.cc index 9a6a31e6cb4..ce1384c2890 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/all.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/all.cc @@ -159,6 +159,20 @@ test06() static_assert(!noexcept(views::all(BorrowedRange<false, false>(x)))); } +void +test07() +{ + // LWG 3481 + struct view_t : ranges::empty_view<int> { // move-only view + view_t(const view_t&) = delete; + view_t(view_t&&) = default; + view_t& operator=(const view_t&) = delete; + view_t& operator=(view_t&&) = default; + }; + static_assert(std::movable<view_t> && !std::copyable<view_t>); + static_assert(!ranges::viewable_range<view_t&>); +} + int main() { @@ -168,4 +182,5 @@ main() static_assert(test04()); test05(); test06(); + test07(); } |