]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/testsuite/24_iterators/range_operations/distance.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 24_iterators / range_operations / distance.cc
index 754c0cc200b441dc70c21d545faed6075e136d26..9a1d0c3efe8346fc8ce43544cfc2a294f2652549 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2019-2020 Free Software Foundation, Inc.
+// Copyright (C) 2019-2024 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
@@ -15,8 +15,7 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// { dg-options "-std=gnu++2a" }
-// { dg-do run { target c++2a } }
+// { dg-do run { target c++20 } }
 
 #include <iterator>
 #include <testsuite_hooks.h>
@@ -39,13 +38,17 @@ test01()
   test_range<int, random_access_iterator_wrapper> c(a);
   VERIFY( std::ranges::distance(c) == 10 );
 
-  auto b = c.begin(), e = c.end();
+  auto b = c.begin();
+  auto e = c.end();
+  auto ei = std::ranges::next(b, e);
   VERIFY( std::ranges::distance(b, e) == 10 );
-  VERIFY( std::ranges::distance(e, b) == -10 );
+  VERIFY( std::ranges::distance(ei, b) == -10 );
 
-  const auto cb = b, ce = e;
+  const auto cb = b;
+  const auto ce = e;
+  const auto cei = ei;
   VERIFY( std::ranges::distance(cb, ce) == 10 );
-  VERIFY( std::ranges::distance(ce, cb) == -10 );
+  VERIFY( std::ranges::distance(cei, cb) == -10 );
 
   test_sized_range<int, random_access_iterator_wrapper> c2(a);
   VERIFY( std::ranges::distance(c2) == 10 );
@@ -60,10 +63,12 @@ test02()
   test_range<int, bidirectional_iterator_wrapper> c(a);
   VERIFY( std::ranges::distance(c) == 2 );
 
-  auto b = c.begin(), e = c.end();
+  auto b = c.begin();
+  auto e = c.end();
   VERIFY( std::ranges::distance(b, e) == 2 );
 
-  const auto cb = b, ce = e;
+  const auto cb = b;
+  const auto ce = e;
   VERIFY( std::ranges::distance(cb, ce) == 2 );
 
   test_sized_range<int, bidirectional_iterator_wrapper> c2(a);
@@ -77,10 +82,12 @@ test03()
   test_range<int, forward_iterator_wrapper> c(a);
   VERIFY( std::ranges::distance(c) == 3 );
 
-  auto b = c.begin(), e = c.end();
+  auto b = c.begin();
+  auto e = c.end();
   VERIFY( std::ranges::distance(b, e) == 3 );
 
-  const auto cb = b, ce = e;
+  const auto cb = b;
+  const auto ce = e;
   VERIFY( std::ranges::distance(cb, ce) == 3 );
 
   test_sized_range<int, forward_iterator_wrapper> c2(a);
@@ -99,11 +106,13 @@ test04()
   VERIFY( std::ranges::distance(c) == 0 );
 
   c = test_range<int, input_iterator_wrapper>(a);
-  auto b = c.begin(), e = c.end();
+  auto b = c.begin();
+  auto e = c.end();
   VERIFY( std::ranges::distance(b, e) == 4 );
 
   test_range<int, input_iterator_wrapper> c2(a);
-  const auto cb = c2.begin(), ce = c2.end();
+  const auto cb = c2.begin();
+  const auto ce = c2.end();
   VERIFY( std::ranges::distance(cb, ce) == 4 );
 
   test_sized_range<int, input_iterator_wrapper> c3(a);