Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 66 additions & 4 deletions stl/inc/queue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public:
explicit queue(_Container&& _Cont) noexcept(is_nothrow_move_constructible_v<_Container>) // strengthened
: c(_STD move(_Cont)) {}

#if _HAS_CXX23
template <class _InIt, enable_if_t<_Is_iterator_v<_InIt>, int> = 0>
queue(_InIt _First, _InIt _Last) noexcept(is_nothrow_constructible_v<_Container, _InIt, _InIt>) // strengthened
: c(_STD move(_First), _STD move(_Last)) {}
#endif // _HAS_CXX23

template <class _Alloc, enable_if_t<uses_allocator_v<_Container, _Alloc>, int> = 0>
explicit queue(const _Alloc& _Al) noexcept(is_nothrow_constructible_v<_Container, const _Alloc&>) // strengthened
: c(_Al) {}
Expand All @@ -58,6 +64,14 @@ public:
is_nothrow_constructible_v<_Container, _Container, const _Alloc&>) // strengthened
: c(_STD move(_Right.c), _Al) {}

#if _HAS_CXX23
template <class _InIt, class _Alloc,
enable_if_t<conjunction_v<_Is_iterator<_InIt>, uses_allocator<_Container, _Alloc>>, int> = 0>
queue(_InIt _First, _InIt _Last, const _Alloc& _Al) noexcept(
is_nothrow_constructible_v<_Container, _InIt, _InIt, const _Alloc&>) // strengthened
: c(_STD move(_First), _STD move(_Last), _Al) {}
#endif // _HAS_CXX23

_NODISCARD bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ {
return c.empty();
}
Expand Down Expand Up @@ -126,6 +140,12 @@ template <class _Container, class _Alloc,
queue(_Container, _Alloc) -> queue<typename _Container::value_type, _Container>;
#endif // _HAS_CXX17

#if _HAS_CXX23
template <class _InIt, class _Alloc = allocator<_Iter_value_t<_InIt>>,
enable_if_t<conjunction_v<_Is_iterator<_InIt>, _Is_allocator<_Alloc>>, int> = 0>
queue(_InIt, _InIt, _Alloc = _Alloc()) -> queue<_Iter_value_t<_InIt>, deque<_Iter_value_t<_InIt>, _Alloc>>;
#endif // _HAS_CXX23

template <class _Ty, class _Container>
_NODISCARD bool operator==(const queue<_Ty, _Container>& _Left, const queue<_Ty, _Container>& _Right) {
return _Left._Get_container() == _Right._Get_container();
Expand Down Expand Up @@ -198,23 +218,23 @@ public:
_STD make_heap(c.begin(), c.end(), comp);
}

template <class _InIt>
template <class _InIt, enable_if_t<_Is_iterator_v<_InIt>, int> = 0>
priority_queue(_InIt _First, _InIt _Last, const _Pr& _Pred, const _Container& _Cont) : c(_Cont), comp(_Pred) {
c.insert(c.end(), _First, _Last);
_STD make_heap(c.begin(), c.end(), comp);
}

template <class _InIt>
template <class _InIt, enable_if_t<_Is_iterator_v<_InIt>, int> = 0>
priority_queue(_InIt _First, _InIt _Last) : c(_First, _Last), comp() {
_STD make_heap(c.begin(), c.end(), comp);
}

template <class _InIt>
template <class _InIt, enable_if_t<_Is_iterator_v<_InIt>, int> = 0>
priority_queue(_InIt _First, _InIt _Last, const _Pr& _Pred) : c(_First, _Last), comp(_Pred) {
_STD make_heap(c.begin(), c.end(), comp);
}

template <class _InIt>
template <class _InIt, enable_if_t<_Is_iterator_v<_InIt>, int> = 0>
priority_queue(_InIt _First, _InIt _Last, const _Pr& _Pred, _Container&& _Cont) : c(_STD move(_Cont)), comp(_Pred) {
c.insert(c.end(), _First, _Last);
_STD make_heap(c.begin(), c.end(), comp);
Expand Down Expand Up @@ -249,6 +269,35 @@ public:
is_nothrow_move_constructible_v<value_compare>) // strengthened
: c(_STD move(_Right.c), _Al), comp(_STD move(_Right.comp)) {}

template <class _InIt, class _Alloc,
enable_if_t<_Is_iterator_v<_InIt> && uses_allocator_v<_Container, _Alloc>, int> = 0>
priority_queue(_InIt _First, _InIt _Last, const _Alloc& _Al) : c(_First, _Last, _Al), comp() {
_STD make_heap(c.begin(), c.end(), comp);
}

template <class _InIt, class _Alloc,
enable_if_t<_Is_iterator_v<_InIt> && uses_allocator_v<_Container, _Alloc>, int> = 0>
priority_queue(_InIt _First, _InIt _Last, const _Pr& _Pred, const _Alloc& _Al)
: c(_First, _Last, _Al), comp(_Pred) {
_STD make_heap(c.begin(), c.end(), comp);
}

template <class _InIt, class _Alloc,
enable_if_t<_Is_iterator_v<_InIt> && uses_allocator_v<_Container, _Alloc>, int> = 0>
priority_queue(_InIt _First, _InIt _Last, const _Pr& _Pred, const _Container& _Cont, const _Alloc& _Al)
: c(_Cont, _Al), comp(_Pred) {
c.insert(c.end(), _First, _Last);
_STD make_heap(c.begin(), c.end(), comp);
}

template <class _InIt, class _Alloc,
enable_if_t<_Is_iterator_v<_InIt> && uses_allocator_v<_Container, _Alloc>, int> = 0>
priority_queue(_InIt _First, _InIt _Last, const _Pr& _Pred, _Container&& _Cont, const _Alloc& _Al)
: c(_STD move(_Cont), _Al), comp(_Pred) {
c.insert(c.end(), _First, _Last);
_STD make_heap(c.begin(), c.end(), comp);
}

_NODISCARD bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ {
return c.empty();
}
Expand Down Expand Up @@ -309,6 +358,19 @@ template <class _Pr, class _Container, class _Alloc,
uses_allocator<_Container, _Alloc>>,
int> = 0>
priority_queue(_Pr, _Container, _Alloc) -> priority_queue<typename _Container::value_type, _Container, _Pr>;

template <class _Iter, class _Alloc, class _Container = vector<_Iter_value_t<_Iter>, _Alloc>,
enable_if_t<conjunction_v<_Is_iterator<_Iter>, _Is_allocator<_Alloc>, uses_allocator<_Container, _Alloc>>, int> = 0>
priority_queue(_Iter, _Iter, _Alloc) -> priority_queue<_Iter_value_t<_Iter>, _Container, less<_Iter_value_t<_Iter>>>;

template <class _Iter, class _Compare, class _Alloc, class _Container = vector<_Iter_value_t<_Iter>, _Alloc>,
enable_if_t<conjunction_v<_Is_iterator<_Iter>, _Is_allocator<_Alloc>, uses_allocator<_Container, _Alloc>>, int> = 0>
priority_queue(_Iter, _Iter, _Compare, _Alloc) -> priority_queue<_Iter_value_t<_Iter>, _Container, _Compare>;

template <class _Iter, class _Compare, class _Container, class _Alloc,
enable_if_t<conjunction_v<_Is_iterator<_Iter>, _Is_allocator<_Alloc>, uses_allocator<_Container, _Alloc>>, int> = 0>
priority_queue(_Iter, _Iter, _Compare, _Container, _Alloc)
-> priority_queue<typename _Container::value_type, _Container, _Compare>;
#endif // _HAS_CXX17

template <class _Ty, class _Container, class _Pr,
Expand Down
20 changes: 20 additions & 0 deletions stl/inc/stack
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public:
explicit stack(_Container&& _Cont) noexcept(is_nothrow_move_constructible_v<_Container>) // strengthened
: c(_STD move(_Cont)) {}

#if _HAS_CXX23
template <class _InIt, enable_if_t<_Is_iterator_v<_InIt>, int> = 0>
stack(_InIt _First, _InIt _Last) noexcept(is_nothrow_constructible_v<_Container, _InIt, _InIt>) // strengthened
: c(_STD move(_First), _STD move(_Last)) {}
#endif // _HAS_CXX23

template <class _Alloc, enable_if_t<uses_allocator_v<_Container, _Alloc>, int> = 0>
explicit stack(const _Alloc& _Al) noexcept(is_nothrow_constructible_v<_Container, const _Alloc&>) // strengthened
: c(_Al) {}
Expand All @@ -56,6 +62,14 @@ public:
is_nothrow_constructible_v<_Container, _Container, const _Alloc&>) // strengthened
: c(_STD move(_Right.c), _Al) {}

#if _HAS_CXX23
template <class _InIt, class _Alloc,
enable_if_t<conjunction_v<_Is_iterator<_InIt>, uses_allocator<_Container, _Alloc>>, int> = 0>
stack(_InIt _First, _InIt _Last, const _Alloc& _Al) noexcept(
is_nothrow_constructible_v<_Container, _InIt, _InIt, const _Alloc&>) // strengthened
: c(_STD move(_First), _STD move(_Last), _Al) {}
#endif // _HAS_CXX23

_NODISCARD bool empty() const noexcept(noexcept(c.empty())) /* strengthened */ {
return c.empty();
}
Expand Down Expand Up @@ -116,6 +130,12 @@ template <class _Container, class _Alloc,
stack(_Container, _Alloc) -> stack<typename _Container::value_type, _Container>;
#endif // _HAS_CXX17

#if _HAS_CXX23
template <class _InIt, class _Alloc = allocator<_Iter_value_t<_InIt>>,
enable_if_t<conjunction_v<_Is_iterator<_InIt>, _Is_allocator<_Alloc>>, int> = 0>
stack(_InIt, _InIt, _Alloc = _Alloc()) -> stack<_Iter_value_t<_InIt>, deque<_Iter_value_t<_InIt>, _Alloc>>;
#endif // _HAS_CXX23

template <class _Ty, class _Container>
_NODISCARD bool operator==(const stack<_Ty, _Container>& _Left, const stack<_Ty, _Container>& _Right) {
return _Left._Get_container() == _Right._Get_container();
Expand Down
3 changes: 3 additions & 0 deletions stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
// P0401R6 Providing Size Feedback In The Allocator Interface
// P1048R1 is_scoped_enum
// P1132R7 out_ptr(), inout_ptr()
// P1425R4 Iterator Pair Constructors For stack And queue
// P1679R3 contains() For basic_string/basic_string_view
// P1682R3 to_underlying() For Enumerations
// P1951R1 Default Template Arguments For pair's Forwarding Constructor
Expand Down Expand Up @@ -1352,6 +1353,8 @@

// C++23
#if _HAS_CXX23
#define __cpp_lib_adaptor_iterator_pair_constructor 202106L

#ifdef __cpp_lib_concepts
#define __cpp_lib_allocate_at_least 202106L
#endif // __cpp_lib_concepts
Expand Down
1 change: 1 addition & 0 deletions tests/std/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ tests\P1135R6_semaphore
tests\P1165R1_consistently_propagating_stateful_allocators
tests\P1208R6_source_location
tests\P1423R3_char8_t_remediation
tests\P1425R4_queue_stack_constructors
tests\P1502R1_standard_library_header_units
tests\P1614R2_spaceship
tests\P1645R1_constexpr_numeric
Expand Down
4 changes: 4 additions & 0 deletions tests/std/tests/P1425R4_queue_stack_constructors/env.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

RUNALL_INCLUDE ..\usual_matrix.lst
Loading