gcc/libstdc++-v3/include/bits/uses_allocator.h

198 lines
6.7 KiB
C
Raw Normal View History

// Uses-allocator Construction -*- C++ -*-
2022-01-03 10:42:10 +01:00
// Copyright (C) 2010-2022 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/>.
#ifndef _USES_ALLOCATOR_H
#define _USES_ALLOCATOR_H 1
#if __cplusplus < 201103L
# include <bits/c++0x_warning.h>
#else
#include <type_traits>
#include <bits/move.h>
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/// @cond undocumented
// This is used for std::experimental::erased_type from Library Fundamentals.
struct __erased_type { };
// This also supports the "type-erased allocator" protocol from the
// Library Fundamentals TS, where allocator_type is erased_type.
// The second condition will always be false for types not using the TS.
template<typename _Alloc, typename _Tp>
using __is_erased_or_convertible
= __or_<is_convertible<_Alloc, _Tp>, is_same<_Tp, __erased_type>>;
/// [allocator.tag]
struct allocator_arg_t { explicit allocator_arg_t() = default; };
Implement P0607R0 "Inline Variables for Standard Library" for C++17 2017-03-23 Daniel Kruegler <daniel.kruegler@gmail.com> * include/bits/c++config (_GLIBCXX17_INLINE): Define. * include/bits/regex_constants.h (All std::regex_constants constants): Add _GLIBCXX17_INLINE as per P0607R0. * include/bits/std_mutex.h (defer_lock, try_to_lock, adopt_lock): Likewise. * include/bits/stl_pair.h (piecewise_construct): Likewise. * include/bits/uses_allocator.h (allocator_arg, uses_allocator_v) (__is_uses_allocator_constructible_v) (__is_nothrow_uses_allocator_constructible_v): Likewise. * include/std/chrono (treat_as_floating_point_v): Likewise. * include/std/functional (is_bind_expression_v, is_placeholder_v): Likewise. * include/std/optional (nullopt): Likewise. * include/std/ratio (ratio_equal_v, ratio_not_equal_v, ratio_less_v) ratio_less_equal_v, ratio_greater_v, ratio_greater_equal_v): Likewise. * include/std/system_error (is_error_code_enum_v) (is_error_condition_enum_v): Likewise. * include/std/tuple (tuple_size_v, ignore): Likewise. (ignore): Declare ignore constexpr as per LWG 2773, declare assignment constexpr as per LWG 2933. * include/std/type_traits (All variable templates): Add _GLIBCXX17_INLINE as per P0607R0. * include/std/variant (variant_size_v, variant_npos, __index_of_v) (__tuple_count_v, __exactly_once): Likewise. * testsuite/18_support/headers/new/synopsis.cc (hardware_destructive_interference_size) (hardware_constructive_interference_size): Likewise for commented-out variables. * testsuite/20_util/tuple/creation_functions/constexpr.cc: Add new test function for constexpr std::ignore (LWG 2773). * testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc: New test for LWG 2933. From-SVN: r246423
2017-03-23 20:40:07 +01:00
_GLIBCXX17_INLINE constexpr allocator_arg_t allocator_arg =
allocator_arg_t();
template<typename _Tp, typename _Alloc, typename = __void_t<>>
struct __uses_allocator_helper
: false_type { };
template<typename _Tp, typename _Alloc>
struct __uses_allocator_helper<_Tp, _Alloc,
__void_t<typename _Tp::allocator_type>>
: __is_erased_or_convertible<_Alloc, typename _Tp::allocator_type>::type
{ };
/// [allocator.uses.trait]
template<typename _Tp, typename _Alloc>
struct uses_allocator
: __uses_allocator_helper<_Tp, _Alloc>::type
{ };
struct __uses_alloc_base { };
struct __uses_alloc0 : __uses_alloc_base
{
struct _Sink { void _GLIBCXX20_CONSTEXPR operator=(const void*) { } } _M_a;
};
template<typename _Alloc>
struct __uses_alloc1 : __uses_alloc_base { const _Alloc* _M_a; };
template<typename _Alloc>
struct __uses_alloc2 : __uses_alloc_base { const _Alloc* _M_a; };
template<bool, typename _Tp, typename _Alloc, typename... _Args>
struct __uses_alloc;
template<typename _Tp, typename _Alloc, typename... _Args>
struct __uses_alloc<true, _Tp, _Alloc, _Args...>
libstdc++: Add std::__conditional_t alias template This change is inspired by the suggestion in http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1715r0.html The new std::__conditional_t alias template is functionally equivalent to std::conditional_t but should be more efficient to compile, due to only ever instantiating two specializations (std::__conditional<true> and std::__conditional<false>) rather than a new specialization for every use of std::conditional. The new alias template is also available in C++11, unlike the C++14 std::conditional_t alias. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/std/type_traits (__conditional): New class template for internal uses of std::conditional. (__conditional_t): New alias template to replace conditional_t. (__and_, __or_, __result_of_memfun, __result_of_memobj): Use __conditional_t instead of conditional::type. * include/bits/atomic_base.h (__atomic_impl::_Diff): Likewise. * include/bits/hashtable.h (_Hashtable): Likewise. * include/bits/hashtable_policy.h (_Node_iterator, _Insert_base) (_Local_iterator): Likewise. Replace typedefs with using-declarations. * include/bits/move.h (move_if_noexcept): Use __conditional_t. * include/bits/parse_numbers.h (_Select_int_base): Likewise. * include/bits/ptr_traits.h (__make_not_void): Likewise. * include/bits/ranges_algobase.h (__copy_or_move_backward) (__copy_or_move): Likewise. * include/bits/ranges_base.h (borrowed_iterator_t): Likewise. * include/bits/ranges_util.h (borrowed_subrange_t): Likewise. * include/bits/regex_compiler.h (_BracketMatcher): Use __conditional_t. Replace typedefs with using-declarations. * include/bits/shared_ptr_base.h (__shared_count): Use __conditional_t. * include/bits/stl_algobase.h (__copy_move, __copy_move_backward): Likewise. * include/bits/stl_iterator.h (__detail::__clamp_iter_cat) (reverse_iterator::iterator_concept) (__make_move_if_noexcept_iterator) (iterator_traits<common_iterator<_It, _Sent>>) (iterator_traits<counted_iterator<_It>>): Likewise. * include/bits/stl_pair.h (_PCC, pair::operator=): Likewise. * include/bits/stl_tree.h (_Rb_tree::insert_return_type) (_Rb_tree::_M_clone_node): Likewise. * include/bits/unique_ptr.h (unique_ptr(unique_ptr<U,E>&&)): Likewise. * include/bits/uses_allocator.h (__uses_alloc): Likewise. (__is_uses_allocator_predicate): Likewise. * include/debug/functions.h (__foreign_iterator_aux2): Likewise. * include/experimental/any (any::_Manager, __any_caster): Likewise. * include/experimental/executor (async_completion): Likewise. * include/experimental/functional (__boyer_moore_base_t): Likewise. * include/std/any (any::_Manager): Likewise. * include/std/functional (__boyer_moore_base_t): Likewise. * include/std/ranges (borrowed_iterator_t) (borrowed_subrange_t, __detail::__maybe_present_t) (__detail::__maybe_const_t, split_view): Likewise. * include/std/tuple (__empty_not_final, tuple::operator=): Likewise. * include/std/variant (__detail::__variant::__get_t): Likewise.
2021-05-06 17:26:21 +02:00
: __conditional_t<
DR 2586 fix value category in uses-allocator checks Because uses-allocator construction is invariably done with a const lvalue the __uses_alloc helper should use a const lvalue for the is_constructible checks. Otherwise, it can detect that the type can be constructed from an rvalue, and then an error happens when a const lvalue is passed to the constructor instead. Prior to LWG DR 2586 scoped_allocator_adaptor incorrectly used an rvalue type in the is_constructible check and then used a non-const lvalue for the actual construction. The other components using uses-allocator construction (tuple and polymorphic_allocator) have always done so with a const lvalue allocator, although the use of __use_alloc in our implementation meant they behaved the same as scoped_allocator_adaptor and incorrectly used rvalues for the is_constructible checks. In C++20 the P0591R4 changes mean that all uses-allocator construction is defined in terms of the new uses_allocator_construction_args functions, which always use a const lvalue allocator. The changes in this patch ensure that the __use_alloc helper correctly matches the requirements in the standard, consistently using a const lvalue allocator for the is_constructible checks and the actual constructor arguments. * doc/xml/manual/intro.xml: Document LWG 2586 status. * include/bits/uses_allocator.h (__uses_alloc): Use const lvalue allocator type in is_constructible checks. * testsuite/20_util/scoped_allocator/69293_neg.cc: Adjust dg-error. * testsuite/20_util/scoped_allocator/dr2586.cc: New test. * testsuite/20_util/tuple/cons/allocators.cc: Add test using problematic type from LWG 2586 discussion. * testsuite/20_util/uses_allocator/69293_neg.cc: Adjust dg-error. * testsuite/20_util/uses_allocator/cons_neg.cc: Likewise. From-SVN: r268882
2019-02-14 16:08:33 +01:00
is_constructible<_Tp, allocator_arg_t, const _Alloc&, _Args...>::value,
__uses_alloc1<_Alloc>,
libstdc++: Add std::__conditional_t alias template This change is inspired by the suggestion in http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1715r0.html The new std::__conditional_t alias template is functionally equivalent to std::conditional_t but should be more efficient to compile, due to only ever instantiating two specializations (std::__conditional<true> and std::__conditional<false>) rather than a new specialization for every use of std::conditional. The new alias template is also available in C++11, unlike the C++14 std::conditional_t alias. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/std/type_traits (__conditional): New class template for internal uses of std::conditional. (__conditional_t): New alias template to replace conditional_t. (__and_, __or_, __result_of_memfun, __result_of_memobj): Use __conditional_t instead of conditional::type. * include/bits/atomic_base.h (__atomic_impl::_Diff): Likewise. * include/bits/hashtable.h (_Hashtable): Likewise. * include/bits/hashtable_policy.h (_Node_iterator, _Insert_base) (_Local_iterator): Likewise. Replace typedefs with using-declarations. * include/bits/move.h (move_if_noexcept): Use __conditional_t. * include/bits/parse_numbers.h (_Select_int_base): Likewise. * include/bits/ptr_traits.h (__make_not_void): Likewise. * include/bits/ranges_algobase.h (__copy_or_move_backward) (__copy_or_move): Likewise. * include/bits/ranges_base.h (borrowed_iterator_t): Likewise. * include/bits/ranges_util.h (borrowed_subrange_t): Likewise. * include/bits/regex_compiler.h (_BracketMatcher): Use __conditional_t. Replace typedefs with using-declarations. * include/bits/shared_ptr_base.h (__shared_count): Use __conditional_t. * include/bits/stl_algobase.h (__copy_move, __copy_move_backward): Likewise. * include/bits/stl_iterator.h (__detail::__clamp_iter_cat) (reverse_iterator::iterator_concept) (__make_move_if_noexcept_iterator) (iterator_traits<common_iterator<_It, _Sent>>) (iterator_traits<counted_iterator<_It>>): Likewise. * include/bits/stl_pair.h (_PCC, pair::operator=): Likewise. * include/bits/stl_tree.h (_Rb_tree::insert_return_type) (_Rb_tree::_M_clone_node): Likewise. * include/bits/unique_ptr.h (unique_ptr(unique_ptr<U,E>&&)): Likewise. * include/bits/uses_allocator.h (__uses_alloc): Likewise. (__is_uses_allocator_predicate): Likewise. * include/debug/functions.h (__foreign_iterator_aux2): Likewise. * include/experimental/any (any::_Manager, __any_caster): Likewise. * include/experimental/executor (async_completion): Likewise. * include/experimental/functional (__boyer_moore_base_t): Likewise. * include/std/any (any::_Manager): Likewise. * include/std/functional (__boyer_moore_base_t): Likewise. * include/std/ranges (borrowed_iterator_t) (borrowed_subrange_t, __detail::__maybe_present_t) (__detail::__maybe_const_t, split_view): Likewise. * include/std/tuple (__empty_not_final, tuple::operator=): Likewise. * include/std/variant (__detail::__variant::__get_t): Likewise.
2021-05-06 17:26:21 +02:00
__uses_alloc2<_Alloc>>
{
DR 2586 fix value category in uses-allocator checks Because uses-allocator construction is invariably done with a const lvalue the __uses_alloc helper should use a const lvalue for the is_constructible checks. Otherwise, it can detect that the type can be constructed from an rvalue, and then an error happens when a const lvalue is passed to the constructor instead. Prior to LWG DR 2586 scoped_allocator_adaptor incorrectly used an rvalue type in the is_constructible check and then used a non-const lvalue for the actual construction. The other components using uses-allocator construction (tuple and polymorphic_allocator) have always done so with a const lvalue allocator, although the use of __use_alloc in our implementation meant they behaved the same as scoped_allocator_adaptor and incorrectly used rvalues for the is_constructible checks. In C++20 the P0591R4 changes mean that all uses-allocator construction is defined in terms of the new uses_allocator_construction_args functions, which always use a const lvalue allocator. The changes in this patch ensure that the __use_alloc helper correctly matches the requirements in the standard, consistently using a const lvalue allocator for the is_constructible checks and the actual constructor arguments. * doc/xml/manual/intro.xml: Document LWG 2586 status. * include/bits/uses_allocator.h (__uses_alloc): Use const lvalue allocator type in is_constructible checks. * testsuite/20_util/scoped_allocator/69293_neg.cc: Adjust dg-error. * testsuite/20_util/scoped_allocator/dr2586.cc: New test. * testsuite/20_util/tuple/cons/allocators.cc: Add test using problematic type from LWG 2586 discussion. * testsuite/20_util/uses_allocator/69293_neg.cc: Adjust dg-error. * testsuite/20_util/uses_allocator/cons_neg.cc: Likewise. From-SVN: r268882
2019-02-14 16:08:33 +01:00
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2586. Wrong value category used in scoped_allocator_adaptor::construct
static_assert(__or_<
DR 2586 fix value category in uses-allocator checks Because uses-allocator construction is invariably done with a const lvalue the __uses_alloc helper should use a const lvalue for the is_constructible checks. Otherwise, it can detect that the type can be constructed from an rvalue, and then an error happens when a const lvalue is passed to the constructor instead. Prior to LWG DR 2586 scoped_allocator_adaptor incorrectly used an rvalue type in the is_constructible check and then used a non-const lvalue for the actual construction. The other components using uses-allocator construction (tuple and polymorphic_allocator) have always done so with a const lvalue allocator, although the use of __use_alloc in our implementation meant they behaved the same as scoped_allocator_adaptor and incorrectly used rvalues for the is_constructible checks. In C++20 the P0591R4 changes mean that all uses-allocator construction is defined in terms of the new uses_allocator_construction_args functions, which always use a const lvalue allocator. The changes in this patch ensure that the __use_alloc helper correctly matches the requirements in the standard, consistently using a const lvalue allocator for the is_constructible checks and the actual constructor arguments. * doc/xml/manual/intro.xml: Document LWG 2586 status. * include/bits/uses_allocator.h (__uses_alloc): Use const lvalue allocator type in is_constructible checks. * testsuite/20_util/scoped_allocator/69293_neg.cc: Adjust dg-error. * testsuite/20_util/scoped_allocator/dr2586.cc: New test. * testsuite/20_util/tuple/cons/allocators.cc: Add test using problematic type from LWG 2586 discussion. * testsuite/20_util/uses_allocator/69293_neg.cc: Adjust dg-error. * testsuite/20_util/uses_allocator/cons_neg.cc: Likewise. From-SVN: r268882
2019-02-14 16:08:33 +01:00
is_constructible<_Tp, allocator_arg_t, const _Alloc&, _Args...>,
is_constructible<_Tp, _Args..., const _Alloc&>>::value,
"construction with an allocator must be possible"
" if uses_allocator is true");
};
template<typename _Tp, typename _Alloc, typename... _Args>
struct __uses_alloc<false, _Tp, _Alloc, _Args...>
: __uses_alloc0 { };
template<typename _Tp, typename _Alloc, typename... _Args>
using __uses_alloc_t =
__uses_alloc<uses_allocator<_Tp, _Alloc>::value, _Tp, _Alloc, _Args...>;
template<typename _Tp, typename _Alloc, typename... _Args>
_GLIBCXX20_CONSTEXPR
inline __uses_alloc_t<_Tp, _Alloc, _Args...>
__use_alloc(const _Alloc& __a)
{
__uses_alloc_t<_Tp, _Alloc, _Args...> __ret;
__ret._M_a = std::__addressof(__a);
return __ret;
}
template<typename _Tp, typename _Alloc, typename... _Args>
void
__use_alloc(const _Alloc&&) = delete;
#if __cplusplus > 201402L
template <typename _Tp, typename _Alloc>
Implement P0607R0 "Inline Variables for Standard Library" for C++17 2017-03-23 Daniel Kruegler <daniel.kruegler@gmail.com> * include/bits/c++config (_GLIBCXX17_INLINE): Define. * include/bits/regex_constants.h (All std::regex_constants constants): Add _GLIBCXX17_INLINE as per P0607R0. * include/bits/std_mutex.h (defer_lock, try_to_lock, adopt_lock): Likewise. * include/bits/stl_pair.h (piecewise_construct): Likewise. * include/bits/uses_allocator.h (allocator_arg, uses_allocator_v) (__is_uses_allocator_constructible_v) (__is_nothrow_uses_allocator_constructible_v): Likewise. * include/std/chrono (treat_as_floating_point_v): Likewise. * include/std/functional (is_bind_expression_v, is_placeholder_v): Likewise. * include/std/optional (nullopt): Likewise. * include/std/ratio (ratio_equal_v, ratio_not_equal_v, ratio_less_v) ratio_less_equal_v, ratio_greater_v, ratio_greater_equal_v): Likewise. * include/std/system_error (is_error_code_enum_v) (is_error_condition_enum_v): Likewise. * include/std/tuple (tuple_size_v, ignore): Likewise. (ignore): Declare ignore constexpr as per LWG 2773, declare assignment constexpr as per LWG 2933. * include/std/type_traits (All variable templates): Add _GLIBCXX17_INLINE as per P0607R0. * include/std/variant (variant_size_v, variant_npos, __index_of_v) (__tuple_count_v, __exactly_once): Likewise. * testsuite/18_support/headers/new/synopsis.cc (hardware_destructive_interference_size) (hardware_constructive_interference_size): Likewise for commented-out variables. * testsuite/20_util/tuple/creation_functions/constexpr.cc: Add new test function for constexpr std::ignore (LWG 2773). * testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc: New test for LWG 2933. From-SVN: r246423
2017-03-23 20:40:07 +01:00
inline constexpr bool uses_allocator_v =
uses_allocator<_Tp, _Alloc>::value;
#endif // C++17
template<template<typename...> class _Predicate,
typename _Tp, typename _Alloc, typename... _Args>
struct __is_uses_allocator_predicate
libstdc++: Add std::__conditional_t alias template This change is inspired by the suggestion in http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1715r0.html The new std::__conditional_t alias template is functionally equivalent to std::conditional_t but should be more efficient to compile, due to only ever instantiating two specializations (std::__conditional<true> and std::__conditional<false>) rather than a new specialization for every use of std::conditional. The new alias template is also available in C++11, unlike the C++14 std::conditional_t alias. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/std/type_traits (__conditional): New class template for internal uses of std::conditional. (__conditional_t): New alias template to replace conditional_t. (__and_, __or_, __result_of_memfun, __result_of_memobj): Use __conditional_t instead of conditional::type. * include/bits/atomic_base.h (__atomic_impl::_Diff): Likewise. * include/bits/hashtable.h (_Hashtable): Likewise. * include/bits/hashtable_policy.h (_Node_iterator, _Insert_base) (_Local_iterator): Likewise. Replace typedefs with using-declarations. * include/bits/move.h (move_if_noexcept): Use __conditional_t. * include/bits/parse_numbers.h (_Select_int_base): Likewise. * include/bits/ptr_traits.h (__make_not_void): Likewise. * include/bits/ranges_algobase.h (__copy_or_move_backward) (__copy_or_move): Likewise. * include/bits/ranges_base.h (borrowed_iterator_t): Likewise. * include/bits/ranges_util.h (borrowed_subrange_t): Likewise. * include/bits/regex_compiler.h (_BracketMatcher): Use __conditional_t. Replace typedefs with using-declarations. * include/bits/shared_ptr_base.h (__shared_count): Use __conditional_t. * include/bits/stl_algobase.h (__copy_move, __copy_move_backward): Likewise. * include/bits/stl_iterator.h (__detail::__clamp_iter_cat) (reverse_iterator::iterator_concept) (__make_move_if_noexcept_iterator) (iterator_traits<common_iterator<_It, _Sent>>) (iterator_traits<counted_iterator<_It>>): Likewise. * include/bits/stl_pair.h (_PCC, pair::operator=): Likewise. * include/bits/stl_tree.h (_Rb_tree::insert_return_type) (_Rb_tree::_M_clone_node): Likewise. * include/bits/unique_ptr.h (unique_ptr(unique_ptr<U,E>&&)): Likewise. * include/bits/uses_allocator.h (__uses_alloc): Likewise. (__is_uses_allocator_predicate): Likewise. * include/debug/functions.h (__foreign_iterator_aux2): Likewise. * include/experimental/any (any::_Manager, __any_caster): Likewise. * include/experimental/executor (async_completion): Likewise. * include/experimental/functional (__boyer_moore_base_t): Likewise. * include/std/any (any::_Manager): Likewise. * include/std/functional (__boyer_moore_base_t): Likewise. * include/std/ranges (borrowed_iterator_t) (borrowed_subrange_t, __detail::__maybe_present_t) (__detail::__maybe_const_t, split_view): Likewise. * include/std/tuple (__empty_not_final, tuple::operator=): Likewise. * include/std/variant (__detail::__variant::__get_t): Likewise.
2021-05-06 17:26:21 +02:00
: __conditional_t<uses_allocator<_Tp, _Alloc>::value,
__or_<_Predicate<_Tp, allocator_arg_t, _Alloc, _Args...>,
_Predicate<_Tp, _Args..., _Alloc>>,
libstdc++: Add std::__conditional_t alias template This change is inspired by the suggestion in http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1715r0.html The new std::__conditional_t alias template is functionally equivalent to std::conditional_t but should be more efficient to compile, due to only ever instantiating two specializations (std::__conditional<true> and std::__conditional<false>) rather than a new specialization for every use of std::conditional. The new alias template is also available in C++11, unlike the C++14 std::conditional_t alias. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/std/type_traits (__conditional): New class template for internal uses of std::conditional. (__conditional_t): New alias template to replace conditional_t. (__and_, __or_, __result_of_memfun, __result_of_memobj): Use __conditional_t instead of conditional::type. * include/bits/atomic_base.h (__atomic_impl::_Diff): Likewise. * include/bits/hashtable.h (_Hashtable): Likewise. * include/bits/hashtable_policy.h (_Node_iterator, _Insert_base) (_Local_iterator): Likewise. Replace typedefs with using-declarations. * include/bits/move.h (move_if_noexcept): Use __conditional_t. * include/bits/parse_numbers.h (_Select_int_base): Likewise. * include/bits/ptr_traits.h (__make_not_void): Likewise. * include/bits/ranges_algobase.h (__copy_or_move_backward) (__copy_or_move): Likewise. * include/bits/ranges_base.h (borrowed_iterator_t): Likewise. * include/bits/ranges_util.h (borrowed_subrange_t): Likewise. * include/bits/regex_compiler.h (_BracketMatcher): Use __conditional_t. Replace typedefs with using-declarations. * include/bits/shared_ptr_base.h (__shared_count): Use __conditional_t. * include/bits/stl_algobase.h (__copy_move, __copy_move_backward): Likewise. * include/bits/stl_iterator.h (__detail::__clamp_iter_cat) (reverse_iterator::iterator_concept) (__make_move_if_noexcept_iterator) (iterator_traits<common_iterator<_It, _Sent>>) (iterator_traits<counted_iterator<_It>>): Likewise. * include/bits/stl_pair.h (_PCC, pair::operator=): Likewise. * include/bits/stl_tree.h (_Rb_tree::insert_return_type) (_Rb_tree::_M_clone_node): Likewise. * include/bits/unique_ptr.h (unique_ptr(unique_ptr<U,E>&&)): Likewise. * include/bits/uses_allocator.h (__uses_alloc): Likewise. (__is_uses_allocator_predicate): Likewise. * include/debug/functions.h (__foreign_iterator_aux2): Likewise. * include/experimental/any (any::_Manager, __any_caster): Likewise. * include/experimental/executor (async_completion): Likewise. * include/experimental/functional (__boyer_moore_base_t): Likewise. * include/std/any (any::_Manager): Likewise. * include/std/functional (__boyer_moore_base_t): Likewise. * include/std/ranges (borrowed_iterator_t) (borrowed_subrange_t, __detail::__maybe_present_t) (__detail::__maybe_const_t, split_view): Likewise. * include/std/tuple (__empty_not_final, tuple::operator=): Likewise. * include/std/variant (__detail::__variant::__get_t): Likewise.
2021-05-06 17:26:21 +02:00
_Predicate<_Tp, _Args...>> { };
template<typename _Tp, typename _Alloc, typename... _Args>
struct __is_uses_allocator_constructible
: __is_uses_allocator_predicate<is_constructible, _Tp, _Alloc, _Args...>
{ };
#if __cplusplus >= 201402L
template<typename _Tp, typename _Alloc, typename... _Args>
Implement P0607R0 "Inline Variables for Standard Library" for C++17 2017-03-23 Daniel Kruegler <daniel.kruegler@gmail.com> * include/bits/c++config (_GLIBCXX17_INLINE): Define. * include/bits/regex_constants.h (All std::regex_constants constants): Add _GLIBCXX17_INLINE as per P0607R0. * include/bits/std_mutex.h (defer_lock, try_to_lock, adopt_lock): Likewise. * include/bits/stl_pair.h (piecewise_construct): Likewise. * include/bits/uses_allocator.h (allocator_arg, uses_allocator_v) (__is_uses_allocator_constructible_v) (__is_nothrow_uses_allocator_constructible_v): Likewise. * include/std/chrono (treat_as_floating_point_v): Likewise. * include/std/functional (is_bind_expression_v, is_placeholder_v): Likewise. * include/std/optional (nullopt): Likewise. * include/std/ratio (ratio_equal_v, ratio_not_equal_v, ratio_less_v) ratio_less_equal_v, ratio_greater_v, ratio_greater_equal_v): Likewise. * include/std/system_error (is_error_code_enum_v) (is_error_condition_enum_v): Likewise. * include/std/tuple (tuple_size_v, ignore): Likewise. (ignore): Declare ignore constexpr as per LWG 2773, declare assignment constexpr as per LWG 2933. * include/std/type_traits (All variable templates): Add _GLIBCXX17_INLINE as per P0607R0. * include/std/variant (variant_size_v, variant_npos, __index_of_v) (__tuple_count_v, __exactly_once): Likewise. * testsuite/18_support/headers/new/synopsis.cc (hardware_destructive_interference_size) (hardware_constructive_interference_size): Likewise for commented-out variables. * testsuite/20_util/tuple/creation_functions/constexpr.cc: Add new test function for constexpr std::ignore (LWG 2773). * testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc: New test for LWG 2933. From-SVN: r246423
2017-03-23 20:40:07 +01:00
_GLIBCXX17_INLINE constexpr bool __is_uses_allocator_constructible_v =
__is_uses_allocator_constructible<_Tp, _Alloc, _Args...>::value;
#endif // C++14
template<typename _Tp, typename _Alloc, typename... _Args>
struct __is_nothrow_uses_allocator_constructible
: __is_uses_allocator_predicate<is_nothrow_constructible,
_Tp, _Alloc, _Args...>
{ };
#if __cplusplus >= 201402L
template<typename _Tp, typename _Alloc, typename... _Args>
Implement P0607R0 "Inline Variables for Standard Library" for C++17 2017-03-23 Daniel Kruegler <daniel.kruegler@gmail.com> * include/bits/c++config (_GLIBCXX17_INLINE): Define. * include/bits/regex_constants.h (All std::regex_constants constants): Add _GLIBCXX17_INLINE as per P0607R0. * include/bits/std_mutex.h (defer_lock, try_to_lock, adopt_lock): Likewise. * include/bits/stl_pair.h (piecewise_construct): Likewise. * include/bits/uses_allocator.h (allocator_arg, uses_allocator_v) (__is_uses_allocator_constructible_v) (__is_nothrow_uses_allocator_constructible_v): Likewise. * include/std/chrono (treat_as_floating_point_v): Likewise. * include/std/functional (is_bind_expression_v, is_placeholder_v): Likewise. * include/std/optional (nullopt): Likewise. * include/std/ratio (ratio_equal_v, ratio_not_equal_v, ratio_less_v) ratio_less_equal_v, ratio_greater_v, ratio_greater_equal_v): Likewise. * include/std/system_error (is_error_code_enum_v) (is_error_condition_enum_v): Likewise. * include/std/tuple (tuple_size_v, ignore): Likewise. (ignore): Declare ignore constexpr as per LWG 2773, declare assignment constexpr as per LWG 2933. * include/std/type_traits (All variable templates): Add _GLIBCXX17_INLINE as per P0607R0. * include/std/variant (variant_size_v, variant_npos, __index_of_v) (__tuple_count_v, __exactly_once): Likewise. * testsuite/18_support/headers/new/synopsis.cc (hardware_destructive_interference_size) (hardware_constructive_interference_size): Likewise for commented-out variables. * testsuite/20_util/tuple/creation_functions/constexpr.cc: Add new test function for constexpr std::ignore (LWG 2773). * testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc: New test for LWG 2933. From-SVN: r246423
2017-03-23 20:40:07 +01:00
_GLIBCXX17_INLINE constexpr bool
__is_nothrow_uses_allocator_constructible_v =
__is_nothrow_uses_allocator_constructible<_Tp, _Alloc, _Args...>::value;
#endif // C++14
template<typename _Tp, typename... _Args>
void __uses_allocator_construct_impl(__uses_alloc0 __a, _Tp* __ptr,
_Args&&... __args)
{ ::new ((void*)__ptr) _Tp(std::forward<_Args>(__args)...); }
template<typename _Tp, typename _Alloc, typename... _Args>
void __uses_allocator_construct_impl(__uses_alloc1<_Alloc> __a, _Tp* __ptr,
_Args&&... __args)
{
::new ((void*)__ptr) _Tp(allocator_arg, *__a._M_a,
std::forward<_Args>(__args)...);
}
template<typename _Tp, typename _Alloc, typename... _Args>
void __uses_allocator_construct_impl(__uses_alloc2<_Alloc> __a, _Tp* __ptr,
_Args&&... __args)
{ ::new ((void*)__ptr) _Tp(std::forward<_Args>(__args)..., *__a._M_a); }
template<typename _Tp, typename _Alloc, typename... _Args>
void __uses_allocator_construct(const _Alloc& __a, _Tp* __ptr,
_Args&&... __args)
{
std::__uses_allocator_construct_impl(
std::__use_alloc<_Tp, _Alloc, _Args...>(__a), __ptr,
std::forward<_Args>(__args)...);
}
/// @endcond
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif
#endif