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 <memory> in <scoped_allocator> and
<memory_resource>.

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 <memory_resource> and <scoped_allocator> 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
<memory> so that they are (mostly?) self-contained. It should no longer
be necessary to include other headers before <bits/shared_ptr.h> when
other parts of the library want to use std::shared_ptr without including
the whole of <memory>.

libstdc++-v3/ChangeLog:

        * include/Makefile.am: Add new header.
        * include/Makefile.in: Regenerate.
        * include/bits/shared_ptr.h: Include <iosfwd>.
        * include/bits/shared_ptr_base.h: Include required headers here
        directly, instead of in <memory>.
        * include/bits/uses_allocator_args.h: New file. Move utility
        functions for uses-allocator construction from <memory> 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 <bits/uses_allocator_args.h> 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 <memory_resource> 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 <[email protected]>
Date:   Fri Oct 23 00:58:35 2020

    libstdc++: Ensure std::forward_as_tuple is defined
    
    The recent changes to reduce includes in <memory_resource> 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 <tuple>.
            (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 <memory>			// align, uses_allocator, __uses_alloc
 #include <experimental/utility>		// pair, experimental::erased_type
+#include <tuple>			// tuple, forward_as_tuple
 #include <atomic>			// atomic
 #include <new>				// placement new
 #include <cstddef>			// 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 <typename _Tp1, typename _Tp2, typename _Up, typename _Vp>
@@ -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 <typename _Tp1, typename _Tp2, typename _Up, typename _Vp>
@@ -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 <typename _Up>
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 ! __cpp_lib_make_obj_using_allocator
 # include <utility>			// pair, index_sequence
+# include <tuple>			// tuple, forward_as_tuple
 #endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
@@ -286,8 +287,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 <typename _Tp1, typename _Tp2, typename _Up, typename _Vp>
@@ -296,8 +297,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<typename _Tp1, typename _Tp2, typename _Up, typename _Vp>
@@ -306,8 +307,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)));
 	}
 #else // make_obj_using_allocator
       template<typename _Tp1, typename... _Args>

Reply via email to