Commit 3d7beb79 by Jonathan Wakely Committed by Jonathan Wakely

PR libstdc++/89416 fix alloc insertable trait for clang (again)

	PR libstdc++/89416
	* include/bits/alloc_traits.h (__is_alloc_insertable_impl): Change
	to class template and partial specialization using void_t.
	(__is_copy_insertable, __is_move_insertable): Adjust base class.

From-SVN: r269229
parent ec2d749a
2019-02-26 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/89416
* include/bits/alloc_traits.h (__is_alloc_insertable_impl): Change
to class template and partial specialization using void_t.
(__is_copy_insertable, __is_move_insertable): Adjust base class.
2019-02-24 Jonathan Wakely <jwakely@redhat.com> 2019-02-24 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/89416 PR libstdc++/89416
......
...@@ -576,32 +576,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -576,32 +576,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__do_alloc_on_swap(__one, __two, __pocs()); __do_alloc_on_swap(__one, __two, __pocs());
} }
class __is_alloc_insertable_impl template<typename _Alloc, typename _Tp,
{ typename _ValueT = __remove_cvref_t<typename _Alloc::value_type>,
template<typename _Alloc, typename _Up, typename = void>
typename _Tp = __remove_cvref_t<_Up>, struct __is_alloc_insertable_impl
typename = decltype(allocator_traits<_Alloc>::construct( : false_type
std::declval<_Alloc&>(), std::declval<_Tp*>(), { };
std::declval<_Up>()))>
static true_type template<typename _Alloc, typename _Tp, typename _ValueT>
_M_select(int); struct __is_alloc_insertable_impl<_Alloc, _Tp, _ValueT,
__void_t<decltype(allocator_traits<_Alloc>::construct(
template<typename, typename> std::declval<_Alloc&>(), std::declval<_ValueT*>(),
static false_type std::declval<_Tp>()))>>
_M_select(...); : true_type
{ };
public:
template<typename _Alloc, typename _Tp = typename _Alloc::value_type>
using copy = decltype(_M_select<_Alloc, const _Tp&>(0));
template<typename _Alloc, typename _Tp = typename _Alloc::value_type>
using move = decltype(_M_select<_Alloc, _Tp>(0));
};
// true if _Alloc::value_type is CopyInsertable into containers using _Alloc // true if _Alloc::value_type is CopyInsertable into containers using _Alloc
// (might be wrong if _Alloc::construct exists but is not constrained,
// i.e. actually trying to use it would still be invalid. Use with caution.)
template<typename _Alloc> template<typename _Alloc>
struct __is_copy_insertable struct __is_copy_insertable
: __is_alloc_insertable_impl::template copy<_Alloc> : __is_alloc_insertable_impl<_Alloc,
typename _Alloc::value_type const&>::type
{ }; { };
// std::allocator<_Tp> just requires CopyConstructible // std::allocator<_Tp> just requires CopyConstructible
...@@ -611,9 +607,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -611,9 +607,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ }; { };
// true if _Alloc::value_type is MoveInsertable into containers using _Alloc // true if _Alloc::value_type is MoveInsertable into containers using _Alloc
// (might be wrong if _Alloc::construct exists but is not constrained,
// i.e. actually trying to use it would still be invalid. Use with caution.)
template<typename _Alloc> template<typename _Alloc>
struct __is_move_insertable struct __is_move_insertable
: __is_alloc_insertable_impl::template move<_Alloc> : __is_alloc_insertable_impl<_Alloc, typename _Alloc::value_type>::type
{ }; { };
// std::allocator<_Tp> just requires MoveConstructible // std::allocator<_Tp> just requires MoveConstructible
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment