libstdc++: Reduce header dependencies in and on <memory>

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.
This commit is contained in:
Jonathan Wakely 2020-10-22 18:42:03 +01:00
parent d667beea36
commit b1e7c6fce1
11 changed files with 278 additions and 242 deletions

View File

@ -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 \
${bits_srcdir}/valarray_before.h \

View File

@ -568,6 +568,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 \
${bits_srcdir}/valarray_before.h \

View File

@ -49,6 +49,7 @@
#ifndef _SHARED_PTR_H
#define _SHARED_PTR_H 1
#include <iosfwd> // std::basic_ostream
#include <bits/shared_ptr_base.h>
namespace std _GLIBCXX_VISIBILITY(default)

View File

@ -51,9 +51,15 @@
#include <typeinfo>
#include <bits/allocated_ptr.h>
#include <bits/allocator.h>
#include <bits/exception_defines.h>
#include <bits/functional_hash.h>
#include <bits/refwrap.h>
#include <bits/stl_function.h>
#include <bits/stl_function.h> // std::less
#include <bits/unique_ptr.h>
#include <ext/aligned_buffer.h>
#include <ext/atomicity.h>
#include <ext/concurrence.h>
#if __cplusplus > 201703L
# include <compare>
#endif

View File

@ -0,0 +1,227 @@
// Utility functions for uses-allocator construction -*- C++ -*-
// Copyright (C) 2019-2020 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.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/*
* Copyright (c) 1997-1999
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear
* in supporting documentation. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*/
/** @file include/bits/uses_allocator_args.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{memory}
*/
#ifndef _USES_ALLOCATOR_ARGS
#define _USES_ALLOCATOR_ARGS 1
#pragma GCC system_header
#if __cplusplus > 201703L && __cpp_concepts
#include <new> // for placement operator new
#include <tuple> // for tuple, make_tuple, make_from_tuple
#include <bits/stl_construct.h> // construct_at
#include <bits/stl_pair.h> // pair
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp>
inline constexpr bool __is_pair = false;
template<typename _Tp, typename _Up>
inline constexpr bool __is_pair<pair<_Tp, _Up>> = true;
template<typename _Tp, typename _Up>
inline constexpr bool __is_pair<const pair<_Tp, _Up>> = true;
template<typename _Tp>
concept _Std_pair = __is_pair<_Tp>;
/** @addtogroup allocators
* @{
*/
// Not specified by C++20, used internally
#define __cpp_lib_make_obj_using_allocator 201811L
template<typename _Tp, typename _Alloc, typename... _Args>
constexpr auto
uses_allocator_construction_args(const _Alloc& __a,
_Args&&... __args) noexcept
requires (! _Std_pair<_Tp>)
{
if constexpr (uses_allocator_v<remove_cv_t<_Tp>, _Alloc>)
{
if constexpr (is_constructible_v<_Tp, allocator_arg_t,
const _Alloc&, _Args...>)
{
return tuple<allocator_arg_t, const _Alloc&, _Args&&...>(
allocator_arg, __a, std::forward<_Args>(__args)...);
}
else
{
static_assert(is_constructible_v<_Tp, _Args..., const _Alloc&>,
"construction with an allocator must be possible"
" if uses_allocator is true");
return tuple<_Args&&..., const _Alloc&>(
std::forward<_Args>(__args)..., __a);
}
}
else
{
static_assert(is_constructible_v<_Tp, _Args...>);
return tuple<_Args&&...>(std::forward<_Args>(__args)...);
}
}
template<_Std_pair _Tp, typename _Alloc, typename _Tuple1, typename _Tuple2>
constexpr auto
uses_allocator_construction_args(const _Alloc& __a, piecewise_construct_t,
_Tuple1&& __x, _Tuple2&& __y) noexcept;
template<_Std_pair _Tp, typename _Alloc>
constexpr auto
uses_allocator_construction_args(const _Alloc&) noexcept;
template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp>
constexpr auto
uses_allocator_construction_args(const _Alloc&, _Up&&, _Vp&&) noexcept;
template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp>
constexpr auto
uses_allocator_construction_args(const _Alloc&,
const pair<_Up, _Vp>&) noexcept;
template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp>
constexpr auto
uses_allocator_construction_args(const _Alloc&, pair<_Up, _Vp>&&) noexcept;
template<_Std_pair _Tp, typename _Alloc, typename _Tuple1, typename _Tuple2>
constexpr auto
uses_allocator_construction_args(const _Alloc& __a, piecewise_construct_t,
_Tuple1&& __x, _Tuple2&& __y) noexcept
{
using _Tp1 = typename _Tp::first_type;
using _Tp2 = typename _Tp::second_type;
return std::make_tuple(piecewise_construct,
std::apply([&__a](auto&&... __args1) {
return std::uses_allocator_construction_args<_Tp1>(
__a, std::forward<decltype(__args1)>(__args1)...);
}, std::forward<_Tuple1>(__x)),
std::apply([&__a](auto&&... __args2) {
return std::uses_allocator_construction_args<_Tp2>(
__a, std::forward<decltype(__args2)>(__args2)...);
}, std::forward<_Tuple2>(__y)));
}
template<_Std_pair _Tp, typename _Alloc>
constexpr auto
uses_allocator_construction_args(const _Alloc& __a) noexcept
{
using _Tp1 = typename _Tp::first_type;
using _Tp2 = typename _Tp::second_type;
return std::make_tuple(piecewise_construct,
std::uses_allocator_construction_args<_Tp1>(__a),
std::uses_allocator_construction_args<_Tp2>(__a));
}
template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp>
constexpr auto
uses_allocator_construction_args(const _Alloc& __a, _Up&& __u, _Vp&& __v)
noexcept
{
using _Tp1 = typename _Tp::first_type;
using _Tp2 = typename _Tp::second_type;
return std::make_tuple(piecewise_construct,
std::uses_allocator_construction_args<_Tp1>(__a,
std::forward<_Up>(__u)),
std::uses_allocator_construction_args<_Tp2>(__a,
std::forward<_Vp>(__v)));
}
template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp>
constexpr auto
uses_allocator_construction_args(const _Alloc& __a,
const pair<_Up, _Vp>& __pr) noexcept
{
using _Tp1 = typename _Tp::first_type;
using _Tp2 = typename _Tp::second_type;
return std::make_tuple(piecewise_construct,
std::uses_allocator_construction_args<_Tp1>(__a, __pr.first),
std::uses_allocator_construction_args<_Tp2>(__a, __pr.second));
}
template<_Std_pair _Tp, typename _Alloc, typename _Up, typename _Vp>
constexpr auto
uses_allocator_construction_args(const _Alloc& __a,
pair<_Up, _Vp>&& __pr) noexcept
{
using _Tp1 = typename _Tp::first_type;
using _Tp2 = typename _Tp::second_type;
return std::make_tuple(piecewise_construct,
std::uses_allocator_construction_args<_Tp1>(__a,
std::move(__pr).first),
std::uses_allocator_construction_args<_Tp2>(__a,
std::move(__pr).second));
}
template<typename _Tp, typename _Alloc, typename... _Args>
inline _Tp
make_obj_using_allocator(const _Alloc& __a, _Args&&... __args)
{
return std::make_from_tuple<_Tp>(
std::uses_allocator_construction_args<_Tp>(__a,
std::forward<_Args>(__args)...));
}
template<typename _Tp, typename _Alloc, typename... _Args>
inline _Tp*
uninitialized_construct_using_allocator(_Tp* __p, const _Alloc& __a,
_Args&&... __args)
{
return std::apply([&](auto&&... __xs) {
return std::construct_at(__p, std::forward<decltype(__xs)>(__xs)...);
}, std::uses_allocator_construction_args<_Tp>(__a,
std::forward<_Args>(__args)...));
}
// @}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // C++20
#endif // _USES_ALLOCATOR_ARGS

View File

@ -39,10 +39,7 @@
#include <bits/std_mutex.h>
#include <bits/unique_lock.h>
#include <ext/concurrence.h>
#include <bits/alloc_traits.h>
#include <bits/allocator.h>
#include <bits/unique_ptr.h>
#include <bits/shared_ptr.h>
#include <bits/cxxabi_forced.h>

View File

@ -35,19 +35,18 @@
# include <bits/c++0x_warning.h>
#else
#include <mutex>
#include <mutex> // call_once
#include <thread>
#include <condition_variable>
#include <condition_variable> // __at_thread_exit_elt
#include <system_error>
#include <atomic>
#include <bits/allocated_ptr.h>
#include <bits/atomic_futex.h>
#include <bits/functexcept.h>
#include <bits/invoke.h>
#include <bits/unique_ptr.h>
#include <bits/shared_ptr.h>
#include <bits/std_function.h>
#include <bits/uses_allocator.h>
#include <bits/allocated_ptr.h>
#include <ext/aligned_buffer.h>
namespace std _GLIBCXX_VISIBILITY(default)

View File

@ -66,38 +66,28 @@
#include <bits/stl_uninitialized.h>
#include <bits/stl_tempbuf.h>
#include <bits/stl_raw_storage_iter.h>
#include <bits/ranges_uninitialized.h>
#if __cplusplus >= 201103L
# include <exception> // std::exception
# include <typeinfo> // std::type_info in get_deleter
# include <iosfwd> // std::basic_ostream
# include <ext/atomicity.h>
# include <ext/concurrence.h>
# include <type_traits>
# include <bits/align.h>
# include <bits/functexcept.h>
# include <bits/stl_function.h> // std::less
# include <bits/uses_allocator.h>
# include <bits/alloc_traits.h>
# include <type_traits>
# include <debug/debug.h>
# include <bits/unique_ptr.h>
# include <bits/shared_ptr.h>
# include <bits/shared_ptr_atomic.h>
# if _GLIBCXX_USE_DEPRECATED
# include <backward/auto_ptr.h>
# endif
#else
#endif
#if __cplusplus < 201103L || _GLIBCXX_USE_DEPRECATED
# include <backward/auto_ptr.h>
#endif
#if __cplusplus >= 201103L
#include <cstdint>
#if __cplusplus > 201703L
# include <bit> // for has_single_bit
# include <new> // for placement operator new
# include <tuple> // for tuple, make_tuple, make_from_tuple
# include <bits/ranges_uninitialized.h>
# include <bits/uses_allocator_args.h>
#endif
#if __cplusplus >= 201103L
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
@ -140,210 +130,11 @@ inline pointer_safety
get_pointer_safety() noexcept { return pointer_safety::relaxed; }
// @}
#if __cplusplus > 201703L
template<typename _Tp>
struct __is_pair : false_type { };
template<typename _Tp, typename _Up>
struct __is_pair<pair<_Tp, _Up>> : true_type { };
template<typename _Tp, typename _Up>
struct __is_pair<const pair<_Tp, _Up>> : true_type { };
/** @addtogroup allocators
* @{
*/
template<typename _Tp, typename __ = _Require<__not_<__is_pair<_Tp>>>,
typename _Alloc, typename... _Args>
constexpr auto
__uses_alloc_args(const _Alloc& __a, _Args&&... __args) noexcept
{
if constexpr (uses_allocator_v<remove_cv_t<_Tp>, _Alloc>)
{
if constexpr (is_constructible_v<_Tp, allocator_arg_t,
const _Alloc&, _Args...>)
{
return tuple<allocator_arg_t, const _Alloc&, _Args&&...>(
allocator_arg, __a, std::forward<_Args>(__args)...);
}
else
{
static_assert(is_constructible_v<_Tp, _Args..., const _Alloc&>,
"construction with an allocator must be possible"
" if uses_allocator is true");
return tuple<_Args&&..., const _Alloc&>(
std::forward<_Args>(__args)..., __a);
}
}
else
{
static_assert(is_constructible_v<_Tp, _Args...>);
return tuple<_Args&&...>(std::forward<_Args>(__args)...);
}
}
#if __cpp_concepts
template<typename _Tp>
concept _Std_pair = __is_pair<_Tp>::value;
#endif
// This is a temporary workaround until -fconcepts is implied by -std=gnu++2a
#if __cpp_concepts
# define _GLIBCXX_STD_PAIR_CONSTRAINT(T) _Std_pair T
# define _GLIBCXX_STD_PAIR_CONSTRAINT_(T) _Std_pair T
#else
# define _GLIBCXX_STD_PAIR_CONSTRAINT(T) \
typename T, typename __ = _Require<__is_pair<T>>
# define _GLIBCXX_STD_PAIR_CONSTRAINT_(T) typename T, typename
#endif
template<typename _Tp,
#if ! __cpp_concepts
typename __ = _Require<__not_<__is_pair<_Tp>>>,
#endif
typename _Alloc, typename... _Args>
constexpr auto
uses_allocator_construction_args(const _Alloc& __a,
_Args&&... __args) noexcept
#if __cpp_concepts
requires (! _Std_pair<_Tp>)
#endif
{
return std::__uses_alloc_args<_Tp>(__a, std::forward<_Args>(__args)...);
}
template<_GLIBCXX_STD_PAIR_CONSTRAINT(_Tp), typename _Alloc,
typename _Tuple1, typename _Tuple2>
constexpr auto
uses_allocator_construction_args(const _Alloc& __a, piecewise_construct_t,
_Tuple1&& __x, _Tuple2&& __y) noexcept;
template<_GLIBCXX_STD_PAIR_CONSTRAINT(_Tp), typename _Alloc>
constexpr auto
uses_allocator_construction_args(const _Alloc&) noexcept;
template<_GLIBCXX_STD_PAIR_CONSTRAINT(_Tp), typename _Alloc,
typename _Up, typename _Vp>
constexpr auto
uses_allocator_construction_args(const _Alloc&, _Up&&, _Vp&&) noexcept;
template<_GLIBCXX_STD_PAIR_CONSTRAINT(_Tp), typename _Alloc,
typename _Up, typename _Vp>
constexpr auto
uses_allocator_construction_args(const _Alloc&,
const pair<_Up, _Vp>&) noexcept;
template<_GLIBCXX_STD_PAIR_CONSTRAINT(_Tp), typename _Alloc,
typename _Up, typename _Vp>
constexpr auto
uses_allocator_construction_args(const _Alloc&, pair<_Up, _Vp>&&) noexcept;
template<_GLIBCXX_STD_PAIR_CONSTRAINT_(_Tp), typename _Alloc,
typename _Tuple1, typename _Tuple2>
constexpr auto
uses_allocator_construction_args(const _Alloc& __a, piecewise_construct_t,
_Tuple1&& __x, _Tuple2&& __y) noexcept
{
using _Tp1 = typename _Tp::first_type;
using _Tp2 = typename _Tp::second_type;
return std::make_tuple(piecewise_construct,
std::apply([&__a](auto&&... __args1) {
return std::uses_allocator_construction_args<_Tp1>(
__a, std::forward<decltype(__args1)>(__args1)...);
}, std::forward<_Tuple1>(__x)),
std::apply([&__a](auto&&... __args2) {
return std::uses_allocator_construction_args<_Tp2>(
__a, std::forward<decltype(__args2)>(__args2)...);
}, std::forward<_Tuple2>(__y)));
}
template<_GLIBCXX_STD_PAIR_CONSTRAINT_(_Tp), typename _Alloc>
constexpr auto
uses_allocator_construction_args(const _Alloc& __a) noexcept
{
using _Tp1 = typename _Tp::first_type;
using _Tp2 = typename _Tp::second_type;
return std::make_tuple(piecewise_construct,
std::uses_allocator_construction_args<_Tp1>(__a),
std::uses_allocator_construction_args<_Tp2>(__a));
}
template<_GLIBCXX_STD_PAIR_CONSTRAINT_(_Tp), typename _Alloc,
typename _Up, typename _Vp>
constexpr auto
uses_allocator_construction_args(const _Alloc& __a, _Up&& __u, _Vp&& __v)
noexcept
{
using _Tp1 = typename _Tp::first_type;
using _Tp2 = typename _Tp::second_type;
return std::make_tuple(piecewise_construct,
std::uses_allocator_construction_args<_Tp1>(__a,
std::forward<_Up>(__u)),
std::uses_allocator_construction_args<_Tp2>(__a,
std::forward<_Vp>(__v)));
}
template<_GLIBCXX_STD_PAIR_CONSTRAINT_(_Tp), typename _Alloc,
typename _Up, typename _Vp>
constexpr auto
uses_allocator_construction_args(const _Alloc& __a,
const pair<_Up, _Vp>& __pr) noexcept
{
using _Tp1 = typename _Tp::first_type;
using _Tp2 = typename _Tp::second_type;
return std::make_tuple(piecewise_construct,
std::uses_allocator_construction_args<_Tp1>(__a, __pr.first),
std::uses_allocator_construction_args<_Tp2>(__a, __pr.second));
}
template<_GLIBCXX_STD_PAIR_CONSTRAINT_(_Tp), typename _Alloc,
typename _Up, typename _Vp>
constexpr auto
uses_allocator_construction_args(const _Alloc& __a,
pair<_Up, _Vp>&& __pr) noexcept
{
using _Tp1 = typename _Tp::first_type;
using _Tp2 = typename _Tp::second_type;
return std::make_tuple(piecewise_construct,
std::uses_allocator_construction_args<_Tp1>(__a,
std::move(__pr).first),
std::uses_allocator_construction_args<_Tp2>(__a,
std::move(__pr).second));
}
template<typename _Tp, typename _Alloc, typename... _Args>
inline _Tp
make_obj_using_allocator(const _Alloc& __a, _Args&&... __args)
{
return std::make_from_tuple<_Tp>(
std::uses_allocator_construction_args<_Tp>(__a,
std::forward<_Args>(__args)...));
}
template<typename _Tp, typename _Alloc, typename... _Args>
inline _Tp*
uninitialized_construct_using_allocator(_Tp* __p, const _Alloc& __a,
_Args&&... __args)
{
return std::apply([&](auto&&... __xs) {
return std::construct_at(__p, std::forward<decltype(__xs)>(__xs)...);
}, std::uses_allocator_construction_args<_Tp>(__a,
std::forward<_Args>(__args)...));
}
// @}
#endif // C++2a
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif // C++11
#if __cplusplus > 201402L
#if __cplusplus >= 201703L
// Parallel STL algorithms
# if _PSTL_EXECUTION_POLICIES_DEFINED
// If <execution> has already been included, pull in implementations

View File

@ -33,15 +33,20 @@
#if __cplusplus >= 201703L
#include <memory> // align, allocator_arg_t, __uses_alloc
#include <utility> // pair, index_sequence
#include <vector> // vector
#include <cstddef> // size_t, max_align_t, byte
#include <shared_mutex> // shared_mutex
#include <bits/functexcept.h>
#include <bits/align.h> // align
#include <bits/functexcept.h> // __throw_bad_array_new_length
#include <bits/uses_allocator.h> // __use_alloc
#include <bits/uses_allocator_args.h> // uninitialized_construct_using_alloc
#include <ext/numeric_traits.h>
#include <debug/assertions.h>
#if ! __cpp_lib_make_obj_using_allocator
# include <utility> // pair, index_sequence
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
@ -49,7 +54,7 @@ namespace pmr
{
#ifdef _GLIBCXX_HAS_GTHREADS
// Header and all contents are present.
# define __cpp_lib_memory_resource 201603
# define __cpp_lib_memory_resource 201603L
#else
// The pmr::synchronized_pool_resource type is missing.
# define __cpp_lib_memory_resource 1
@ -231,7 +236,7 @@ namespace pmr
}
#endif // C++2a
#if __cplusplus == 201703L
#if ! __cpp_lib_make_obj_using_allocator
template<typename _Tp1, typename... _Args>
__attribute__((__nonnull__))
typename __not_pair<_Tp1>::type
@ -304,7 +309,7 @@ namespace pmr
forward_as_tuple(std::forward<_Up>(__pr.first)),
forward_as_tuple(std::forward<_Vp>(__pr.second)));
}
#else
#else // make_obj_using_allocator
template<typename _Tp1, typename... _Args>
__attribute__((__nonnull__))
void
@ -334,6 +339,7 @@ namespace pmr
using __uses_alloc1_ = __uses_alloc1<polymorphic_allocator>;
using __uses_alloc2_ = __uses_alloc2<polymorphic_allocator>;
#if ! __cpp_lib_make_obj_using_allocator
template<typename _Ind, typename... _Args>
static tuple<_Args&&...>
_S_construct_p(__uses_alloc0, _Ind, tuple<_Args...>& __t)
@ -354,6 +360,7 @@ namespace pmr
_S_construct_p(__uses_alloc2_ __ua, index_sequence<_Ind...>,
tuple<_Args...>& __t)
{ return { std::get<_Ind>(std::move(__t))..., *__ua._M_a }; }
#endif
memory_resource* _M_resource;
};

View File

@ -36,10 +36,13 @@
# include <bits/c++0x_warning.h>
#else
#include <memory>
#include <utility>
#include <tuple>
#include <bits/alloc_traits.h>
#include <bits/stl_pair.h>
#include <bits/uses_allocator.h>
#if __cplusplus > 201703L
# include <bits/uses_allocator_args.h>
#endif
namespace std _GLIBCXX_VISIBILITY(default)
{
@ -194,7 +197,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
using __outermost_alloc_traits
= allocator_traits<typename __outermost_type<_Alloc>::type>;
#if __cplusplus <= 201703
#if ! __cpp_lib_make_obj_using_allocator
template<typename _Tp, typename... _Args>
void
_M_construct(__uses_alloc0, _Tp* __p, _Args&&... __args)
@ -226,7 +229,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
std::forward<_Args>(__args)...,
inner_allocator());
}
#endif // C++17
#endif // ! make_obj_using_allocator
template<typename _Alloc>
static _Alloc
@ -364,7 +367,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
size_type max_size() const
{ return __traits::max_size(outer_allocator()); }
#if __cplusplus <= 201703
#if ! __cpp_lib_make_obj_using_allocator
template<typename _Tp, typename... _Args>
typename __not_pair<_Tp>::type
construct(_Tp* __p, _Args&&... __args)
@ -427,7 +430,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
std::forward_as_tuple(std::forward<_Up>(__x.first)),
std::forward_as_tuple(std::forward<_Vp>(__x.second)));
}
#else // C++2a
#else // make_obj_using_allocator
template<typename _Tp, typename... _Args>
__attribute__((__nonnull__))
void
@ -441,7 +444,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
uses_allocator_construction_args<_Tp>(inner_allocator(),
std::forward<_Args>(__args)...));
}
#endif // C++2a
#endif
template<typename _Tp>
void destroy(_Tp* __p)
@ -464,7 +467,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept;
private:
#if __cplusplus <= 201703L
#if ! __cpp_lib_make_obj_using_allocator
template<typename _Ind, typename... _Args>
tuple<_Args&&...>
_M_construct_p(__uses_alloc0, _Ind, tuple<_Args...>& __t)
@ -487,7 +490,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
return { std::get<_Ind>(std::move(__t))..., inner_allocator() };
}
#endif // C++17
#endif // ! make_obj_using_allocator
};
/// @related std::scoped_allocator_adaptor

View File

@ -144,7 +144,7 @@
#define __cpp_lib_map_try_emplace 201411
#define __cpp_lib_math_special_functions 201603L
#ifdef _GLIBCXX_HAS_GTHREADS
# define __cpp_lib_memory_resource 201603
# define __cpp_lib_memory_resource 201603L
#else
# define __cpp_lib_memory_resource 1
#endif
@ -217,6 +217,9 @@
# define __cpp_lib_jthread 201911L
#endif
#define __cpp_lib_list_remove_return_type 201806L
#if __cpp_lib_concepts
# define __cpp_lib_make_obj_using_allocator 201811L
#endif
#define __cpp_lib_math_constants 201907L
#define __cpp_lib_polymorphic_allocator 201902L
#if __cpp_lib_concepts