________________________________
From: Jonathan Wakely <jwak...@redhat.com>
Sent: Friday, November 15, 2019 2:05 PM
To: Smith-Rowland, Edward M
Cc: libstd...@gcc.gnu.org; gcc-patches@gcc.gnu.org
Subject: [External]_Re: Implement the <iterator> part of C++20 p1032 Misc
constexpr bits.
On 15/11/19 18:40 +0000, Smith-Rowland, Edward M wrote:
>Index: testsuite/24_iterators/headers/iterator/inserters_c++17.cc
>===================================================================
>--- testsuite/24_iterators/headers/iterator/inserters_c++17.cc (nonexistent)
>+++ testsuite/24_iterators/headers/iterator/inserters_c++17.cc (working copy)
>@@ -0,0 +1,40 @@
>+// { dg-options "-std=gnu++17" }
>+// { dg-do compile }
This should have { target c++2a }
>+// { dg-require-normal-namespace "" }
>+
>+// 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 <iterator>
>+
>+namespace std {
>+
>+ template <class Container> class back_insert_iterator;
>+
>+ template <class Container>
>+ back_insert_iterator<Container> back_inserter(Container& x);
>+
>+ template <class Container> class front_insert_iterator;
>+
>+ template <class Container>
>+ front_insert_iterator<Container> front_inserter(Container& x);
>+
>+ template <class Container> class insert_iterator;
>+
>+ template <class Container, class Iterator>
>+ insert_iterator<Container> inserter(Container& x, Iterator i);
>+}
>Index: testsuite/24_iterators/headers/iterator/inserters_c++20.cc
>===================================================================
>--- testsuite/24_iterators/headers/iterator/inserters_c++20.cc (nonexistent)
>+++ testsuite/24_iterators/headers/iterator/inserters_c++20.cc (working copy)
>@@ -0,0 +1,40 @@
>+// { dg-options "-std=gnu++2a" }
>+// { dg-do compile }
This should have { target c++2a }
>+// { dg-require-normal-namespace "" }
>+
>+// 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 <iterator>
>+
>+namespace std {
>+
>+ template <class Container> class back_insert_iterator;
>+
>+ template <class Container>
>+ constexpr back_insert_iterator<Container> back_inserter(Container& x);
>+
>+ template <class Container> class front_insert_iterator;
>+
>+ template <class Container>
>+ constexpr front_insert_iterator<Container> front_inserter(Container& x);
>+
>+ template <class Container> class insert_iterator;
>+
>+ template <class Container, class Iterator>
>+ constexpr insert_iterator<Container> inserter(Container& x, Iterator i);
>+}
>Index: testsuite/24_iterators/headers/iterator/synopsis_c++17.cc
>===================================================================
>--- testsuite/24_iterators/headers/iterator/synopsis_c++17.cc (revision
>278302)
>+++ testsuite/24_iterators/headers/iterator/synopsis_c++17.cc (working copy)
>@@ -89,21 +89,6 @@
> template <class Iterator>
> constexpr reverse_iterator<Iterator> make_reverse_iterator(const Iterator&);
>
>- template <class Container> class back_insert_iterator;
>-
>- template <class Container>
>- back_insert_iterator<Container> back_inserter(Container& x);
>-
>- template <class Container> class front_insert_iterator;
>-
>- template <class Container>
>- front_insert_iterator<Container> front_inserter(Container& x);
>-
>- template <class Container> class insert_iterator;
>-
>- template <class Container, class Iterator>
>- insert_iterator<Container> inserter(Container& x, Iterator i);
>-
> template <class Iterator> class move_iterator;
>
> template <class Iterator1, class Iterator2>
This seems wrong ... these are still part of C++17, aren't they?
I think we want to conditionally declare those constexpr so the test
passes in C++20 mode as well e.g.
OK, what I did there was to just remove those tests in synopsis_c++17.cc to a
new inserters_c++17.cc (which is just run for C++17) and add a
inserters_c++20.cc (which is just run for C++20) for the constexpr versions.
So I think everything should be checked with the right version. The C++17
inserters are still checked for C++17.
Ed