2020-03-11 Patrick Palka <ppalka@redhat.com>
+ * include/std/ranges (split_view::_OuterIter::_OuterIter): Typo fix,
+ 'address' -> 'std::__addressof'.
+ * testsuite/std/ranges/adaptors/split.cc: Test taking the split_view of
+ a non-forward input_range.
+ * testsuite/util/testsuite_iterators.h (output_iterator_wrapper): Make
+ default constructor protected instead of deleted, like with
+ input_iterator_wrapper.
+ (test_range::iterator): Add comment explaining that this type is used
+ only when the underlying wrapper is input_iterator_wrapper or
+ output_iterator_wrapper. Remove delegating defaulted constructor so
+ that the inherited default constructor is used instead.
+
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
constexpr explicit
_OuterIter(_Parent& __parent) requires (!forward_range<_Base>)
- : _M_parent(address(__parent))
+ : _M_parent(std::__addressof(__parent))
{ }
constexpr
using __gnu_test::test_range;
using __gnu_test::forward_iterator_wrapper;
+using __gnu_test::input_iterator_wrapper;
namespace ranges = std::ranges;
namespace views = std::ranges::views;
static_assert( noexcept(iter_swap(b, b2)) );
}
+void
+test08()
+{
+ char x[] = "the quick brown fox";
+ test_range<char, input_iterator_wrapper> rx(x, x+sizeof(x)-1);
+ auto v = rx | views::split(' ');
+ auto i = v.begin();
+ VERIFY( ranges::equal(*i, "the"sv) );
+ ++i;
+ VERIFY( ranges::equal(*i, "quick"sv) );
+ ++i;
+ VERIFY( ranges::equal(*i, "brown"sv) );
+ ++i;
+ VERIFY( ranges::equal(*i, "fox"sv) );
+ ++i;
+ VERIFY( i == v.end() );
+}
+
int
main()
{
test05();
test06();
test07();
+ test08();
}
struct output_iterator_wrapper
: public std::iterator<std::output_iterator_tag, T, std::ptrdiff_t, T*, T&>
{
+ protected:
+ output_iterator_wrapper() : ptr(0), SharedInfo(0)
+ { }
+
+ public:
typedef OutputContainer<T> ContainerType;
T* ptr;
ContainerType* SharedInfo;
}
#if __cplusplus >= 201103L
- output_iterator_wrapper() = delete;
-
output_iterator_wrapper(const output_iterator_wrapper&) = default;
output_iterator_wrapper&
template<typename T, template<typename> class Iter>
class test_range
{
- // Adds default constructor to Iter<T> if needed
+ // Exposes the protected default constructor of Iter<T> if needed. This
+ // is needed only when Iter is input_iterator_wrapper or
+ // output_iterator_wrapper, because legacy forward iterators and beyond
+ // are already default constructible.
struct iterator : Iter<T>
{
using Iter<T>::Iter;
- iterator() : Iter<T>(nullptr, nullptr) { }
-
using Iter<T>::operator++;
iterator& operator++() { Iter<T>::operator++(); return *this; }