[gcc(refs/users/ppalka/heads/libstdcxx-constrained-algos-adaptors)] Add missing piece of [ranges] from the end of the synopsis

Patrick Palka ppalka@gcc.gnu.org
Thu Feb 6 23:23:00 GMT 2020


https://gcc.gnu.org/g:360957e795aa3c2b9ae70260c9e92506c7962773

commit 360957e795aa3c2b9ae70260c9e92506c7962773
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Feb 5 10:47:07 2020 -0500

    Add missing piece of [ranges] from the end of the synopsis

Diff:
---
 libstdc++-v3/include/std/ranges | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 5ec4a7a..231e429 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -2609,8 +2609,7 @@ namespace views
 	    const auto __end = ranges::end(_M_parent->_M_base);
 	    if (_M_current == __end)
 	      return *this;
-	    const auto __pbegin = ranges::begin(_M_parent->_M_pattern);
-	    const auto __pend = ranges::end(_M_parent->_M_pattern);
+	    const auto [__pbegin, __pend] = subrange{_M_parent->_M_pattern};
 	    if (__pbegin == __pend)
 	      ++_M_current;
 	    else
@@ -2660,13 +2659,7 @@ namespace views
 	  constexpr bool
 	  __at_end() const
 	  {
-	    // XXX: the spec says
-	    // auto [__pcur, __pend] = subrange{_M_i._M_parent->_M_pattern};
-	    // but a subrange cannot be decomposed with a structured binding
-	    auto& __pattern = _M_i._M_parent->_M_pattern;
-	    auto __pcur = ranges::begin(__pattern);
-	    auto __pend = ranges::end(__pattern);
-
+	    auto [__pcur, __pend] = subrange{_M_i._M_parent->_M_pattern};
 	    auto __end = ranges::end(_M_i._M_parent->_M_base);
 	    if constexpr (__detail::__tiny_range<_Pattern>)
 	      {
@@ -3353,6 +3346,22 @@ namespace views
   } // namespace views
 
 } // namespace ranges
+
+  namespace views = ranges::views;
+
+  template<typename _Iter, typename _Sent, ranges::subrange_kind _Kind>
+    struct tuple_size<ranges::subrange<_Iter, _Sent, _Kind>>
+    : integral_constant<size_t, 2>
+    { };
+
+  template<typename _Iter, typename _Sent, ranges::subrange_kind _Kind>
+    struct tuple_element<0, ranges::subrange<_Iter, _Sent, _Kind>>
+    { using type = _Iter; };
+
+  template<typename _Iter, typename _Sent, ranges::subrange_kind _Kind>
+    struct tuple_element<1, ranges::subrange<_Iter, _Sent, _Kind>>
+    { using type = _Sent; };
+
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 #endif // library concepts



More information about the Libstdc++-cvs mailing list