public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2356] libstdc++: Give split_view::_Sentinel a default ctor [PR101214]
@ 2021-07-16 13:46 Patrick Palka
  0 siblings, 0 replies; only message in thread
From: Patrick Palka @ 2021-07-16 13:46 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:73464a472aa4e86359f1a5dc529394fe5152fec0

commit r12-2356-g73464a472aa4e86359f1a5dc529394fe5152fec0
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Jul 16 09:44:32 2021 -0400

    libstdc++: Give split_view::_Sentinel a default ctor [PR101214]
    
    This gives the new split_view's sentinel type a defaulted default
    constructor, something which was overlooked in r12-1665.  This patch
    also fixes a couple of other issues with the new split_view as reported
    in the PR.
    
            PR libstdc++/101214
    
    libstdc++-v3/ChangeLog:
    
            * include/std/ranges (split_view::split_view): Use std::move.
            (split_view::_Iterator::_Iterator): Remove redundant
            default_initializable constraint.
            (split_view::_Sentinel::_Sentinel): Declare.
            * testsuite/std/ranges/adaptors/split.cc (test02): New test.

Diff:
---
 libstdc++-v3/include/std/ranges                     |  6 ++++--
 libstdc++-v3/testsuite/std/ranges/adaptors/split.cc | 11 +++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index f552caa9d5b..df74ac9dc19 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -3306,7 +3306,7 @@ namespace views::__adaptor
 	&& constructible_from<_Pattern, single_view<range_value_t<_Range>>>
     constexpr
     split_view(_Range&& __r, range_value_t<_Range> __e)
-      : _M_pattern(views::single(__e)),
+      : _M_pattern(views::single(std::move(__e))),
 	_M_base(views::all(std::forward<_Range>(__r)))
     { }
 
@@ -3364,7 +3364,7 @@ namespace views::__adaptor
       using value_type = subrange<iterator_t<_Vp>>;
       using difference_type = range_difference_t<_Vp>;
 
-      _Iterator() requires default_initializable<iterator_t<_Vp>> = default;
+      _Iterator() = default;
 
       constexpr
       _Iterator(split_view* __parent,
@@ -3429,6 +3429,8 @@ namespace views::__adaptor
       { return __x._M_cur == _M_end && !__x._M_trailing_empty; }
 
     public:
+      _Sentinel() = default;
+
       constexpr explicit
       _Sentinel(split_view* __parent)
 	: _M_end(ranges::end(__parent->_M_base))
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/split.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/split.cc
index 02c6073a503..b4e01fea6e4 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/split.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/split.cc
@@ -46,6 +46,16 @@ test01()
   VERIFY( ranges::equal(ints, (int[]){1,2,3,4}) );
 }
 
+void
+test02()
+{
+  // PR libstdc++/101214
+  auto v = views::iota(0) | views::take(5) | views::split(0);
+  static_assert(!ranges::common_range<decltype(v)>);
+  static_assert(std::default_initializable<decltype(v.end())>);
+  static_assert(std::sentinel_for<decltype(v.end()), decltype(v.begin())>);
+}
+
 // The following testcases are adapted from lazy_split.cc.
 namespace from_lazy_split_cc
 {
@@ -189,6 +199,7 @@ int
 main()
 {
   test01();
+  test02();
 
   from_lazy_split_cc::test01();
   from_lazy_split_cc::test02();


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-16 13:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16 13:46 [gcc r12-2356] libstdc++: Give split_view::_Sentinel a default ctor [PR101214] Patrick Palka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).