Re: Implement the part of C++20 p1032 Misc constexpr bits.

2019-11-20 Thread Ville Voutilainen
On Wed, 20 Nov 2019 at 12:16, Christophe Lyon
 wrote:
>
> On Wed, 20 Nov 2019 at 11:10, Ville Voutilainen
>  wrote:
> >
> > On Wed, 20 Nov 2019 at 11:47, Christophe Lyon
> >  wrote:
> > >
> > > On Thu, 14 Nov 2019 at 16:55, Jonathan Wakely  wrote:
> > > >
> > > > On 09/11/19 02:07 +, Smith-Rowland, Edward M wrote:
> > > > >Here is the  part of C++20 p1032 Misc constexpr bits.
> > > > >
> > > > >Tested on x86_64-linux. OK?
> > > >
> > > > OK for trunk, thanks.
> > > >
> > >
> > > Hi,
> > >
> > > The new test constexpr_allocator_arg_t.cc fails on arm and aarch64 and
> > > many other targets according to gcc-testresults.
> > > Is that expected?
> >
> > No, that's not expected. Can you give a link to the build log?
>
> On (cross) aarch64, I can see:
> FAIL: 20_util/tuple/cons/constexpr_allocator_arg_t.cc (test for excess errors)
> Excess errors:
> /libstdc++-v3/testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc:48:
> error: non-constant condition for static assertion
> /libstdc++-v3/testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc:48:
>   in 'constexpr' expansion of 'test_tuple()'
> /libstdc++-v3/testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc:31:
>   in 'constexpr' expansion of 'ta.std::tuple double>::tuple >(std::allocator_arg, alloc)'
> /aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64-none-linux-gnu/gcc3/aarch64-none-linux-gnu/libstdc++-v3/include/tuple:705:
> error: 'constexpr std::_Tuple_impl<_Idx, _Head, _Tail
> ...>::_Tuple_impl(std::allocator_arg_t, const _Alloc&) [with _Alloc =
> std::allocator; long unsigned int _Idx = 0; _Head = int; _Tail =
> {double, double}]' called in a constant expression
> /aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64-none-linux-gnu/gcc3/aarch64-none-linux-gnu/libstdc++-v3/include/tuple:251:
> error: call to non-'constexpr' function 'std::__uses_alloc_t<_Tp,
> _Alloc, _Args ...> std::__use_alloc(const _Alloc&) [with _Tp = int;
> _Alloc = std::allocator; _Args = {}; std::__uses_alloc_t<_Tp,
> _Alloc, _Args ...> = std::__uses_alloc_t >]'
>
>
> I see it failing at r278333, was it fixed since then?

Yes, in r278373.


Re: Implement the part of C++20 p1032 Misc constexpr bits.

2019-11-20 Thread Christophe Lyon
On Wed, 20 Nov 2019 at 11:10, Ville Voutilainen
 wrote:
>
> On Wed, 20 Nov 2019 at 11:47, Christophe Lyon
>  wrote:
> >
> > On Thu, 14 Nov 2019 at 16:55, Jonathan Wakely  wrote:
> > >
> > > On 09/11/19 02:07 +, Smith-Rowland, Edward M wrote:
> > > >Here is the  part of C++20 p1032 Misc constexpr bits.
> > > >
> > > >Tested on x86_64-linux. OK?
> > >
> > > OK for trunk, thanks.
> > >
> >
> > Hi,
> >
> > The new test constexpr_allocator_arg_t.cc fails on arm and aarch64 and
> > many other targets according to gcc-testresults.
> > Is that expected?
>
> No, that's not expected. Can you give a link to the build log?

On (cross) aarch64, I can see:
FAIL: 20_util/tuple/cons/constexpr_allocator_arg_t.cc (test for excess errors)
Excess errors:
/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc:48:
error: non-constant condition for static assertion
/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc:48:
  in 'constexpr' expansion of 'test_tuple()'
/libstdc++-v3/testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc:31:
  in 'constexpr' expansion of 'ta.std::tuple::tuple >(std::allocator_arg, alloc)'
/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64-none-linux-gnu/gcc3/aarch64-none-linux-gnu/libstdc++-v3/include/tuple:705:
error: 'constexpr std::_Tuple_impl<_Idx, _Head, _Tail
...>::_Tuple_impl(std::allocator_arg_t, const _Alloc&) [with _Alloc =
std::allocator; long unsigned int _Idx = 0; _Head = int; _Tail =
{double, double}]' called in a constant expression
/aci-gcc-fsf/builds/gcc-fsf-gccsrc/obj-aarch64-none-linux-gnu/gcc3/aarch64-none-linux-gnu/libstdc++-v3/include/tuple:251:
error: call to non-'constexpr' function 'std::__uses_alloc_t<_Tp,
_Alloc, _Args ...> std::__use_alloc(const _Alloc&) [with _Tp = int;
_Alloc = std::allocator; _Args = {}; std::__uses_alloc_t<_Tp,
_Alloc, _Args ...> = std::__uses_alloc_t >]'


I see it failing at r278333, was it fixed since then?


Re: Implement the part of C++20 p1032 Misc constexpr bits.

2019-11-20 Thread Ville Voutilainen
On Wed, 20 Nov 2019 at 11:47, Christophe Lyon
 wrote:
>
> On Thu, 14 Nov 2019 at 16:55, Jonathan Wakely  wrote:
> >
> > On 09/11/19 02:07 +, Smith-Rowland, Edward M wrote:
> > >Here is the  part of C++20 p1032 Misc constexpr bits.
> > >
> > >Tested on x86_64-linux. OK?
> >
> > OK for trunk, thanks.
> >
>
> Hi,
>
> The new test constexpr_allocator_arg_t.cc fails on arm and aarch64 and
> many other targets according to gcc-testresults.
> Is that expected?

No, that's not expected. Can you give a link to the build log?


Re: Implement the part of C++20 p1032 Misc constexpr bits.

2019-11-20 Thread Christophe Lyon
On Thu, 14 Nov 2019 at 16:55, Jonathan Wakely  wrote:
>
> On 09/11/19 02:07 +, Smith-Rowland, Edward M wrote:
> >Here is the  part of C++20 p1032 Misc constexpr bits.
> >
> >Tested on x86_64-linux. OK?
>
> OK for trunk, thanks.
>

Hi,

The new test constexpr_allocator_arg_t.cc fails on arm and aarch64 and
many other targets according to gcc-testresults.
Is that expected?

Christophe


Re: [External]_Re: Implement the part of C++20 p1032 Misc constexpr bits.

2019-11-15 Thread Smith-Rowland, Edward M

From: Jonathan Wakely 
Sent: Friday, November 15, 2019 2:33 PM
To: Smith-Rowland, Edward M
Cc: libstd...@gcc.gnu.org; gcc-patches@gcc.gnu.org
Subject: Re: [External]_Re: Implement the  part of C++20 p1032 Misc 
constexpr bits.   

Oh I see the problem, it's because I made synopsis_c++20.cc include
synopsis_c++17.cc because I was lazy.

How about leaving those declarations in synopsis_c++17.cc but
guarding them with #if __cplusplus == 201703L and then adding the
constexpr versions of them in synopsis_c++20.cc ?

I think we should also add { target c++17_only } to synopsis_c++17.cc
(which should have had a target selector anyway).


Ok,
Testing this...
2019-11-15  Edward Smith-Rowland  <3dw...@verizon.net>

	Implement the  part of C++20 p1032 Misc constexpr bits.
	* include/bits/stl_iterator.h (back_insert_iterator, back_inserter)
	(front_insert_iterator, front_inserter, insert_iterator, inserter):
	Make constexpr.
	* testsuite/24_iterators/insert_iterator/requirements/constexpr.cc: New.
	* testsuite/24_iterators/back_insert_iterator/requirements/
	constexpr.cc: New.
	* testsuite/24_iterators/front_insert_iterator/requirements/
	constexpr.cc: New.
	* testsuite/24_iterators/headers/iterator/synopsis_c++17.cc: Make test
	C++17 only and block insert_iterator tests for C++17 (because of include
	of synopsis_c++20.cc.
	* testsuite/24_iterators/headers/iterator/synopsis_c++20.cc: Add
	constexpr inserter tests.

Index: include/bits/stl_iterator.h
===
--- include/bits/stl_iterator.h	(revision 278302)
+++ include/bits/stl_iterator.h	(working copy)
@@ -497,8 +497,12 @@
   /// A nested typedef for the type of whatever container you used.
   typedef _Container  container_type;
 
+#if __cplusplus > 201703L
+  constexpr back_insert_iterator() noexcept = default;
+#endif
+
   /// The only way to create this %iterator is with a container.
-  explicit
+  explicit _GLIBCXX20_CONSTEXPR
   back_insert_iterator(_Container& __x)
   : container(std::__addressof(__x)) { }
 
@@ -521,7 +525,7 @@
 	return *this;
   }
 #else
-  back_insert_iterator&
+  _GLIBCXX20_CONSTEXPR back_insert_iterator&
   operator=(const typename _Container::value_type& __value)
   {
 	container->push_back(__value);
@@ -528,7 +532,7 @@
 	return *this;
   }
 
-  back_insert_iterator&
+  _GLIBCXX20_CONSTEXPR back_insert_iterator&
   operator=(typename _Container::value_type&& __value)
   {
 	container->push_back(std::move(__value));
@@ -537,17 +541,17 @@
 #endif
 
   /// Simply returns *this.
-  back_insert_iterator&
+  _GLIBCXX20_CONSTEXPR back_insert_iterator&
   operator*()
   { return *this; }
 
   /// Simply returns *this.  (This %iterator does not @a move.)
-  back_insert_iterator&
+  _GLIBCXX20_CONSTEXPR back_insert_iterator&
   operator++()
   { return *this; }
 
   /// Simply returns *this.  (This %iterator does not @a move.)
-  back_insert_iterator
+  _GLIBCXX20_CONSTEXPR back_insert_iterator
   operator++(int)
   { return *this; }
 };
@@ -564,7 +568,7 @@
*  types for you.
   */
   template
-inline back_insert_iterator<_Container>
+inline _GLIBCXX20_CONSTEXPR back_insert_iterator<_Container>
 back_inserter(_Container& __x)
 { return back_insert_iterator<_Container>(__x); }
 
@@ -589,8 +593,13 @@
   /// A nested typedef for the type of whatever container you used.
   typedef _Container  container_type;
 
+#if __cplusplus > 201703L
+  constexpr front_insert_iterator() noexcept = default;
+#endif
+
   /// The only way to create this %iterator is with a container.
-  explicit front_insert_iterator(_Container& __x)
+  explicit _GLIBCXX20_CONSTEXPR
+  front_insert_iterator(_Container& __x)
   : container(std::__addressof(__x)) { }
 
   /**
@@ -612,14 +621,13 @@
 	return *this;
   }
 #else
-  front_insert_iterator&
+  _GLIBCXX20_CONSTEXPR front_insert_iterator&
   operator=(const typename _Container::value_type& __value)
   {
 	container->push_front(__value);
 	return *this;
   }
-
-  front_insert_iterator&
+  _GLIBCXX20_CONSTEXPR front_insert_iterator&
   operator=(typename _Container::value_type&& __value)
   {
 	container->push_front(std::move(__value));
@@ -628,17 +636,17 @@
 #endif
 
   /// Simply returns *this.
-  front_insert_iterator&
+  _GLIBCXX20_CONSTEXPR front_insert_iterator&
   operator*()
   { return *this; }
 
   /// Simply returns *this.  (This %iterator does not @a move.)
-  front_insert_iterator&
+  _GLIBCXX20_CONSTEXPR front_insert_iterator&
   operator++()
   { return *this; }
 
   /// Simply returns *this.  (This %iterator does not @a move.

Re: [External]_Re: Implement the part of C++20 p1032 Misc constexpr bits.

2019-11-15 Thread Jonathan Wakely

On 15/11/19 19:12 +, Smith-Rowland, Edward M wrote:

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 
  constexpr reverse_iterator make_reverse_iterator(const Iterator&);

-  template  class back_insert_iterator;
-
-  template 
-  back_insert_iterator back_inserter(Container& x);
-
-  template  class front_insert_iterator;
-
-  template 
-  front_insert_iterator front_inserter(Container& x);
-
-  template  class insert_iterator;
-
-  template 
-  insert_iterator inserter(Container& x, Iterator i);
-
  template  class move_iterator;

  template 


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.


Oh I see the problem, it's because I made synopsis_c++20.cc include
synopsis_c++17.cc because I was lazy.

How about leaving those declarations in synopsis_c++17.cc but
guarding them with #if __cplusplus == 201703L and then adding the
constexpr versions of them in synopsis_c++20.cc ?

I think we should also add { target c++17_only } to synopsis_c++17.cc
(which should have had a target selector anyway).



Re: [External]_Re: Implement the part of C++20 p1032 Misc constexpr bits.

2019-11-15 Thread Smith-Rowland, Edward M





From: Jonathan Wakely 
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  part of C++20 p1032 Misc 
constexpr bits.

On 15/11/19 18:40 +, 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 
>+
>+namespace std {
>+
>+  template  class back_insert_iterator;
>+
>+  template 
>+  back_insert_iterator back_inserter(Container& x);
>+
>+  template  class front_insert_iterator;
>+
>+  template 
>+  front_insert_iterator front_inserter(Container& x);
>+
>+  template  class insert_iterator;
>+
>+  template 
>+  insert_iterator 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 
>+
>+namespace std {
>+
>+  template  class back_insert_iterator;
>+
>+  template 
>+  constexpr back_insert_iterator back_inserter(Container& x);
>+
>+  template  class front_insert_iterator;
>+
>+  template 
>+  constexpr front_insert_iterator front_inserter(Container& x);
>+
>+  template  class insert_iterator;
>+
>+  template 
>+  constexpr insert_iterator 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 
>   constexpr reverse_iterator make_reverse_iterator(const Iterator&);
>
>-  template  class back_insert_iterator;
>-
>-  template 
>-  back_insert_iterator back_inserter(Container& x);
>-
>-  template  class front_insert_iterator;
>-
>-  template 
>-  front_insert_iterator front_inserter(Container& x);
>-
>-  template  class insert_iterator;
>-
>-  template 
>-  insert_iterator inserter(Container& x, Iterator i);
>-
>   template  class move_iterator;
>
>   template 

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



Re: Implement the part of C++20 p1032 Misc constexpr bits.

2019-11-15 Thread Jonathan Wakely

On 15/11/19 18:40 +, 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
+// .
+
+#include 
+
+namespace std {
+
+  template  class back_insert_iterator;
+
+  template 
+  back_insert_iterator back_inserter(Container& x);
+
+  template  class front_insert_iterator;
+
+  template 
+  front_insert_iterator front_inserter(Container& x);
+
+  template  class insert_iterator;
+
+  template 
+  insert_iterator 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
+// .
+
+#include 
+
+namespace std {
+
+  template  class back_insert_iterator;
+
+  template 
+  constexpr back_insert_iterator back_inserter(Container& x);
+
+  template  class front_insert_iterator;
+
+  template 
+  constexpr front_insert_iterator front_inserter(Container& x);
+
+  template  class insert_iterator;
+
+  template 
+  constexpr insert_iterator 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 
  constexpr reverse_iterator make_reverse_iterator(const Iterator&);

-  template  class back_insert_iterator;
-
-  template 
-  back_insert_iterator back_inserter(Container& x);
-
-  template  class front_insert_iterator;
-
-  template 
-  front_insert_iterator front_inserter(Container& x);
-
-  template  class insert_iterator;
-
-  template 
-  insert_iterator inserter(Container& x, Iterator i);
-
  template  class move_iterator;

  template 


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 
#if __cplusplus > 201703L
   constexpr
#endif



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

2019-11-15 Thread Smith-Rowland, Edward M

Here is another chunk of p1032.
Jonthan,
I plan to get it all except maybe string::copy.  I can't figure out how to test 
without being able to create a constexpr string object. And anything I do will 
probably collide with your work on constexpr string. p1032 would be a tiny 
patch on top of that work anyway.
Ed

Test on x86_64-linux. OK?
2019-11-15  Edward Smith-Rowland  <3dw...@verizon.net>

	Implement the  part of C++20 p1032 Misc constexpr bits.
	* include/bits/stl_iterator.h (back_insert_iterator, back_inserter)
	(front_insert_iterator, front_inserter, insert_iterator, inserter):
	Make constexpr.
	* testsuite/24_iterators/insert_iterator/requirements/constexpr.cc: New.
	* testsuite/24_iterators/back_insert_iterator/requirements/constexpr.cc: New.
	* testsuite/24_iterators/front_insert_iterator/requirements/constexpr.cc: New.
	* testsuite/24_iterators/headers/iterator/synopsis_c++17.cc: Move
	inserter tests ...
	* testsuite/24_iterators/headers/iterator/inserters_c++17.cc: ... here.
	* testsuite/24_iterators/headers/iterator/inserters_c++20.cc: New.

Index: include/bits/stl_iterator.h
===
--- include/bits/stl_iterator.h	(revision 278302)
+++ include/bits/stl_iterator.h	(working copy)
@@ -497,8 +497,12 @@
   /// A nested typedef for the type of whatever container you used.
   typedef _Container  container_type;
 
+#if __cplusplus > 201703L
+  constexpr back_insert_iterator() noexcept = default;
+#endif
+
   /// The only way to create this %iterator is with a container.
-  explicit
+  explicit _GLIBCXX20_CONSTEXPR
   back_insert_iterator(_Container& __x)
   : container(std::__addressof(__x)) { }
 
@@ -521,7 +525,7 @@
 	return *this;
   }
 #else
-  back_insert_iterator&
+  _GLIBCXX20_CONSTEXPR back_insert_iterator&
   operator=(const typename _Container::value_type& __value)
   {
 	container->push_back(__value);
@@ -528,7 +532,7 @@
 	return *this;
   }
 
-  back_insert_iterator&
+  _GLIBCXX20_CONSTEXPR back_insert_iterator&
   operator=(typename _Container::value_type&& __value)
   {
 	container->push_back(std::move(__value));
@@ -537,17 +541,17 @@
 #endif
 
   /// Simply returns *this.
-  back_insert_iterator&
+  _GLIBCXX20_CONSTEXPR back_insert_iterator&
   operator*()
   { return *this; }
 
   /// Simply returns *this.  (This %iterator does not @a move.)
-  back_insert_iterator&
+  _GLIBCXX20_CONSTEXPR back_insert_iterator&
   operator++()
   { return *this; }
 
   /// Simply returns *this.  (This %iterator does not @a move.)
-  back_insert_iterator
+  _GLIBCXX20_CONSTEXPR back_insert_iterator
   operator++(int)
   { return *this; }
 };
@@ -564,7 +568,7 @@
*  types for you.
   */
   template
-inline back_insert_iterator<_Container>
+inline _GLIBCXX20_CONSTEXPR back_insert_iterator<_Container>
 back_inserter(_Container& __x)
 { return back_insert_iterator<_Container>(__x); }
 
@@ -589,8 +593,13 @@
   /// A nested typedef for the type of whatever container you used.
   typedef _Container  container_type;
 
+#if __cplusplus > 201703L
+  constexpr front_insert_iterator() noexcept = default;
+#endif
+
   /// The only way to create this %iterator is with a container.
-  explicit front_insert_iterator(_Container& __x)
+  explicit _GLIBCXX20_CONSTEXPR
+  front_insert_iterator(_Container& __x)
   : container(std::__addressof(__x)) { }
 
   /**
@@ -612,14 +621,13 @@
 	return *this;
   }
 #else
-  front_insert_iterator&
+  _GLIBCXX20_CONSTEXPR front_insert_iterator&
   operator=(const typename _Container::value_type& __value)
   {
 	container->push_front(__value);
 	return *this;
   }
-
-  front_insert_iterator&
+  _GLIBCXX20_CONSTEXPR front_insert_iterator&
   operator=(typename _Container::value_type&& __value)
   {
 	container->push_front(std::move(__value));
@@ -628,17 +636,17 @@
 #endif
 
   /// Simply returns *this.
-  front_insert_iterator&
+  _GLIBCXX20_CONSTEXPR front_insert_iterator&
   operator*()
   { return *this; }
 
   /// Simply returns *this.  (This %iterator does not @a move.)
-  front_insert_iterator&
+  _GLIBCXX20_CONSTEXPR front_insert_iterator&
   operator++()
   { return *this; }
 
   /// Simply returns *this.  (This %iterator does not @a move.)
-  front_insert_iterator
+  _GLIBCXX20_CONSTEXPR front_insert_iterator
   operator++(int)
   { return *this; }
 };
@@ -655,7 +663,7 @@
*  types for you.
   */
   template
-inline front_insert_iterator<_Container>
+inline _GLIBCXX20_CONSTEXPR front_insert_iterator<_Container>
 front_inserter(_Container

Re: Implement the part of C++20 p1032 Misc constexpr bits.

2019-11-14 Thread Jonathan Wakely

On 09/11/19 02:07 +, Smith-Rowland, Edward M wrote:

Here is the  part of C++20 p1032 Misc constexpr bits.

Tested on x86_64-linux. OK?


OK for trunk, thanks.



Re: Implement the part of C++20 p1032 Misc constexpr bits.

2019-11-14 Thread Jonathan Wakely

On 09/11/19 01:15 +, Smith-Rowland, Edward M wrote:

I'm going to implement p1032 in pieces.  It *is* miscellaneous after all ;-).

Tested on x96_64-linux? OK?



2019-11-09  Edward Smith-Rowland  <3dw...@verizon.net>

    Implement the  part of C++20 p1032 Misc constexpr bits.
* include/std/array (fill, swap): Make constexpr.
* testsuite/23_containers/array/requirements/constexpr_fill.cc: New.
* testsuite/23_containers/array/requirements/constexpr_swap.cc: New.


OK for trunk, thanks.



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

2019-11-08 Thread Smith-Rowland, Edward M
Here is the  part of C++20 p1032 Misc constexpr bits.

Tested on x86_64-linux. OK?

Ed
2019-11-09  Edward Smith-Rowland  <3dw...@verizon.net>

	Implement the  part of C++20 p1032 Misc constexpr bits.
	* include/std/tuple (_Head_base, _Tuple_impl(allocator_arg_t,...),
	_M_assign, tuple(allocator_arg_t,...), _Inherited, operator=, _M_swap,
	swap, pair(piecewise_construct_t,): Constexpr.
	* (__uses_alloc0::_Sink::operator=, __uses_alloc_t): Constexpr.
	* testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc: New test.

Index: include/std/tuple
===
--- include/std/tuple	(revision 277944)
+++ include/std/tuple	(working copy)
@@ -132,6 +132,7 @@
 constexpr _Head_base(_UHead&& __h)
 	: _M_head_impl(std::forward<_UHead>(__h)) { }
 
+  _GLIBCXX20_CONSTEXPR
   _Head_base(allocator_arg_t, __uses_alloc0)
   : _M_head_impl() { }
 
@@ -144,6 +145,7 @@
 	: _M_head_impl(*__a._M_a) { }
 
   template
+	_GLIBCXX20_CONSTEXPR
 	_Head_base(__uses_alloc0, _UHead&& __uhead)
 	: _M_head_impl(std::forward<_UHead>(__uhead)) { }
 
@@ -243,6 +245,7 @@
 		(_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { }
 
   template
+	_GLIBCXX20_CONSTEXPR
 	_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a)
 	: _Inherited(__tag, __a),
   _Base(__tag, __use_alloc<_Head>(__a)) { }
@@ -256,6 +259,7 @@
   template::type>
+	_GLIBCXX20_CONSTEXPR
 	_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
 	_UHead&& __head, _UTail&&... __tail)
 	: _Inherited(__tag, __a, std::forward<_UTail>(__tail)...),
@@ -263,6 +267,7 @@
 	std::forward<_UHead>(__head)) { }
 
   template
+	_GLIBCXX20_CONSTEXPR
 _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
 	const _Tuple_impl& __in)
 	: _Inherited(__tag, __a, _M_tail(__in)),
@@ -269,6 +274,7 @@
   _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
 
   template
+	_GLIBCXX20_CONSTEXPR
 	_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
 	_Tuple_impl&& __in)
 	: _Inherited(__tag, __a, std::move(_M_tail(__in))),
@@ -276,6 +282,7 @@
 	std::forward<_Head>(_M_head(__in))) { }
 
   template
+	_GLIBCXX20_CONSTEXPR
 	_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
 	const _Tuple_impl<_Idx, _UElements...>& __in)
 	: _Inherited(__tag, __a,
@@ -284,6 +291,7 @@
 		_Tuple_impl<_Idx, _UElements...>::_M_head(__in)) { }
 
   template
+	_GLIBCXX20_CONSTEXPR
 	_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
 	_Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
 	: _Inherited(__tag, __a, std::move
@@ -293,6 +301,7 @@
 		(_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { }
 
   template
+	_GLIBCXX20_CONSTEXPR
 void
 _M_assign(const _Tuple_impl<_Idx, _UElements...>& __in)
 {
@@ -302,6 +311,7 @@
 	}
 
   template
+	_GLIBCXX20_CONSTEXPR
 void
 _M_assign(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
 {
@@ -312,6 +322,7 @@
 	}
 
 protected:
+  _GLIBCXX20_CONSTEXPR
   void
   _M_swap(_Tuple_impl& __in)
   {
@@ -369,6 +380,7 @@
 	{ }
 
   template
+	_GLIBCXX20_CONSTEXPR
 	_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a)
 	: _Base(__tag, __use_alloc<_Head>(__a)) { }
 
@@ -378,6 +390,7 @@
 	: _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __head) { }
 
   template
+	_GLIBCXX20_CONSTEXPR
 	_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
 	_UHead&& __head)
 	: _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
@@ -384,11 +397,13 @@
 	std::forward<_UHead>(__head)) { }
 
   template
+	_GLIBCXX20_CONSTEXPR
 _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
 	const _Tuple_impl& __in)
 	: _Base(__use_alloc<_Head, _Alloc, _Head>(__a), _M_head(__in)) { }
 
   template
+	_GLIBCXX20_CONSTEXPR
 	_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
 	_Tuple_impl&& __in)
 	: _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
@@ -395,6 +410,7 @@
 	std::forward<_Head>(_M_head(__in))) { }
 
   template
+	_GLIBCXX20_CONSTEXPR
 	_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
 	const _Tuple_impl<_Idx, _UHead>& __in)
 	: _Base(__use_alloc<_Head, _Alloc, _Head>(__a),
@@ -401,6 +417,7 @@
 		_Tuple_impl<_Idx, _UHead>::_M_head(__in)) { }
 
   template
+	_GLIBCXX20_CONSTEXPR
 	_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
 	_Tuple_impl<_Idx, _UHead>&& __in)
 	: _Base(__use_alloc<_Head, _Alloc, _UHead>(__a),
@@ -408,6 +425,7 @@
 	{ }
 
   template
+	_GLIBCXX20_CONSTEXPR
 void
 

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

2019-11-08 Thread Smith-Rowland, Edward M
I'm going to implement p1032 in pieces.  It *is* miscellaneous after all ;-).

Tested on x96_64-linux? OK?
2019-11-09  Edward Smith-Rowland  <3dw...@verizon.net>

	Implement the  part of C++20 p1032 Misc constexpr bits.
	* include/std/array (fill, swap): Make constexpr.
	* testsuite/23_containers/array/requirements/constexpr_fill.cc: New.
	* testsuite/23_containers/array/requirements/constexpr_swap.cc: New.
Index: include/std/array
===
--- include/std/array	(revision 277944)
+++ include/std/array	(working copy)
@@ -112,11 +112,11 @@
   // No explicit construct/copy/destroy for aggregate type.
 
   // DR 776.
-  void
+  _GLIBCXX20_CONSTEXPR void
   fill(const value_type& __u)
   { std::fill_n(begin(), size(), __u); }
 
-  void
+  _GLIBCXX20_CONSTEXPR void
   swap(array& __other)
   noexcept(_AT_Type::_Is_nothrow_swappable::value)
   { std::swap_ranges(begin(), end(), __other.begin()); }
@@ -288,6 +288,7 @@
 
   // Specialized algorithms.
   template
+_GLIBCXX20_CONSTEXPR
 inline
 #if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
 // Constrained free swap overload, see p0185r1
@@ -295,7 +296,6 @@
   _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::_Is_swappable::value
 >::type
 #else
-_GLIBCXX20_CONSTEXPR
 void
 #endif
 swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
Index: testsuite/23_containers/array/requirements/constexpr_fill.cc
===
--- testsuite/23_containers/array/requirements/constexpr_fill.cc	(nonexistent)
+++ testsuite/23_containers/array/requirements/constexpr_fill.cc	(working copy)
@@ -0,0 +1,36 @@
+// { 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 
+
+constexpr bool
+test_array()
+{
+  auto ok = true;
+
+  std::array fa{};
+  fa.fill(3.333f);
+
+  ok = ok && (fa[0] == fa[2]);
+
+  return ok;
+}
+
+static_assert(test_array());
Index: testsuite/23_containers/array/requirements/constexpr_swap.cc
===
--- testsuite/23_containers/array/requirements/constexpr_swap.cc	(nonexistent)
+++ testsuite/23_containers/array/requirements/constexpr_swap.cc	(working copy)
@@ -0,0 +1,43 @@
+// { 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 
+
+constexpr bool
+test_array()
+{
+  auto ok = true;
+
+  std::array fa{{1.1f, 2.2f, 3.3f}};
+
+  std::array fb{{4.4f, 5.5f, 6.6f}};
+
+  fb.swap(fa);
+
+  ok = ok && (fa[0] == 4.4f);
+
+  std::swap(fa, fb);
+
+  ok = ok && (fa[0] == 1.1f);
+
+  return ok;
+}
+
+static_assert(test_array());