[PATCH, libstdc++] Two parts of C++20 p1032...

2019-12-10 Thread Smith-Rowland, Edward M
These patches are modest reworkings of previous patches.

The patch for char_traits was pretty much approved already.  But in response to 
a comment from François I at least added __copy_backwards, and used ptrdiff_t 
instead of size_t parameters and I put all the mem* wrappers in a __detail 
namespace. I didn't change some names. I know Jonathan wanted a bikeshed 
discussion.

For the constexpr iterators I was asked to simplify the testsuite. Done.

These would finish p1032 except for std::string::copy which I think should wait 
behind the rest of constexpr string.

Another thing I need to do is respond to the SG-10 changes for the p1032 
macros.  There's one thing that bothers me still in light of the policy that 
these macros are names __cpp_lib_constexpr_HEADER: We sill have 
__cpp_lib_constexpr_algorithmS in .

OK if these pass final retesting?
2019-12-10  Edward Smith-Rowland  <3dw...@verizon.net>

	Implement the char_traits and string_view part of C++20 p1032 Misc.
	constexpr bits.
	* include/bits/char_traits.h (move, copy, assign): Constexpr.
	* include/bits/stl_algobase.h (__memcpy, __memset): New.
	* include/ext/pod_char_traits.h (from, to, operator==, operator<)
	(assign, eq, lt, compare, length, find, move, copy, assign)
	(to_char_type, to_int_type, eq_int_type, eof, not_eof):
	Make these constespr for appropriate standards.
	* include/std/string_view (copy): Constexpr.
	* testsuite/21_strings/char_traits/requirements/char/constexpr.cc: New test.
	* testsuite/21_strings/char_traits/requirements/wchar_t/constexpr.cc: New test.
	* testsuite/21_strings/basic_string_view/operations/copy/char/constexpr.cc: New test.
	* testsuite/21_strings/basic_string_view/operations/copy/wchar_t/constexpr.cc: New test.

Index: include/bits/char_traits.h
===
--- include/bits/char_traits.h	(revision 279174)
+++ include/bits/char_traits.h	(working copy)
@@ -113,13 +113,13 @@
   static _GLIBCXX14_CONSTEXPR const char_type*
   find(const char_type* __s, std::size_t __n, const char_type& __a);
 
-  static char_type*
+  static _GLIBCXX20_CONSTEXPR char_type*
   move(char_type* __s1, const char_type* __s2, std::size_t __n);
 
-  static char_type*
+  static _GLIBCXX20_CONSTEXPR char_type*
   copy(char_type* __s1, const char_type* __s2, std::size_t __n);
 
-  static char_type*
+  static _GLIBCXX20_CONSTEXPR char_type*
   assign(char_type* __s, std::size_t __n, char_type __a);
 
   static _GLIBCXX_CONSTEXPR char_type
@@ -179,18 +179,18 @@
 }
 
   template
-typename char_traits<_CharT>::char_type*
+_GLIBCXX20_CONSTEXPR typename char_traits<_CharT>::char_type*
 char_traits<_CharT>::
 move(char_type* __s1, const char_type* __s2, std::size_t __n)
 {
   if (__n == 0)
 	return __s1;
-  return static_cast<_CharT*>(__builtin_memmove(__s1, __s2,
-		__n * sizeof(char_type)));
+  return static_cast<_CharT*>
+		(std::__detail::__memmove(__s1, __s2, __n));
 }
 
   template
-typename char_traits<_CharT>::char_type*
+_GLIBCXX20_CONSTEXPR typename char_traits<_CharT>::char_type*
 char_traits<_CharT>::
 copy(char_type* __s1, const char_type* __s2, std::size_t __n)
 {
@@ -200,7 +200,7 @@
 }
 
   template
-typename char_traits<_CharT>::char_type*
+_GLIBCXX20_CONSTEXPR typename char_traits<_CharT>::char_type*
 char_traits<_CharT>::
 assign(char_type* __s, std::size_t __n, char_type __a)
 {
@@ -349,28 +349,30 @@
 	return static_cast(__builtin_memchr(__s, __a, __n));
   }
 
-  static char_type*
+  static _GLIBCXX20_CONSTEXPR char_type*
   move(char_type* __s1, const char_type* __s2, size_t __n)
   {
 	if (__n == 0)
 	  return __s1;
-	return static_cast(__builtin_memmove(__s1, __s2, __n));
+	return static_cast
+		(std::__detail::__memmove(__s1, __s2, __n));
   }
 
-  static char_type*
+  static _GLIBCXX20_CONSTEXPR char_type*
   copy(char_type* __s1, const char_type* __s2, size_t __n)
   {
 	if (__n == 0)
 	  return __s1;
-	return static_cast(__builtin_memcpy(__s1, __s2, __n));
+	return static_cast(
+			std::__detail::__memcpy(__s1, __s2, __n));
   }
 
-  static char_type*
+  static _GLIBCXX20_CONSTEXPR char_type*
   assign(char_type* __s, size_t __n, char_type __a)
   {
 	if (__n == 0)
 	  return __s;
-	return static_cast(__builtin_memset(__s, __a, __n));
+	return static_cast(std::__detail::__memset(__s, __a, __n));
   }
 
   static _GLIBCXX_CONSTEXPR char_type
@@ -458,27 +460,45 @@
 	return wmemchr(__s, __a, __n);
   }
 
-  static char_type*
+  static _GLIBCXX20_CONSTEXPR char_type*
   move(char_type* __s1, const char_type* __s2, size_t __n)
   {
 	if (__n == 0)
 	  return __s1;
+#ifdef __cpp_lib_is_constant_evaluated
+	if (std::is_constant_evaluated())
+	  return static_cast
+		   (std::__detail::__memmove(__s1, __s2, __n));
+	else
+#endif
 	return 

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.

[PATCH, libstdc++] Implement C++20 p1032 default_searcher constexprosity.

2019-11-15 Thread Smith-Rowland, Edward M
Pretty self-explanatory.
Ed
2019-11-15  Edward Smith-Rowland  <3dw...@verizon.net>

	Implement the default_searcher part of C++20 p1032 Misc constexpr bits.
	* include/std/functional
	(default_searcher, default_searcher::operator()): Constexpr.
	* testsuite/20_util/function_objects/constexpr_searcher.cc: New.



Index: include/std/functional
===
--- include/std/functional	(revision 278302)
+++ include/std/functional	(working copy)
@@ -1000,6 +1000,7 @@
 class default_searcher
 {
 public:
+  _GLIBCXX20_CONSTEXPR
   default_searcher(_ForwardIterator1 __pat_first,
 		   _ForwardIterator1 __pat_last,
 		   _BinaryPredicate __pred = _BinaryPredicate())
@@ -1007,7 +1008,8 @@
   { }
 
   template
-pair<_ForwardIterator2, _ForwardIterator2>
+	_GLIBCXX20_CONSTEXPR
+	pair<_ForwardIterator2, _ForwardIterator2>
 	operator()(_ForwardIterator2 __first, _ForwardIterator2 __last) const
 	{
 	  _ForwardIterator2 __first_ret =
Index: testsuite/20_util/function_objects/constexpr_searcher.cc
===
--- testsuite/20_util/function_objects/constexpr_searcher.cc	(nonexistent)
+++ testsuite/20_util/function_objects/constexpr_searcher.cc	(working copy)
@@ -0,0 +1,52 @@
+// Copyright (C) 2014-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
+// .
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include 
+#include 
+
+const std::string_view
+patt = "World";
+
+constexpr std::string_view
+greet = "Hello, Humongous World of Wonder!!!";
+
+const std::wstring_view
+wpatt = L"World";
+
+constexpr std::wstring_view
+wgreet = L"Hello, Humongous World of Wonder!!!";
+
+constexpr bool
+test_searcher()
+{
+  auto ok = true;
+
+  const std::default_searcher search(patt.begin(), patt.end(),
+ std::equal_to<>());
+  const auto find = search(greet.begin(), greet.end());
+
+  const std::default_searcher wsearch(wpatt.begin(), wpatt.end(),
+  std::equal_to<>());
+  const auto wfind = wsearch(wgreet.begin(), wgreet.end());
+
+  return ok;
+}
+
+static_assert(test_searcher());


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



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& __x)
 { return front_insert_iterator<_Container>(__x); }
 
@@ -685,10 +693,15 @@
   /// A nested typedef for the type of whatever container you used.
 

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
 _M_assign(const _Tuple_impl<_Idx, _UHead>& __in)
 {
@@ -415,6 +433,7 @@
 	}
 
   template
+	_GLIBCXX20_CONSTEXPR
 void
 _M_assign(_Tuple_impl<_Idx, _UHead>&& __in)
 {
@@ -423,6 +442,7 @@
 	}
 
 protected:
+  _GLIBCXX20_CONSTEXPR
   void
   _M_swap(_Tuple_impl& __in)
   {

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
+// .
+
+#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
+// .
+
+#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());


[PATCH, libstdc++ docs] Add lines to C++20 status.

2019-10-24 Thread Smith-Rowland, Edward M
This patch to the libstdc++ docs should get the remaining status entries for 
C++20 lib.
Ed
Index: doc/xml/manual/status_cxx2020.xml
===
--- doc/xml/manual/status_cxx2020.xml	(revision 277405)
+++ doc/xml/manual/status_cxx2020.xml	(working copy)
@@ -1127,6 +1127,160 @@
__cpp_lib_bounded_array_traits = 201902L 
 
 
+
+   std::to_array 
+  
+http://www.w3.org/1999/xlink; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0325r4.html;>
+	P0325R4
+	
+  
+   10.1 
+   __cpp_lib_to_array = 201907L 
+
+
+
+   Bit operations 
+  
+http://www.w3.org/1999/xlink; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0553r4.html;>
+	P0553R4
+	
+  
+   10.1 
+   __cpp_lib_bitops = 201907L 
+
+
+
+   Mathematical constants 
+  
+http://www.w3.org/1999/xlink; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0631r8.pdf;>
+	P0631R8
+	
+  
+   10.1 
+   __cpp_lib_math_constants = 201907L 
+
+
+
+  
+   Layout-compatibility and pointer-interconvertibility traits 
+  
+http://www.w3.org/1999/xlink; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0466r5.pdf;>
+	P0466R5
+	
+  
+   
+  
+__cpp_lib_is_layout_compatible = 201907L,
+__cpp_lib_is_layout_interconvertible = 201907L,
+  
+
+
+
+   std::stop_token and std::jthread 
+  
+http://www.w3.org/1999/xlink; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0660r10.pdf;>
+	P0660R10
+	
+  
+   10.1 
+   __cpp_lib_jthread = 201907L 
+
+
+
+  
+   Text formatting 
+  
+http://www.w3.org/1999/xlink; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0645r10.html;>
+	P0645R10
+	
+  
+   
+  
+__cpp_lib_format = 201907L,
+  
+
+
+
+   constexpr std::invoke and related utilities 
+  
+http://www.w3.org/1999/xlink; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1065r2.html;>
+	P1065R2
+	
+  
+   10.1 
+   __cpp_lib_constexpr_invoke = 201907L 
+
+
+
+   constexpr std::allocator and related utilities 
+  
+http://www.w3.org/1999/xlink; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0784r7.html;>
+	P0784R7
+	
+  
+   10.1 
+   __cpp_constexpr_dynamic_alloc = 201907L 
+
+
+
+  
+   Atomic waiting and notifying, std::semaphore, std::latch and std::barrier 
+  
+http://www.w3.org/1999/xlink; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1135r6.html;>
+	P1135R6
+	
+  
+   
+  
+__cpp_lib_atomic_lock_free_type_aliases = 201907L in atomic,
+__cpp_lib_atomic_flag_test = 201907L in atomic,
+__cpp_lib_atomic_wait = 201907L in atomic,
+__cpp_lib_semaphore = 201907L in semaphore,
+__cpp_lib_latch = 201907L in latch,
+__cpp_lib_barrier = 201907L in barrier
+  
+
+
+
+  
+   std::source_location 
+  
+http://www.w3.org/1999/xlink; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1208r6.pdf;>
+	P1208R6
+	
+  
+   
+  
+__cpp_lib_source_location = 201907L,
+  
+
+
+
+  
+   Adding = to the standard library 
+  
+http://www.w3.org/1999/xlink; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1614r2.html;>
+	P1614R2
+	
+  
+   
+  
+__cpp_lib_spaceship = 201907L,
+  
+
+
+
+  
+   Efficient access to std::basic_stringbuf's Buffer 
+  
+http://www.w3.org/1999/xlink; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0408r7.pdf;>
+	P0408R7
+	
+  
+   
+  
+
+
   
 
 


[PATCH C++/57644] [C++1y] Cannot bind bitfield to lvalue reference

2014-07-11 Thread Smith-Rowland, Edward M
Just add a test case and close.

Can I add this to 4.9 too?

Ed



CL_pr57644
Description: CL_pr57644


patch_pr57644
Description: patch_pr57644


Re: C++ PATCHes to run testsuite in C++14 mode

2014-03-25 Thread Smith-Rowland, Edward M
Jason,
I noticed while converting some of my test cases to use the new targets that 
gnu targets don't seem to work.
It doesn't matter for the test cases at hand but we might want to consider
target gnu++11
target gnu++11_only
target gnu++1y
target gnu++1y_only