From 3d7beb79e0631c7ca8532c497295af03822eeed2 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 26 Feb 2019 20:34:46 +0000 Subject: [PATCH] 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 --- libstdc++-v3/ChangeLog | 7 ++++ libstdc++-v3/include/bits/alloc_traits.h | 44 +++++++++++------------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1ace579e625..d6ae3226eff 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2019-02-26 Jonathan Wakely + + 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 PR libstdc++/89416 diff --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/include/bits/alloc_traits.h index 9a3d816c42c..b8689daf74b 100644 --- a/libstdc++-v3/include/bits/alloc_traits.h +++ b/libstdc++-v3/include/bits/alloc_traits.h @@ -576,32 +576,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __do_alloc_on_swap(__one, __two, __pocs()); } - class __is_alloc_insertable_impl - { - template, - typename = decltype(allocator_traits<_Alloc>::construct( - std::declval<_Alloc&>(), std::declval<_Tp*>(), - std::declval<_Up>()))> - static true_type - _M_select(int); - - template - static false_type - _M_select(...); - - public: - template - using copy = decltype(_M_select<_Alloc, const _Tp&>(0)); - - template - using move = decltype(_M_select<_Alloc, _Tp>(0)); - }; + template, + typename = void> + struct __is_alloc_insertable_impl + : false_type + { }; + + template + struct __is_alloc_insertable_impl<_Alloc, _Tp, _ValueT, + __void_t::construct( + std::declval<_Alloc&>(), std::declval<_ValueT*>(), + std::declval<_Tp>()))>> + : true_type + { }; // 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 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 @@ -611,9 +607,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; // 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 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 -- 2.30.2