base() const
{ return _M_current; }
#else
- constexpr iterator_type
- base() const &
-#if __cpp_lib_concepts
- requires copy_constructible<iterator_type>
-#endif
+ constexpr const iterator_type&
+ base() const & noexcept
{ return _M_current; }
constexpr iterator_type
return *this;
}
- constexpr _It
- base() const &
- noexcept(is_nothrow_copy_constructible_v<_It>)
- requires copy_constructible<_It>
+ constexpr const _It&
+ base() const & noexcept
{ return _M_current; }
constexpr _It
--- /dev/null
+// Copyright (C) 2021 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+// Verify LWG 3391 changes.
+
+#include <iterator>
+#include <ranges>
+
+#include <testsuite_iterators.h>
+
+using __gnu_test::test_range;
+using __gnu_test::input_iterator_wrapper_nocopy;
+
+void
+test01()
+{
+ extern test_range<int, input_iterator_wrapper_nocopy> rx;
+ auto v = rx | std::views::take(5);
+ std::ranges::begin(v) != std::ranges::end(v);
+}
static_assert(std::input_iterator<move_only_iterator>);
template<typename T>
- concept has_member_base = requires (T t) { std::forward<T>(t).base(); };
+ concept has_member_base = requires (T t) {
+ // LWG 3391 made the const& overload of move_iterator::base()
+ // unconstrained and return a const reference. So rather than checking
+ // whether base() is valid (which is now trivially true in an unevaluated
+ // context), the below now checks whether decay-copying base() is valid.
+ [](auto){}(std::forward<T>(t).base());
+ };
using move_only_move_iterator = std::move_iterator<move_only_iterator>;