[committed] [1/2] libstdc++: Reduce header dependencies on and

2021-07-27 Thread Jonathan Wakely via Gcc-patches
This refactoring reduces the memory usage and compilation time to parse
a number of headers that depend on std::pair, std::tuple or std::array.
Previously the headers for these class templates were all intertwined,
due to the common dependency on std::tuple_size, std::tuple_element and
their std::get overloads. This decouples the headers by moving some
parts of  into a new  header. This means that
 and  no longer need to include the whole of ,
and  no longer needs to include .

This decoupling benefits headers such as  and 
which only need std::tuple, and so no longer have to parse std::array.

Some other headers such as ,  and  no longer
need to include  just for the std::in_place tag types, so
do not have to parse the std::pair definitions.

Removing direct uses of  also means that the std::rel_ops
namespace is not transitively declared by other headers.

Signed-off-by: Jonathan Wakely 

libstdc++-v3/ChangeLog:

* include/Makefile.am: Add bits/utility.h header.
* include/Makefile.in: Regenerate.
* include/bits/utility.h: New file.
* include/std/utility (tuple_size, tuple_element): Move
to new header.
* include/std/type_traits (__is_tuple_like_impl>):
Move to .
(_Index_tuple, _Build_index_tuple, integer_sequence): Likewise.
(in_place_t, in_place_index_t, in_place_type_t): Likewise.
* include/bits/ranges_util.h: Include new header instead of
.
* include/bits/stl_pair.h (tuple_size, tuple_element): Move
partial specializations for std::pair here.
(get): Move overloads for std::pair here.
* include/std/any: Include new header instead of .
* include/std/array: Likewise.
* include/std/memory_resource: Likewise.
* include/std/optional: Likewise.
* include/std/variant: Likewise.
* include/std/tuple: Likewise.
(__is_tuple_like_impl>): Move here.
(get) Declare overloads for std::array.
* include/std/version (__cpp_lib_tuples_by_type): Change type
to long.
* testsuite/20_util/optional/84601.cc: Include .
* 
testsuite/20_util/specialized_algorithms/uninitialized_fill/constrained.cc:
Likewise.
* testsuite/23_containers/array/tuple_interface/get_neg.cc:
Adjust dg-error line numbers.
* testsuite/std/ranges/access/cbegin.cc: Include .
* testsuite/std/ranges/access/cend.cc: Likewise.
* testsuite/std/ranges/access/end.cc: Likewise.
* testsuite/std/ranges/single_view.cc: Likewise.

Tested powerpc64le-linux. Committed to trunk.

commit 261d5a4a459bd49942e53bc83334ccc7154a09d5
Author: Jonathan Wakely 
Date:   Thu Jul 22 14:48:27 2021

libstdc++: Reduce header dependencies on  and 

This refactoring reduces the memory usage and compilation time to parse
a number of headers that depend on std::pair, std::tuple or std::array.
Previously the headers for these class templates were all intertwined,
due to the common dependency on std::tuple_size, std::tuple_element and
their std::get overloads. This decouples the headers by moving some
parts of  into a new  header. This means that
 and  no longer need to include the whole of ,
and  no longer needs to include .

This decoupling benefits headers such as  and 
which only need std::tuple, and so no longer have to parse std::array.

Some other headers such as ,  and  no longer
need to include  just for the std::in_place tag types, so
do not have to parse the std::pair definitions.

Removing direct uses of  also means that the std::rel_ops
namespace is not transitively declared by other headers.

Signed-off-by: Jonathan Wakely 

libstdc++-v3/ChangeLog:

* include/Makefile.am: Add bits/utility.h header.
* include/Makefile.in: Regenerate.
* include/bits/utility.h: New file.
* include/std/utility (tuple_size, tuple_element): Move
to new header.
* include/std/type_traits (__is_tuple_like_impl>):
Move to .
(_Index_tuple, _Build_index_tuple, integer_sequence): Likewise.
(in_place_t, in_place_index_t, in_place_type_t): Likewise.
* include/bits/ranges_util.h: Include new header instead of
.
* include/bits/stl_pair.h (tuple_size, tuple_element): Move
partial specializations for std::pair here.
(get): Move overloads for std::pair here.
* include/std/any: Include new header instead of .
* include/std/array: Likewise.
* include/std/memory_resource: Likewise.
* include/std/optional: Likewise.
* include/std/variant: Likewise.
* include/std/tuple: Likewise.
(__is_tuple_like_impl>): Move here.
(get) Declare overloads for std::array.
* include/std/version 

Re: [committed 1/2] libstdc++: Reduce header dependencies in and on

2020-10-22 Thread Jonathan Wakely via Gcc-patches

On 22/10/20 18:59 +0100, Jonathan Wakely wrote:

By moving std::make_obj_using_allocator and the related "utility
functions for uses-allocator construction" to a new header, we can avoid
including the whole of  in  and
.

In order to simplify the implementation of those utility functions they
now use concepts unconditionally. They are no longer defined if
__cpp_concepts is not defined. To simplify the code that uses those
functions I've introduced a __cpp_lib_make_obj_using_allocator feature
test macro (not specified in the standard, which might be an oversight).
That allows the code in  and  to
check the feature test macro to decide whether to use the new utilities,
or fall back to the C++17 code.

At the same time, this reshuffles some of the headers included by
 so that they are (mostly?) self-contained. It should no longer
be necessary to include other headers before  when
other parts of the library want to use std::shared_ptr without including
the whole of .

libstdc++-v3/ChangeLog:

* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/bits/shared_ptr.h: Include .
* include/bits/shared_ptr_base.h: Include required headers here
directly, instead of in .
* include/bits/uses_allocator_args.h: New file. Move utility
functions for uses-allocator construction from  to here.
Only define the utility functions when concepts are available.
(__cpp_lib_make_obj_using_allocator): Define non-standard
feature test macro.
* include/std/condition_variable: Remove unused headers.
* include/std/future: Likewise.
* include/std/memory: Remove headers that are not needed
directly, and are now inclkuded where they're needed. Include
new  header.
* include/std/memory_resource: Include only the necessary
headers. Use new feature test macro to detect support for the
utility functions.
* include/std/scoped_allocator: Likewise.
* include/std/version (__cpp_lib_make_obj_using_allocator):
Define.



The recent changes to reduce includes in  went a bit
too far, and it's possible for std::forward_as_tuple to not be defined
when used.

While doing this, I noticed the problematic calls to forward_as_tuple

were not qualified, so performed unwanted ADL.
 
Fixed with this patch.


Tested powerpc64le-linux. Committed to trunk.
commit ca021ac617277ba73cb694f8d26ec0f5e1293451
Author: Jonathan Wakely 
Date:   Fri Oct 23 00:58:35 2020

libstdc++: Ensure std::forward_as_tuple is defined

The recent changes to reduce includes in  went a bit
too far, and it's possible for std::forward_as_tuple to not be defined
when used.

While doing this, I noticed the problematic calls to forward_as_tuple
were not qualified, so performed unwanted ADL.

libstdc++-v3/ChangeLog:

* include/experimental/memory_resource: Include .
(polymorphic_allocator::construct): Qualify forward_as_tuple.
* include/std/memory_resource: Likewise.

diff --git a/libstdc++-v3/include/experimental/memory_resource b/libstdc++-v3/include/experimental/memory_resource
index 1c4de70c533..ca1bad9ecd0 100644
--- a/libstdc++-v3/include/experimental/memory_resource
+++ b/libstdc++-v3/include/experimental/memory_resource
@@ -36,6 +36,7 @@
 
 #include 			// align, uses_allocator, __uses_alloc
 #include 		// pair, experimental::erased_type
+#include 			// tuple, forward_as_tuple
 #include 			// atomic
 #include // placement new
 #include 			// max_align_t
@@ -196,8 +197,8 @@ namespace pmr {
 	construct(pair<_Tp1,_Tp2>* __p, _Up&& __x, _Vp&& __y)
 	{
 	  this->construct(__p, piecewise_construct,
-			  forward_as_tuple(std::forward<_Up>(__x)),
-			  forward_as_tuple(std::forward<_Vp>(__y)));
+	  std::forward_as_tuple(std::forward<_Up>(__x)),
+	  std::forward_as_tuple(std::forward<_Vp>(__y)));
 	}
 
   template 
@@ -205,8 +206,8 @@ namespace pmr {
 	construct(pair<_Tp1,_Tp2>* __p, const std::pair<_Up, _Vp>& __pr)
 	{
 	  this->construct(__p, piecewise_construct,
-			  forward_as_tuple(__pr.first),
-			  forward_as_tuple(__pr.second));
+	  std::forward_as_tuple(__pr.first),
+	  std::forward_as_tuple(__pr.second));
 	}
 
   template 
@@ -214,8 +215,8 @@ namespace pmr {
 	construct(pair<_Tp1,_Tp2>* __p, pair<_Up, _Vp>&& __pr)
 	{
 	  this->construct(__p, piecewise_construct,
-			  forward_as_tuple(std::forward<_Up>(__pr.first)),
-			  forward_as_tuple(std::forward<_Vp>(__pr.second)));
+	  std::forward_as_tuple(std::forward<_Up>(__pr.first)),
+	  std::forward_as_tuple(std::forward<_Vp>(__pr.second)));
 	}
 
   template 
diff --git a/libstdc++-v3/include/std/memory_resource b/libstdc++-v3/include/std/memory_resource
index 350799ee382..40e23a2f9ce 100644
--- a/libstdc++-v3/include/std/memory_resource
+++ b/libstdc++-v3/include/std/memory_resource
@@ -45,6 +45,7 @@
 
 #if ! 

[committed 1/2] libstdc++: Reduce header dependencies in and on

2020-10-22 Thread Jonathan Wakely via Gcc-patches
By moving std::make_obj_using_allocator and the related "utility
functions for uses-allocator construction" to a new header, we can avoid
including the whole of  in  and
.

In order to simplify the implementation of those utility functions they
now use concepts unconditionally. They are no longer defined if
__cpp_concepts is not defined. To simplify the code that uses those
functions I've introduced a __cpp_lib_make_obj_using_allocator feature
test macro (not specified in the standard, which might be an oversight).
That allows the code in  and  to
check the feature test macro to decide whether to use the new utilities,
or fall back to the C++17 code.

At the same time, this reshuffles some of the headers included by
 so that they are (mostly?) self-contained. It should no longer
be necessary to include other headers before  when
other parts of the library want to use std::shared_ptr without including
the whole of .

libstdc++-v3/ChangeLog:

* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/bits/shared_ptr.h: Include .
* include/bits/shared_ptr_base.h: Include required headers here
directly, instead of in .
* include/bits/uses_allocator_args.h: New file. Move utility
functions for uses-allocator construction from  to here.
Only define the utility functions when concepts are available.
(__cpp_lib_make_obj_using_allocator): Define non-standard
feature test macro.
* include/std/condition_variable: Remove unused headers.
* include/std/future: Likewise.
* include/std/memory: Remove headers that are not needed
directly, and are now inclkuded where they're needed. Include
new  header.
* include/std/memory_resource: Include only the necessary
headers. Use new feature test macro to detect support for the
utility functions.
* include/std/scoped_allocator: Likewise.
* include/std/version (__cpp_lib_make_obj_using_allocator):
Define.

Tested powerpc64le-linux. Committed to trunk.

commit b1e7c6fce15b8ad222f265df2537701407fd289e
Author: Jonathan Wakely 
Date:   Thu Oct 22 18:42:03 2020

libstdc++: Reduce header dependencies in and on 

By moving std::make_obj_using_allocator and the related "utility
functions for uses-allocator construction" to a new header, we can avoid
including the whole of  in  and
.

In order to simplify the implementation of those utility functions they
now use concepts unconditionally. They are no longer defined if
__cpp_concepts is not defined. To simplify the code that uses those
functions I've introduced a __cpp_lib_make_obj_using_allocator feature
test macro (not specified in the standard, which might be an oversight).
That allows the code in  and  to
check the feature test macro to decide whether to use the new utilities,
or fall back to the C++17 code.

At the same time, this reshuffles some of the headers included by
 so that they are (mostly?) self-contained. It should no longer
be necessary to include other headers before  when
other parts of the library want to use std::shared_ptr without including
the whole of .

libstdc++-v3/ChangeLog:

* include/Makefile.am: Add new header.
* include/Makefile.in: Regenerate.
* include/bits/shared_ptr.h: Include .
* include/bits/shared_ptr_base.h: Include required headers here
directly, instead of in .
* include/bits/uses_allocator_args.h: New file. Move utility
functions for uses-allocator construction from  to here.
Only define the utility functions when concepts are available.
(__cpp_lib_make_obj_using_allocator): Define non-standard
feature test macro.
* include/std/condition_variable: Remove unused headers.
* include/std/future: Likewise.
* include/std/memory: Remove headers that are not needed
directly, and are now inclkuded where they're needed. Include
new  header.
* include/std/memory_resource: Include only the necessary
headers. Use new feature test macro to detect support for the
utility functions.
* include/std/scoped_allocator: Likewise.
* include/std/version (__cpp_lib_make_obj_using_allocator):
Define.

diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 28d273924ee..c90ac555e15 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -222,6 +222,7 @@ bits_headers = \
${bits_srcdir}/unordered_map.h \
${bits_srcdir}/unordered_set.h \
${bits_srcdir}/uses_allocator.h \
+   ${bits_srcdir}/uses_allocator_args.h \
${bits_srcdir}/valarray_array.h \
${bits_srcdir}/valarray_array.tcc \