]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/testsuite/util/testsuite_iterators.h
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / util / testsuite_iterators.h
index 70c1f9b66894e9c58043ecb7c1d52ac2918fe124..e01d7daea5da1adbca87befdc5a005f659ab2637 100644 (file)
@@ -1,7 +1,7 @@
 // -*- C++ -*-
 // Iterator Wrappers for the C++ library testsuite.
 //
-// Copyright (C) 2004-2019 Free Software Foundation, Inc.
+// Copyright (C) 2004-2020 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
@@ -95,7 +95,7 @@ namespace __gnu_test
 #if __cplusplus >= 201103L
       template<class U>
       typename std::enable_if<std::is_assignable<T&, U>::value>::type
-      operator=(U&& new_val)
+      operator=(U&& new_val) const
       {
        ITERATOR_VERIFY(SharedInfo->writtento[ptr - SharedInfo->first] == 0);
        SharedInfo->writtento[ptr - SharedInfo->first] = 1;
@@ -184,7 +184,7 @@ namespace __gnu_test
     void operator,(const T&, const output_iterator_wrapper<U>&) = delete;
 #endif
 
-#if __cplusplus >= 2011L
+#if __cplusplus >= 201103L
   using std::remove_cv;
 #else
   template<typename T> struct remove_cv { typedef T type; };
@@ -677,21 +677,12 @@ namespace __gnu_test
 
          friend bool operator==(const sentinel& s, const I& i)
          { return s.end == i.ptr; }
-
-         friend bool operator!=(const sentinel& s, const I& i)
-         { return !(s == i); }
-
-         friend bool operator==(const I& i, const sentinel& s)
-         { return s == i; }
-
-         friend bool operator!=(const I& i, const sentinel& s)
-         { return !(s == i); }
        };
 
       auto
       get_iterator(T* p)
       {
-       if constexpr (std::default_constructible<Iter<T>>)
+       if constexpr (std::default_initializable<Iter<T>>)
          return Iter<T>(p, &bounds);
        else
          return iterator(p, &bounds);
@@ -720,6 +711,25 @@ namespace __gnu_test
       typename Iter<T>::ContainerType bounds;
     };
 
+  template<typename T>
+    using test_contiguous_range
+      = test_range<T, contiguous_iterator_wrapper>;
+  template<typename T>
+    using test_random_access_range
+      = test_range<T, random_access_iterator_wrapper>;
+  template<typename T>
+    using test_bidirectional_range
+      = test_range<T, bidirectional_iterator_wrapper>;
+  template<typename T>
+    using test_forward_range
+      = test_range<T, forward_iterator_wrapper>;
+  template<typename T>
+    using test_input_range
+      = test_range<T, input_iterator_wrapper>;
+  template<typename T>
+    using test_output_range
+      = test_range<T, output_iterator_wrapper>;
+
   // A type meeting the minimum std::sized_range requirements
   template<typename T, template<typename> class Iter>
     struct test_sized_range : test_range<T, Iter>
@@ -729,6 +739,30 @@ namespace __gnu_test
       std::size_t size() const noexcept
       { return this->bounds.size(); }
     };
+
+  template<typename T>
+    using test_contiguous_sized_range
+      = test_sized_range<T, contiguous_iterator_wrapper>;
+  template<typename T>
+    using test_random_access_sized_range
+      = test_sized_range<T, random_access_iterator_wrapper>;
+  template<typename T>
+    using test_bidirectional_sized_range
+      = test_sized_range<T, bidirectional_iterator_wrapper>;
+  template<typename T>
+    using test_forward_sized_range
+      = test_sized_range<T, forward_iterator_wrapper>;
+  template<typename T>
+    using test_input_sized_range
+      = test_sized_range<T, input_iterator_wrapper>;
+  template<typename T>
+    using test_output_sized_range
+      = test_sized_range<T, output_iterator_wrapper>;
+
+// test_container, test_range and test_sized_range do not own their elements,
+// so they all model std::ranges::safe_range. This file does not define
+// specializations of std::ranges::enable_safe_range, so that individual
+// test can decide whether or not to do so.
 #endif // C++20
 } // namespace __gnu_test
 #endif // _TESTSUITE_ITERATORS