Test for C++20 p0858 - ConstexprIterator requirements.

Ed Smith-Rowland via gcc-patches gcc-patches@gcc.gnu.org
Mon Jun 10 22:46:00 GMT 2019


On 6/10/19 2:43 AM, Ville Voutilainen wrote:
> On Mon, 10 Jun 2019 at 02:53, Ed Smith-Rowland <3dw4rd@verizon.net> wrote:
>
>> Darn it, I had those constexpr lib patches in tree.
>> Attached are what I just committed to gcc-9 and passes there. Those
>> std::copy didn't really add anything anyway.
> They added a test that *i++ = *j++ works, and that i != j works.
>
Ok,

Here is a version that adds back a hand written copy thing to test 
Ville's observation.

This is tested on a clean branch.

I would also like to add the same copy lines to the gcc-9 branch.

OK?

Ed


-------------- next part --------------
2019-06-11  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Test C++20 - p0858 ConstexprIterator requirements.
	* testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc:
	New test.
	* testsuite/23_containers/array/requirements/constexpr_iter.cc:
	New test.

-------------- next part --------------
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc
index 24ab502372a..799fb0391f5 100644
--- a/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc
@@ -30,7 +30,11 @@ test()
   static_assert('W' == *(hw.cbegin() + 7));
 
   std::array<int, hw.size()> a2{{0,0,0,0,0,0,0,0,0,0,0,0,0}};
-  std::copy(hw.begin(), hw.end(), a2.begin());
+  auto hwi = hw.begin();
+  auto hwe = hw.end();
+  auto a2i = a2.begin();
+  while (hwi != hwe)
+    *a2i++ = *hwi++;
 
   return *(hw.cbegin() + 3);
 }
diff --git a/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc b/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc
index 88d69d2f8c7..4b5346631c9 100644
--- a/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc
+++ b/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc
@@ -27,9 +27,13 @@ test()
   static_assert(1 == *a1.begin());
   auto n = a1[0] * a1[1]* a1[2];
   static_assert(1 == *a1.cbegin());
-
+ 
   std::array<int, 3> a2{{0, 0, 0}};
-  std::copy(a1.begin(), a1.end(), a2.begin());
+  auto a1i = a1.begin();
+  auto a1e = a1.end();
+  auto a2i = a2.begin();
+  while (a1i != a1e)
+    *a2i++ = *a1i++;
 
   return n;
 }


More information about the Gcc-patches mailing list