From b1e7c6fce15b8ad222f265df2537701407fd289e Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 22 Oct 2020 18:42:03 +0100 Subject: [PATCH] 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. --- libstdc++-v3/include/Makefile.am | 1 + libstdc++-v3/include/Makefile.in | 1 + libstdc++-v3/include/bits/shared_ptr.h | 1 + libstdc++-v3/include/bits/shared_ptr_base.h | 8 +- .../include/bits/uses_allocator_args.h | 227 ++++++++++++++++++ libstdc++-v3/include/std/condition_variable | 3 - libstdc++-v3/include/std/future | 7 +- libstdc++-v3/include/std/memory | 227 +----------------- libstdc++-v3/include/std/memory_resource | 19 +- libstdc++-v3/include/std/scoped_allocator | 21 +- libstdc++-v3/include/std/version | 5 +- 11 files changed, 278 insertions(+), 242 deletions(-) create mode 100644 libstdc++-v3/include/bits/uses_allocator_args.h 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 \ ${bits_srcdir}/valarray_before.h \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 2dfd8d2cb36..aa751f62c4f 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -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 \ diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h index 0bfb525aae7..92394c6a9e6 100644 --- a/libstdc++-v3/include/bits/shared_ptr.h +++ b/libstdc++-v3/include/bits/shared_ptr.h @@ -49,6 +49,7 @@ #ifndef _SHARED_PTR_H #define _SHARED_PTR_H 1 +#include // std::basic_ostream #include namespace std _GLIBCXX_VISIBILITY(default) diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h index ca37f2bebd6..a9e1c9bb1d5 100644 --- a/libstdc++-v3/include/bits/shared_ptr_base.h +++ b/libstdc++-v3/include/bits/shared_ptr_base.h @@ -51,9 +51,15 @@ #include #include +#include +#include +#include #include -#include +#include // std::less +#include #include +#include +#include #if __cplusplus > 201703L # include #endif diff --git a/libstdc++-v3/include/bits/uses_allocator_args.h b/libstdc++-v3/include/bits/uses_allocator_args.h new file mode 100644 index 00000000000..2f10c8b1745 --- /dev/null +++ b/libstdc++-v3/include/bits/uses_allocator_args.h @@ -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 +// . + +/* + * 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 // for placement operator new +#include // for tuple, make_tuple, make_from_tuple +#include // construct_at +#include // pair + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + template + inline constexpr bool __is_pair = false; + template + inline constexpr bool __is_pair> = true; + template + inline constexpr bool __is_pair> = true; + + template + concept _Std_pair = __is_pair<_Tp>; + +/** @addtogroup allocators + * @{ + */ + +// Not specified by C++20, used internally +#define __cpp_lib_make_obj_using_allocator 201811L + + template + constexpr auto + uses_allocator_construction_args(const _Alloc& __a, + _Args&&... __args) noexcept + requires (! _Std_pair<_Tp>) + { + if constexpr (uses_allocator_v, _Alloc>) + { + if constexpr (is_constructible_v<_Tp, allocator_arg_t, + const _Alloc&, _Args...>) + { + return tuple( + 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(__args1)...); + }, std::forward<_Tuple1>(__x)), + std::apply([&__a](auto&&... __args2) { + return std::uses_allocator_construction_args<_Tp2>( + __a, std::forward(__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 + 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 + 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(__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 diff --git a/libstdc++-v3/include/std/condition_variable b/libstdc++-v3/include/std/condition_variable index 1abec546320..7406fde6e4b 100644 --- a/libstdc++-v3/include/std/condition_variable +++ b/libstdc++-v3/include/std/condition_variable @@ -39,10 +39,7 @@ #include #include -#include #include -#include -#include #include #include diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future index a7466a32e03..3c2aaa1fab1 100644 --- a/libstdc++-v3/include/std/future +++ b/libstdc++-v3/include/std/future @@ -35,19 +35,18 @@ # include #else -#include +#include // call_once #include -#include +#include // __at_thread_exit_elt #include #include +#include #include -#include #include #include #include #include #include -#include #include namespace std _GLIBCXX_VISIBILITY(default) diff --git a/libstdc++-v3/include/std/memory b/libstdc++-v3/include/std/memory index aee7b050bd7..41ba74dd36f 100644 --- a/libstdc++-v3/include/std/memory +++ b/libstdc++-v3/include/std/memory @@ -66,38 +66,28 @@ #include #include #include -#include #if __cplusplus >= 201103L -# include // std::exception -# include // std::type_info in get_deleter -# include // std::basic_ostream -# include -# include +# include # include -# include -# include // std::less # include # include -# include # include # include # include # include -# if _GLIBCXX_USE_DEPRECATED -# include -# endif -#else +#endif + +#if __cplusplus < 201103L || _GLIBCXX_USE_DEPRECATED # include #endif -#if __cplusplus >= 201103L -#include #if __cplusplus > 201703L -# include // for has_single_bit -# include // for placement operator new -# include // for tuple, make_tuple, make_from_tuple +# include +# include #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 - struct __is_pair : false_type { }; - template - struct __is_pair> : true_type { }; - template - struct __is_pair> : true_type { }; - -/** @addtogroup allocators - * @{ - */ - template>>, - typename _Alloc, typename... _Args> - constexpr auto - __uses_alloc_args(const _Alloc& __a, _Args&&... __args) noexcept - { - if constexpr (uses_allocator_v, _Alloc>) - { - if constexpr (is_constructible_v<_Tp, allocator_arg_t, - const _Alloc&, _Args...>) - { - return tuple( - 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 - 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> -# define _GLIBCXX_STD_PAIR_CONSTRAINT_(T) typename T, typename -#endif - - template>>, -#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(__args1)...); - }, std::forward<_Tuple1>(__x)), - std::apply([&__a](auto&&... __args2) { - return std::uses_allocator_construction_args<_Tp2>( - __a, std::forward(__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 - 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 - 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(__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 has already been included, pull in implementations diff --git a/libstdc++-v3/include/std/memory_resource b/libstdc++-v3/include/std/memory_resource index 6491179a7c5..350799ee382 100644 --- a/libstdc++-v3/include/std/memory_resource +++ b/libstdc++-v3/include/std/memory_resource @@ -33,15 +33,20 @@ #if __cplusplus >= 201703L -#include // align, allocator_arg_t, __uses_alloc -#include // pair, index_sequence #include // vector #include // size_t, max_align_t, byte #include // shared_mutex -#include +#include // align +#include // __throw_bad_array_new_length +#include // __use_alloc +#include // uninitialized_construct_using_alloc #include #include +#if ! __cpp_lib_make_obj_using_allocator +# include // 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 __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 __attribute__((__nonnull__)) void @@ -334,6 +339,7 @@ namespace pmr using __uses_alloc1_ = __uses_alloc1; using __uses_alloc2_ = __uses_alloc2; +#if ! __cpp_lib_make_obj_using_allocator template 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; }; diff --git a/libstdc++-v3/include/std/scoped_allocator b/libstdc++-v3/include/std/scoped_allocator index 969b6d8e8c2..5f2fa5fac96 100644 --- a/libstdc++-v3/include/std/scoped_allocator +++ b/libstdc++-v3/include/std/scoped_allocator @@ -36,10 +36,13 @@ # include #else -#include -#include #include #include +#include +#include +#if __cplusplus > 201703L +# include +#endif namespace std _GLIBCXX_VISIBILITY(default) { @@ -194,7 +197,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using __outermost_alloc_traits = allocator_traits::type>; -#if __cplusplus <= 201703 +#if ! __cpp_lib_make_obj_using_allocator template 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 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 __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 __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 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 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 diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index d5d42ed0a72..9c16f2c4e70 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -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 -- 2.30.2