aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorEdward Smith-Rowland <3dw4rd@verizon.net>2019-06-08 22:18:36 +0000
committerEdward Smith-Rowland <emsr@gcc.gnu.org>2019-06-08 22:18:36 +0000
commit79f31e3d18c959c70dc2dd4076f695eca88b5383 (patch)
tree9f29f8ad491a08b5992a707bef94c95bf104354b /libstdc++-v3
parent8e73afcf40a43a88c9e2ca5406570f0189e6d903 (diff)
downloadgcc-79f31e3d18c959c70dc2dd4076f695eca88b5383.zip
gcc-79f31e3d18c959c70dc2dd4076f695eca88b5383.tar.gz
gcc-79f31e3d18c959c70dc2dd4076f695eca88b5383.tar.bz2
Test for C++20 p0858 - ConstexprIterator requirements.
2019-06-08 Edward Smith-Rowland <3dw4rd@verizon.net> Test for 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. From-SVN: r272085
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog8
-rw-r--r--libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc42
-rw-r--r--libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc41
3 files changed, 91 insertions, 0 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index e20d0b6..0abbaa92 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,11 @@
+2019-06-08 Edward Smith-Rowland <3dw4rd@verizon.net>
+
+ Test for 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.
+
2019-06-07 Thomas Rodgers <trodgers@redhat.com>
Rename PSTL macro's consistent with libstdc++ (and llvm upstream
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
new file mode 100644
index 0000000..24ab502
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/requirements/constexpr_iter.cc
@@ -0,0 +1,42 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+//
+// Copyright (C) 2019 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/>.
+
+#include <string_view>
+#include <array>
+
+constexpr char
+test()
+{
+ constexpr std::string_view hw("Hello, World!");
+ static_assert('H' == *hw.begin());
+ auto ch = hw[4];
+ 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());
+
+ return *(hw.cbegin() + 3);
+}
+
+void
+run_test()
+{
+ constexpr char ch = test();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc b/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc
new file mode 100644
index 0000000..88d69d2
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/array/requirements/constexpr_iter.cc
@@ -0,0 +1,41 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+//
+// Copyright (C) 2019 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/>.
+
+#include <array>
+
+constexpr int
+test()
+{
+ constexpr std::array<int, 3> a1{{1, 2, 3}};
+ 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());
+
+ return n;
+}
+
+void
+run_test()
+{
+ constexpr int n = test();
+}