Implement the <iterator> part of C++20 p1032 Misc constexpr bits.

Jonathan Wakely jwakely@redhat.com
Fri Nov 15 19:06:00 GMT 2019


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.

  template <class Container>
#if __cplusplus > 201703L
    constexpr
#endif



More information about the Libstdc++ mailing list