diff --git a/libcxx/include/deque b/libcxx/include/deque --- a/libcxx/include/deque +++ b/libcxx/include/deque @@ -1315,7 +1315,7 @@ deque(_InputIter __f, _InputIter __l, const allocator_type& __a, typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type* = 0); deque(const deque& __c); - deque(const deque& __c, const allocator_type& __a); + deque(const deque& __c, const __identity_t& __a); deque& operator=(const deque& __c); @@ -1329,7 +1329,7 @@ _LIBCPP_INLINE_VISIBILITY deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value); _LIBCPP_INLINE_VISIBILITY - deque(deque&& __c, const allocator_type& __a); + deque(deque&& __c, const __identity_t& __a); _LIBCPP_INLINE_VISIBILITY deque& operator=(deque&& __c) _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value && @@ -1586,18 +1586,18 @@ #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES template::value_type>, - class = typename enable_if<__is_allocator<_Alloc>::value, void>::type + class _Alloc = allocator<__iter_value_type<_InputIterator>>, + class = _EnableIf<__is_allocator<_Alloc>::value> > deque(_InputIterator, _InputIterator) - -> deque::value_type, _Alloc>; + -> deque<__iter_value_type<_InputIterator>, _Alloc>; template::value, void>::type + class = _EnableIf<__is_allocator<_Alloc>::value> > deque(_InputIterator, _InputIterator, _Alloc) - -> deque::value_type, _Alloc>; + -> deque<__iter_value_type<_InputIterator>, _Alloc>; #endif @@ -1658,7 +1658,7 @@ } template -deque<_Tp, _Allocator>::deque(const deque& __c, const allocator_type& __a) +deque<_Tp, _Allocator>::deque(const deque& __c, const __identity_t& __a) : __base(__a) { __append(__c.begin(), __c.end()); @@ -1701,7 +1701,7 @@ template inline -deque<_Tp, _Allocator>::deque(deque&& __c, const allocator_type& __a) +deque<_Tp, _Allocator>::deque(deque&& __c, const __identity_t& __a) : __base(_VSTD::move(__c), __a) { if (__a != __c.__alloc()) diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list --- a/libcxx/include/forward_list +++ b/libcxx/include/forward_list @@ -681,7 +681,7 @@ __is_cpp17_input_iterator<_InputIterator>::value >::type* = nullptr); forward_list(const forward_list& __x); - forward_list(const forward_list& __x, const allocator_type& __a); + forward_list(const forward_list& __x, const __identity_t& __a); forward_list& operator=(const forward_list& __x); @@ -690,7 +690,7 @@ forward_list(forward_list&& __x) _NOEXCEPT_(is_nothrow_move_constructible::value) : base(_VSTD::move(__x)) {} - forward_list(forward_list&& __x, const allocator_type& __a); + forward_list(forward_list&& __x, const __identity_t& __a); forward_list(initializer_list __il); forward_list(initializer_list __il, const allocator_type& __a); @@ -871,18 +871,18 @@ #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES template::value_type>, - class = typename enable_if<__is_allocator<_Alloc>::value, void>::type + class _Alloc = allocator<__iter_value_type<_InputIterator>>, + class = _EnableIf<__is_allocator<_Alloc>::value> > forward_list(_InputIterator, _InputIterator) - -> forward_list::value_type, _Alloc>; + -> forward_list<__iter_value_type<_InputIterator>, _Alloc>; template::value, void>::type + class = _EnableIf<__is_allocator<_Alloc>::value> > forward_list(_InputIterator, _InputIterator, _Alloc) - -> forward_list::value_type, _Alloc>; + -> forward_list<__iter_value_type<_InputIterator>, _Alloc>; #endif template @@ -979,7 +979,7 @@ template forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x, - const allocator_type& __a) + const __identity_t& __a) : base(__a) { insert_after(cbefore_begin(), __x.begin(), __x.end()); @@ -1000,7 +1000,7 @@ #ifndef _LIBCPP_CXX03_LANG template forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x, - const allocator_type& __a) + const __identity_t& __a) : base(_VSTD::move(__x), __a) { if (base::__alloc() != __x.__alloc()) diff --git a/libcxx/include/list b/libcxx/include/list --- a/libcxx/include/list +++ b/libcxx/include/list @@ -895,7 +895,7 @@ typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0); list(const list& __c); - list(const list& __c, const allocator_type& __a); + list(const list& __c, const __identity_t& __a); _LIBCPP_INLINE_VISIBILITY list& operator=(const list& __c); #ifndef _LIBCPP_CXX03_LANG @@ -906,7 +906,7 @@ list(list&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value); _LIBCPP_INLINE_VISIBILITY - list(list&& __c, const allocator_type& __a); + list(list&& __c, const __identity_t& __a); _LIBCPP_INLINE_VISIBILITY list& operator=(list&& __c) _NOEXCEPT_( @@ -1144,18 +1144,18 @@ #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES template::value_type>, - class = typename enable_if<__is_allocator<_Alloc>::value, void>::type + class _Alloc = allocator<__iter_value_type<_InputIterator>>, + class = _EnableIf<__is_allocator<_Alloc>::value> > list(_InputIterator, _InputIterator) - -> list::value_type, _Alloc>; + -> list<__iter_value_type<_InputIterator>, _Alloc>; template::value, void>::type + class = _EnableIf<__is_allocator<_Alloc>::value> > list(_InputIterator, _InputIterator, _Alloc) - -> list::value_type, _Alloc>; + -> list<__iter_value_type<_InputIterator>, _Alloc>; #endif // Link in nodes [__f, __l] just prior to __p @@ -1288,7 +1288,7 @@ } template -list<_Tp, _Alloc>::list(const list& __c, const allocator_type& __a) +list<_Tp, _Alloc>::list(const list& __c, const __identity_t& __a) : base(__a) { #if _LIBCPP_DEBUG_LEVEL == 2 @@ -1335,7 +1335,7 @@ template inline -list<_Tp, _Alloc>::list(list&& __c, const allocator_type& __a) +list<_Tp, _Alloc>::list(list&& __c, const __identity_t& __a) : base(__a) { #if _LIBCPP_DEBUG_LEVEL == 2 diff --git a/libcxx/include/queue b/libcxx/include/queue --- a/libcxx/include/queue +++ b/libcxx/include/queue @@ -249,33 +249,28 @@ template _LIBCPP_INLINE_VISIBILITY explicit queue(const _Alloc& __a, - typename enable_if::value>::type* = 0) + _EnableIf::value>* = 0) : c(__a) {} template _LIBCPP_INLINE_VISIBILITY queue(const queue& __q, const _Alloc& __a, - typename enable_if::value>::type* = 0) + _EnableIf::value>* = 0) : c(__q.c, __a) {} template _LIBCPP_INLINE_VISIBILITY queue(const container_type& __c, const _Alloc& __a, - typename enable_if::value>::type* = 0) + _EnableIf::value>* = 0) : c(__c, __a) {} #ifndef _LIBCPP_CXX03_LANG template _LIBCPP_INLINE_VISIBILITY queue(container_type&& __c, const _Alloc& __a, - typename enable_if::value>::type* = 0) + _EnableIf::value>* = 0) : c(_VSTD::move(__c), __a) {} template _LIBCPP_INLINE_VISIBILITY queue(queue&& __q, const _Alloc& __a, - typename enable_if::value>::type* = 0) + _EnableIf::value>* = 0) : c(_VSTD::move(__q.c), __a) {} #endif // _LIBCPP_CXX03_LANG @@ -335,15 +330,15 @@ #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES template::value, nullptr_t>::type + class = _EnableIf::value> > queue(_Container) -> queue; template::value, nullptr_t>::type, - class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type + class = _EnableIf::value>, + class = _EnableIf::value> > queue(_Container, _Alloc) -> queue; @@ -399,10 +394,7 @@ template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if< - __is_swappable<_Container>::value, - void ->::type +_EnableIf<__is_swappable<_Container>::value, void> swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { @@ -486,36 +478,30 @@ template _LIBCPP_INLINE_VISIBILITY explicit priority_queue(const _Alloc& __a, - typename enable_if::value>::type* = 0); + _EnableIf::value>* = 0); template _LIBCPP_INLINE_VISIBILITY priority_queue(const value_compare& __comp, const _Alloc& __a, - typename enable_if::value>::type* = 0); + _EnableIf::value>* = 0); template _LIBCPP_INLINE_VISIBILITY priority_queue(const value_compare& __comp, const container_type& __c, const _Alloc& __a, - typename enable_if::value>::type* = 0); + _EnableIf::value>* = 0); template _LIBCPP_INLINE_VISIBILITY priority_queue(const priority_queue& __q, const _Alloc& __a, - typename enable_if::value>::type* = 0); + _EnableIf::value>* = 0); #ifndef _LIBCPP_CXX03_LANG template _LIBCPP_INLINE_VISIBILITY priority_queue(const value_compare& __comp, container_type&& __c, const _Alloc& __a, - typename enable_if::value>::type* = 0); + _EnableIf::value>* = 0); template _LIBCPP_INLINE_VISIBILITY priority_queue(priority_queue&& __q, const _Alloc& __a, - typename enable_if::value>::type* = 0); + _EnableIf::value>* = 0); #endif // _LIBCPP_CXX03_LANG _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY @@ -546,28 +532,28 @@ #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES template ::value, nullptr_t>::type, - class = typename enable_if::value, nullptr_t>::type + class = _EnableIf::value>, + class = _EnableIf::value> > priority_queue(_Compare, _Container) -> priority_queue; template::value_type>, - class _Container = vector::value_type>, - class = typename enable_if< __is_cpp17_input_iterator<_InputIterator>::value, nullptr_t>::type, - class = typename enable_if::value, nullptr_t>::type, - class = typename enable_if::value, nullptr_t>::type + class _Compare = less<__iter_value_type<_InputIterator>>, + class _Container = vector<__iter_value_type<_InputIterator>>, + class = _EnableIf<__is_cpp17_input_iterator<_InputIterator>::value>, + class = _EnableIf::value>, + class = _EnableIf::value> > priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container()) - -> priority_queue::value_type, _Container, _Compare>; + -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>; template::value, nullptr_t>::type, - class = typename enable_if::value, nullptr_t>::type, - class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type + class = _EnableIf::value>, + class = _EnableIf::value>, + class = _EnableIf::value> > priority_queue(_Compare, _Container, _Alloc) -> priority_queue; @@ -642,8 +628,7 @@ template inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a, - typename enable_if::value>::type*) + _EnableIf::value>*) : c(__a) { } @@ -653,8 +638,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, const _Alloc& __a, - typename enable_if::value>::type*) + _EnableIf::value>*) : c(__a), comp(__comp) { @@ -666,8 +650,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, const container_type& __c, const _Alloc& __a, - typename enable_if::value>::type*) + _EnableIf::value>*) : c(__c, __a), comp(__comp) { @@ -679,8 +662,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, const _Alloc& __a, - typename enable_if::value>::type*) + _EnableIf::value>*) : c(__q.c, __a), comp(__q.comp) { @@ -695,8 +677,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, container_type&& __c, const _Alloc& __a, - typename enable_if::value>::type*) + _EnableIf::value>*) : c(_VSTD::move(__c), __a), comp(__comp) { @@ -708,8 +689,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, const _Alloc& __a, - typename enable_if::value>::type*) + _EnableIf::value>*) : c(_VSTD::move(__q.c), __a), comp(_VSTD::move(__q.comp)) { @@ -773,11 +753,10 @@ template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if< - __is_swappable<_Container>::value - && __is_swappable<_Compare>::value, +_EnableIf< + __is_swappable<_Container>::value && __is_swappable<_Compare>::value, void ->::type +> swap(priority_queue<_Tp, _Container, _Compare>& __x, priority_queue<_Tp, _Container, _Compare>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) diff --git a/libcxx/include/set b/libcxx/include/set --- a/libcxx/include/set +++ b/libcxx/include/set @@ -852,12 +852,12 @@ #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES template::value_type>, - class _Allocator = allocator::value_type>, + class _Compare = less<__iter_value_type<_InputIterator>>, + class _Allocator = allocator<__iter_value_type<_InputIterator>>, class = _EnableIf<__is_allocator<_Allocator>::value, void>, class = _EnableIf::value, void>> set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) - -> set::value_type, _Compare, _Allocator>; + -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>; template, class _Allocator = allocator<_Key>, @@ -869,8 +869,8 @@ template::value, void>> set(_InputIterator, _InputIterator, _Allocator) - -> set::value_type, - less::value_type>, _Allocator>; + -> set<__iter_value_type<_InputIterator>, + less<__iter_value_type<_InputIterator>>, _Allocator>; template::value, void>> @@ -1379,12 +1379,12 @@ #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES template::value_type>, - class _Allocator = allocator::value_type>, + class _Compare = less<__iter_value_type<_InputIterator>>, + class _Allocator = allocator<__iter_value_type<_InputIterator>>, class = _EnableIf<__is_allocator<_Allocator>::value, void>, class = _EnableIf::value, void>> multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) - -> multiset::value_type, _Compare, _Allocator>; + -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>; template, class _Allocator = allocator<_Key>, @@ -1396,8 +1396,8 @@ template::value, void>> multiset(_InputIterator, _InputIterator, _Allocator) - -> multiset::value_type, - less::value_type>, _Allocator>; + -> multiset<__iter_value_type<_InputIterator>, + less<__iter_value_type<_InputIterator>>, _Allocator>; template::value, void>> diff --git a/libcxx/include/stack b/libcxx/include/stack --- a/libcxx/include/stack +++ b/libcxx/include/stack @@ -156,33 +156,28 @@ template _LIBCPP_INLINE_VISIBILITY explicit stack(const _Alloc& __a, - typename enable_if::value>::type* = 0) + _EnableIf::value>* = 0) : c(__a) {} template _LIBCPP_INLINE_VISIBILITY stack(const container_type& __c, const _Alloc& __a, - typename enable_if::value>::type* = 0) + _EnableIf::value>* = 0) : c(__c, __a) {} template _LIBCPP_INLINE_VISIBILITY stack(const stack& __s, const _Alloc& __a, - typename enable_if::value>::type* = 0) + _EnableIf::value>* = 0) : c(__s.c, __a) {} #ifndef _LIBCPP_CXX03_LANG template _LIBCPP_INLINE_VISIBILITY stack(container_type&& __c, const _Alloc& __a, - typename enable_if::value>::type* = 0) + _EnableIf::value>* = 0) : c(_VSTD::move(__c), __a) {} template _LIBCPP_INLINE_VISIBILITY stack(stack&& __s, const _Alloc& __a, - typename enable_if::value>::type* = 0) + _EnableIf::value>* = 0) : c(_VSTD::move(__s.c), __a) {} #endif // _LIBCPP_CXX03_LANG @@ -236,15 +231,15 @@ #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES template::value, nullptr_t>::type + class = _EnableIf::value> > stack(_Container) -> stack; template::value, nullptr_t>::type, - class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type + class = _EnableIf::value>, + class = _EnableIf::value> > stack(_Container, _Alloc) -> stack; @@ -300,10 +295,7 @@ template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if< - __is_swappable<_Container>::value, - void ->::type +_EnableIf<__is_swappable<_Container>::value, void> swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { diff --git a/libcxx/include/string b/libcxx/include/string --- a/libcxx/include/string +++ b/libcxx/include/string @@ -1734,7 +1734,7 @@ #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES template::value_type, + class _CharT = __iter_value_type<_InputIterator>, class _Allocator = allocator<_CharT>, class = _EnableIf<__is_cpp17_input_iterator<_InputIterator>::value>, class = _EnableIf<__is_allocator<_Allocator>::value> diff --git a/libcxx/include/vector b/libcxx/include/vector --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -557,7 +557,7 @@ } vector(const vector& __x); - vector(const vector& __x, const allocator_type& __a); + vector(const vector& __x, const __identity_t& __a); _LIBCPP_INLINE_VISIBILITY vector& operator=(const vector& __x); @@ -577,7 +577,7 @@ #endif _LIBCPP_INLINE_VISIBILITY - vector(vector&& __x, const allocator_type& __a); + vector(vector&& __x, const __identity_t& __a); _LIBCPP_INLINE_VISIBILITY vector& operator=(vector&& __x) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); @@ -931,18 +931,18 @@ #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES template::value_type>, - class = typename enable_if<__is_allocator<_Alloc>::value, void>::type + class _Alloc = allocator<__iter_value_type<_InputIterator>>, + class = _EnableIf<__is_allocator<_Alloc>::value> > vector(_InputIterator, _InputIterator) - -> vector::value_type, _Alloc>; + -> vector<__iter_value_type<_InputIterator>, _Alloc>; template::value, void>::type + class = _EnableIf<__is_allocator<_Alloc>::value> > vector(_InputIterator, _InputIterator, _Alloc) - -> vector::value_type, _Alloc>; + -> vector<__iter_value_type<_InputIterator>, _Alloc>; #endif template @@ -1261,7 +1261,7 @@ } template -vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a) +vector<_Tp, _Allocator>::vector(const vector& __x, const __identity_t& __a) : __base(__a) { #if _LIBCPP_DEBUG_LEVEL == 2 @@ -1299,7 +1299,7 @@ template inline _LIBCPP_INLINE_VISIBILITY -vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a) +vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t& __a) : __base(__a) { #if _LIBCPP_DEBUG_LEVEL == 2 @@ -2261,7 +2261,7 @@ #else _NOEXCEPT_(is_nothrow_move_constructible::value); #endif - vector(vector&& __v, const allocator_type& __a); + vector(vector&& __v, const __identity_t& __a); _LIBCPP_INLINE_VISIBILITY vector& operator=(vector&& __v) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); @@ -2887,7 +2887,7 @@ } template -vector::vector(vector&& __v, const allocator_type& __a) +vector::vector(vector&& __v, const __identity_t& __a) : __begin_(nullptr), __size_(0), __cap_alloc_(0, __a) diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/deduct.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/deduct.pass.cpp --- a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/deduct.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/deduct.pass.cpp @@ -104,21 +104,76 @@ } { -// This one is odd - you can pass an allocator in to use, but the allocator -// has to match the type of the one used by the underlying container - typedef long double T; - typedef std::greater Comp; - typedef test_allocator Alloc; - typedef std::deque Cont; - - Cont c{2,3,0,1}; - std::priority_queue source(Comp(), c); - std::priority_queue pri(source, Alloc(2)); // queue(queue &, allocator) - static_assert(std::is_same_v, ""); - static_assert(std::is_same_v, ""); - assert(pri.size() == 4); - assert(pri.top() == 0); + typedef short T; + typedef std::greater Comp; + typedef test_allocator Alloc; + typedef std::deque Cont; + typedef test_allocator ConvertibleToAlloc; + static_assert(std::uses_allocator_v && + !std::is_same_v); + + { + Comp comp; + Cont cont; + std::priority_queue pri(comp, cont, Alloc(2)); + static_assert(std::is_same_v>); + } + + { + Comp comp; + Cont cont; + std::priority_queue pri(comp, cont, ConvertibleToAlloc(2)); + static_assert(std::is_same_v>); + } + + { + Comp comp; + Cont cont; + std::priority_queue pri(comp, std::move(cont), Alloc(2)); + static_assert(std::is_same_v>); + } + + { + Comp comp; + Cont cont; + std::priority_queue pri(comp, std::move(cont), ConvertibleToAlloc(2)); + static_assert(std::is_same_v>); + } + } + + { + typedef short T; + typedef std::greater Comp; + typedef test_allocator Alloc; + typedef std::deque Cont; + typedef test_allocator ConvertibleToAlloc; + static_assert(std::uses_allocator_v && + !std::is_same_v); + + { + std::priority_queue source; + std::priority_queue pri(source, Alloc(2)); + static_assert(std::is_same_v>); + } + + { + std::priority_queue source; + std::priority_queue pri(source, ConvertibleToAlloc(2)); + static_assert(std::is_same_v>); + } + + { + std::priority_queue source; + std::priority_queue pri(std::move(source), Alloc(2)); + static_assert(std::is_same_v>); + } + + { + std::priority_queue source; + std::priority_queue pri(std::move(source), ConvertibleToAlloc(2)); + static_assert(std::is_same_v>); + } } - return 0; + return 0; } diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/deduct.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/deduct.pass.cpp --- a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/deduct.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/deduct.pass.cpp @@ -72,21 +72,70 @@ } { -// This one is odd - you can pass an allocator in to use, but the allocator -// has to match the type of the one used by the underlying container - typedef short T; - typedef test_allocator Alloc; - typedef std::deque Container; - - Container c{0,1,2,3}; - std::queue source(c); - std::queue que(source, Alloc(2)); // queue(queue &, allocator) - static_assert(std::is_same_v, ""); - static_assert(std::is_same_v, ""); - assert(que.size() == 4); - assert(que.back() == 3); + typedef short T; + typedef test_allocator Alloc; + typedef std::list Cont; + typedef test_allocator ConvertibleToAlloc; + static_assert(std::uses_allocator_v && + !std::is_same_v); + + { + Cont cont; + std::queue que(cont, Alloc(2)); + static_assert(std::is_same_v>); + } + + { + Cont cont; + std::queue que(cont, ConvertibleToAlloc(2)); + static_assert(std::is_same_v>); + } + + { + Cont cont; + std::queue que(std::move(cont), Alloc(2)); + static_assert(std::is_same_v>); + } + + { + Cont cont; + std::queue que(std::move(cont), ConvertibleToAlloc(2)); + static_assert(std::is_same_v>); + } } + { + typedef short T; + typedef test_allocator Alloc; + typedef std::list Cont; + typedef test_allocator ConvertibleToAlloc; + static_assert(std::uses_allocator_v && + !std::is_same_v); + + { + std::queue source; + std::queue que(source, Alloc(2)); + static_assert(std::is_same_v>); + } + + { + std::queue source; + std::queue que(source, ConvertibleToAlloc(2)); + static_assert(std::is_same_v>); + } + + { + std::queue source; + std::queue que(std::move(source), Alloc(2)); + static_assert(std::is_same_v>); + } + + { + std::queue source; + std::queue que(std::move(source), ConvertibleToAlloc(2)); + static_assert(std::is_same_v>); + } + } - return 0; + return 0; } diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/deduct.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/deduct.pass.cpp --- a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/deduct.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/deduct.pass.cpp @@ -22,6 +22,7 @@ #include +#include #include #include #include @@ -75,21 +76,70 @@ } { -// This one is odd - you can pass an allocator in to use, but the allocator -// has to match the type of the one used by the underlying container - typedef short T; - typedef test_allocator Alloc; - typedef std::deque Container; - - Container c{0,1,2,3}; - std::stack source(c); - std::stack stk(source, Alloc(2)); // stack(stack &, allocator) - static_assert(std::is_same_v, ""); - static_assert(std::is_same_v, ""); - assert(stk.size() == 4); - assert(stk.top() == 3); + typedef short T; + typedef test_allocator Alloc; + typedef std::list Cont; + typedef test_allocator ConvertibleToAlloc; + static_assert(std::uses_allocator_v && + !std::is_same_v); + + { + Cont cont; + std::stack stk(cont, Alloc(2)); + static_assert(std::is_same_v>); + } + + { + Cont cont; + std::stack stk(cont, ConvertibleToAlloc(2)); + static_assert(std::is_same_v>); + } + + { + Cont cont; + std::stack stk(std::move(cont), Alloc(2)); + static_assert(std::is_same_v>); + } + + { + Cont cont; + std::stack stk(std::move(cont), ConvertibleToAlloc(2)); + static_assert(std::is_same_v>); + } } + { + typedef short T; + typedef test_allocator Alloc; + typedef std::list Cont; + typedef test_allocator ConvertibleToAlloc; + static_assert(std::uses_allocator_v && + !std::is_same_v); + + { + std::stack source; + std::stack stk(source, Alloc(2)); + static_assert(std::is_same_v>); + } + + { + std::stack source; + std::stack stk(source, ConvertibleToAlloc(2)); + static_assert(std::is_same_v>); + } + + { + std::stack source; + std::stack stk(std::move(source), Alloc(2)); + static_assert(std::is_same_v>); + } + + { + std::stack source; + std::stack stk(std::move(source), ConvertibleToAlloc(2)); + static_assert(std::is_same_v>); + } + } - return 0; + return 0; } diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp --- a/libcxx/test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp +++ b/libcxx/test/std/containers/sequences/deque/deque.cons/deduct.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// +// // UNSUPPORTED: c++03, c++11, c++14 // UNSUPPORTED: libcpp-no-deduction-guides @@ -95,5 +95,34 @@ assert(deq.size() == 0); } - return 0; + { + typedef test_allocator Alloc; + typedef test_allocator ConvertibleToAlloc; + + { + std::deque source; + std::deque deq(source, Alloc(2)); + static_assert(std::is_same_v); + } + + { + std::deque source; + std::deque deq(source, ConvertibleToAlloc(2)); + static_assert(std::is_same_v); + } + + { + std::deque source; + std::deque deq(std::move(source), Alloc(2)); + static_assert(std::is_same_v); + } + + { + std::deque source; + std::deque deq(std::move(source), ConvertibleToAlloc(2)); + static_assert(std::is_same_v); + } + } + + return 0; } diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/deduct.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/deduct.pass.cpp --- a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/deduct.pass.cpp +++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/deduct.pass.cpp @@ -12,8 +12,8 @@ // template ::value_type>> -// deque(InputIterator, InputIterator, Allocator = Allocator()) -// -> deque::value_type, Allocator>; +// forward_list(InputIterator, InputIterator, Allocator = Allocator()) +// -> forward_list::value_type, Allocator>; // @@ -100,5 +100,34 @@ assert(std::distance(fwl.begin(), fwl.end()) == 0); // no size for forward_list } - return 0; + { + typedef test_allocator Alloc; + typedef test_allocator ConvertibleToAlloc; + + { + std::forward_list source; + std::forward_list fwl(source, Alloc(2)); + static_assert(std::is_same_v); + } + + { + std::forward_list source; + std::forward_list fwl(source, ConvertibleToAlloc(2)); + static_assert(std::is_same_v); + } + + { + std::forward_list source; + std::forward_list fwl(std::move(source), Alloc(2)); + static_assert(std::is_same_v); + } + + { + std::forward_list source; + std::forward_list fwl(std::move(source), ConvertibleToAlloc(2)); + static_assert(std::is_same_v); + } + } + + return 0; } diff --git a/libcxx/test/std/containers/sequences/list/list.cons/deduct.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/deduct.pass.cpp --- a/libcxx/test/std/containers/sequences/list/list.cons/deduct.pass.cpp +++ b/libcxx/test/std/containers/sequences/list/list.cons/deduct.pass.cpp @@ -100,5 +100,34 @@ assert(lst.size() == 0); } - return 0; + { + typedef test_allocator Alloc; + typedef test_allocator ConvertibleToAlloc; + + { + std::list source; + std::list lst(source, Alloc(2)); + static_assert(std::is_same_v); + } + + { + std::list source; + std::list lst(source, ConvertibleToAlloc(2)); + static_assert(std::is_same_v); + } + + { + std::list source; + std::list lst(std::move(source), Alloc(2)); + static_assert(std::is_same_v); + } + + { + std::list source; + std::list lst(std::move(source), ConvertibleToAlloc(2)); + static_assert(std::is_same_v); + } + } + + return 0; } diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/deduct.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/deduct.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/vector.cons/deduct.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.cons/deduct.pass.cpp @@ -12,8 +12,8 @@ // template ::value_type>> -// deque(InputIterator, InputIterator, Allocator = Allocator()) -// -> deque::value_type, Allocator>; +// vector(InputIterator, InputIterator, Allocator = Allocator()) +// -> vector::value_type, Allocator>; // @@ -113,5 +113,34 @@ assert(vec.size() == 0); } - return 0; + { + typedef test_allocator Alloc; + typedef test_allocator ConvertibleToAlloc; + + { + std::vector source; + std::vector vec(source, Alloc(2)); + static_assert(std::is_same_v); + } + + { + std::vector source; + std::vector vec(source, ConvertibleToAlloc(2)); + static_assert(std::is_same_v); + } + + { + std::vector source; + std::vector vec(std::move(source), Alloc(2)); + static_assert(std::is_same_v); + } + + { + std::vector source; + std::vector vec(std::move(source), ConvertibleToAlloc(2)); + static_assert(std::is_same_v); + } + } + + return 0; }