2011-05-30 18:31:17 +02:00
|
|
|
// Uses-allocator Construction -*- C++ -*-
|
|
|
|
|
2022-01-03 10:42:10 +01:00
|
|
|
// Copyright (C) 2010-2022 Free Software Foundation, Inc.
|
2011-05-30 18:31:17 +02:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
|
2012-11-10 18:27:22 +01:00
|
|
|
#if __cplusplus < 201103L
|
2011-05-30 18:31:17 +02:00
|
|
|
# include <bits/c++0x_warning.h>
|
|
|
|
#else
|
|
|
|
|
|
|
|
#include <type_traits>
|
2016-01-08 14:14:01 +01:00
|
|
|
#include <bits/move.h>
|
2011-05-30 18:31:17 +02:00
|
|
|
|
|
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
|
|
{
|
|
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
2021-10-21 18:43:34 +02:00
|
|
|
/// @cond undocumented
|
2011-05-30 18:31:17 +02:00
|
|
|
|
2018-07-24 15:03:25 +02:00
|
|
|
// This is used for std::experimental::erased_type from Library Fundamentals.
|
2015-11-13 11:00:59 +01:00
|
|
|
struct __erased_type { };
|
|
|
|
|
2018-07-24 15:03:25 +02:00
|
|
|
// 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.
|
2015-11-13 11:00:59 +01:00
|
|
|
template<typename _Alloc, typename _Tp>
|
|
|
|
using __is_erased_or_convertible
|
2018-07-24 15:03:25 +02:00
|
|
|
= __or_<is_convertible<_Alloc, _Tp>, is_same<_Tp, __erased_type>>;
|
2015-11-13 11:00:59 +01:00
|
|
|
|
2011-05-30 18:31:17 +02:00
|
|
|
/// [allocator.tag]
|
2015-11-11 15:47:19 +01:00
|
|
|
struct allocator_arg_t { explicit allocator_arg_t() = default; };
|
2011-05-30 18:31:17 +02:00
|
|
|
|
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();
|
2011-05-30 18:31:17 +02:00
|
|
|
|
2014-11-12 00:57:35 +01:00
|
|
|
template<typename _Tp, typename _Alloc, typename = __void_t<>>
|
2011-05-30 18:31:17 +02:00
|
|
|
struct __uses_allocator_helper
|
2014-06-02 00:35:42 +02:00
|
|
|
: false_type { };
|
2011-05-30 18:31:17 +02:00
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc>
|
2014-11-12 00:57:35 +01:00
|
|
|
struct __uses_allocator_helper<_Tp, _Alloc,
|
|
|
|
__void_t<typename _Tp::allocator_type>>
|
2015-11-13 11:00:59 +01:00
|
|
|
: __is_erased_or_convertible<_Alloc, typename _Tp::allocator_type>::type
|
2011-05-30 18:31:17 +02:00
|
|
|
{ };
|
|
|
|
|
|
|
|
/// [allocator.uses.trait]
|
|
|
|
template<typename _Tp, typename _Alloc>
|
|
|
|
struct uses_allocator
|
2014-06-02 00:35:42 +02:00
|
|
|
: __uses_allocator_helper<_Tp, _Alloc>::type
|
2011-05-30 18:31:17 +02:00
|
|
|
{ };
|
|
|
|
|
|
|
|
struct __uses_alloc_base { };
|
2014-06-02 00:35:42 +02:00
|
|
|
|
2011-05-30 18:31:17 +02:00
|
|
|
struct __uses_alloc0 : __uses_alloc_base
|
2014-06-02 00:35:42 +02:00
|
|
|
{
|
2019-11-17 04:31:15 +01:00
|
|
|
struct _Sink { void _GLIBCXX20_CONSTEXPR operator=(const void*) { } } _M_a;
|
2014-06-02 00:35:42 +02:00
|
|
|
};
|
|
|
|
|
2011-05-30 18:31:17 +02:00
|
|
|
template<typename _Alloc>
|
|
|
|
struct __uses_alloc1 : __uses_alloc_base { const _Alloc* _M_a; };
|
2014-06-02 00:35:42 +02:00
|
|
|
|
2011-05-30 18:31:17 +02:00
|
|
|
template<typename _Alloc>
|
|
|
|
struct __uses_alloc2 : __uses_alloc_base { const _Alloc* _M_a; };
|
|
|
|
|
2014-06-02 00:35:42 +02:00
|
|
|
template<bool, typename _Tp, typename _Alloc, typename... _Args>
|
2011-05-30 18:31:17 +02:00
|
|
|
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<
|
2019-02-14 16:08:33 +01:00
|
|
|
is_constructible<_Tp, allocator_arg_t, const _Alloc&, _Args...>::value,
|
2011-05-30 18:31:17 +02:00
|
|
|
__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>>
|
2016-01-16 00:12:13 +01:00
|
|
|
{
|
2019-02-14 16:08:33 +01:00
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
|
|
// 2586. Wrong value category used in scoped_allocator_adaptor::construct
|
2016-01-16 00:12:13 +01:00
|
|
|
static_assert(__or_<
|
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");
|
2016-01-16 00:12:13 +01:00
|
|
|
};
|
2011-05-30 18:31:17 +02:00
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc, typename... _Args>
|
|
|
|
struct __uses_alloc<false, _Tp, _Alloc, _Args...>
|
|
|
|
: __uses_alloc0 { };
|
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc, typename... _Args>
|
2014-06-02 00:35:42 +02:00
|
|
|
using __uses_alloc_t =
|
|
|
|
__uses_alloc<uses_allocator<_Tp, _Alloc>::value, _Tp, _Alloc, _Args...>;
|
2011-05-30 18:31:17 +02:00
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc, typename... _Args>
|
2019-11-17 04:31:15 +01:00
|
|
|
_GLIBCXX20_CONSTEXPR
|
2014-06-02 00:35:42 +02:00
|
|
|
inline __uses_alloc_t<_Tp, _Alloc, _Args...>
|
2011-05-30 18:31:17 +02:00
|
|
|
__use_alloc(const _Alloc& __a)
|
|
|
|
{
|
2014-06-02 00:35:42 +02:00
|
|
|
__uses_alloc_t<_Tp, _Alloc, _Args...> __ret;
|
2016-01-07 16:01:33 +01:00
|
|
|
__ret._M_a = std::__addressof(__a);
|
2011-05-30 18:31:17 +02:00
|
|
|
return __ret;
|
|
|
|
}
|
2017-07-06 13:54:10 +02:00
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc, typename... _Args>
|
|
|
|
void
|
|
|
|
__use_alloc(const _Alloc&&) = delete;
|
|
|
|
|
2016-07-31 16:52:53 +02:00
|
|
|
#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;
|
2016-07-31 16:52:53 +02:00
|
|
|
#endif // C++17
|
2011-05-30 18:31:17 +02:00
|
|
|
|
2016-08-18 22:31:26 +02:00
|
|
|
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,
|
2016-08-18 22:31:26 +02:00
|
|
|
__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...>> { };
|
2016-08-18 22:31:26 +02:00
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc, typename... _Args>
|
|
|
|
struct __is_uses_allocator_constructible
|
|
|
|
: __is_uses_allocator_predicate<is_constructible, _Tp, _Alloc, _Args...>
|
|
|
|
{ };
|
|
|
|
|
2016-10-18 13:42:18 +02:00
|
|
|
#if __cplusplus >= 201402L
|
2016-08-18 22:31:26 +02:00
|
|
|
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 =
|
2016-08-18 22:31:26 +02:00
|
|
|
__is_uses_allocator_constructible<_Tp, _Alloc, _Args...>::value;
|
2016-10-18 13:42:18 +02:00
|
|
|
#endif // C++14
|
2016-08-18 22:31:26 +02:00
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc, typename... _Args>
|
|
|
|
struct __is_nothrow_uses_allocator_constructible
|
|
|
|
: __is_uses_allocator_predicate<is_nothrow_constructible,
|
|
|
|
_Tp, _Alloc, _Args...>
|
|
|
|
{ };
|
|
|
|
|
|
|
|
|
2016-10-18 13:42:18 +02:00
|
|
|
#if __cplusplus >= 201402L
|
2016-08-18 22:31:26 +02:00
|
|
|
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 =
|
2016-08-18 22:31:26 +02:00
|
|
|
__is_nothrow_uses_allocator_constructible<_Tp, _Alloc, _Args...>::value;
|
2016-10-18 13:42:18 +02:00
|
|
|
#endif // C++14
|
2016-08-18 22:31:26 +02:00
|
|
|
|
|
|
|
template<typename _Tp, typename... _Args>
|
|
|
|
void __uses_allocator_construct_impl(__uses_alloc0 __a, _Tp* __ptr,
|
|
|
|
_Args&&... __args)
|
2016-09-22 11:56:54 +02:00
|
|
|
{ ::new ((void*)__ptr) _Tp(std::forward<_Args>(__args)...); }
|
2016-08-18 22:31:26 +02:00
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc, typename... _Args>
|
|
|
|
void __uses_allocator_construct_impl(__uses_alloc1<_Alloc> __a, _Tp* __ptr,
|
|
|
|
_Args&&... __args)
|
2016-09-22 11:56:54 +02:00
|
|
|
{
|
|
|
|
::new ((void*)__ptr) _Tp(allocator_arg, *__a._M_a,
|
|
|
|
std::forward<_Args>(__args)...);
|
|
|
|
}
|
2016-08-18 22:31:26 +02:00
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc, typename... _Args>
|
|
|
|
void __uses_allocator_construct_impl(__uses_alloc2<_Alloc> __a, _Tp* __ptr,
|
|
|
|
_Args&&... __args)
|
2016-09-22 11:56:54 +02:00
|
|
|
{ ::new ((void*)__ptr) _Tp(std::forward<_Args>(__args)..., *__a._M_a); }
|
2016-08-18 22:31:26 +02:00
|
|
|
|
|
|
|
template<typename _Tp, typename _Alloc, typename... _Args>
|
|
|
|
void __uses_allocator_construct(const _Alloc& __a, _Tp* __ptr,
|
|
|
|
_Args&&... __args)
|
|
|
|
{
|
2018-08-15 21:20:02 +02:00
|
|
|
std::__uses_allocator_construct_impl(
|
|
|
|
std::__use_alloc<_Tp, _Alloc, _Args...>(__a), __ptr,
|
|
|
|
std::forward<_Args>(__args)...);
|
2016-08-18 22:31:26 +02:00
|
|
|
}
|
|
|
|
|
2021-10-21 18:43:34 +02:00
|
|
|
/// @endcond
|
2011-05-30 18:31:17 +02:00
|
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
|
|
|
} // namespace std
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|