@@ -43,6 +43,7 @@ public:
43
43
explicit queue(container_type&& c)
44
44
template<class InputIterator>
45
45
queue(InputIterator first, InputIterator last); // since C++23
46
+ template<container-compatible-range<T> R> queue(from_range_t, R&& rg); // since C++23
46
47
template <class Alloc>
47
48
explicit queue(const Alloc& a);
48
49
template <class Alloc>
@@ -55,6 +56,8 @@ public:
55
56
queue(queue&& q, const Alloc& a);
56
57
template <class InputIterator, class Alloc>
57
58
queue(InputIterator first, InputIterator last, const Alloc&); // since C++23
59
+ template<container-compatible-range<T> R, class Alloc>
60
+ queue(from_range_t, R&& rg, const Alloc&); // since C++23
58
61
59
62
bool empty() const;
60
63
size_type size() const;
@@ -66,6 +69,8 @@ public:
66
69
67
70
void push(const value_type& v);
68
71
void push(value_type&& v);
72
+ template<container-compatible-range<T> R>
73
+ void push_range(R&& rg); // C++23
69
74
template <class... Args> reference emplace(Args&&... args); // reference in C++17
70
75
void pop();
71
76
@@ -78,6 +83,9 @@ template<class Container>
78
83
template<class InputIterator>
79
84
queue(InputIterator, InputIterator) -> queue<iter-value-type<InputIterator>>; // since C++23
80
85
86
+ template<ranges::input_range R>
87
+ queue(from_range_t, R&&) -> queue<ranges::range_value_t<R>>; // since C++23
88
+
81
89
template<class Container, class Allocator>
82
90
queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17
83
91
@@ -86,6 +94,10 @@ template<class InputIterator, class Allocator>
86
94
-> queue<iter-value-type<InputIterator>,
87
95
deque<iter-value-type<InputIterator>, Allocator>>; // since C++23
88
96
97
+ template<ranges::input_range R, class Allocator>
98
+ queue(from_range_t, R&&, Allocator)
99
+ -> queue<ranges::range_value_t<R>, deque<ranges::range_value_t<R>, Allocator>>; // since C++23
100
+
89
101
template <class T, class Container>
90
102
bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
91
103
@@ -138,6 +150,8 @@ public:
138
150
template <class InputIterator>
139
151
priority_queue(InputIterator first, InputIterator last,
140
152
const Compare& comp, Container&& c);
153
+ template <container-compatible-range<T> R>
154
+ priority_queue(from_range_t, R&& rg, const Compare& x = Compare()); // since C++23
141
155
template <class Alloc>
142
156
explicit priority_queue(const Alloc& a);
143
157
template <class Alloc>
@@ -160,6 +174,10 @@ public:
160
174
template <class InputIterator>
161
175
priority_queue(InputIterator first, InputIterator last,
162
176
const Compare& comp, Container&& c, const Alloc& a);
177
+ template <container-compatible-range<T> R, class Alloc>
178
+ priority_queue(from_range_t, R&& rg, const Compare&, const Alloc&); // since C++23
179
+ template <container-compatible-range<T> R, class Alloc>
180
+ priority_queue(from_range_t, R&& rg, const Alloc&); // since C++23
163
181
template <class Alloc>
164
182
priority_queue(const priority_queue& q, const Alloc& a);
165
183
template <class Alloc>
@@ -171,6 +189,8 @@ public:
171
189
172
190
void push(const value_type& v);
173
191
void push(value_type&& v);
192
+ template<container-compatible-range<T> R>
193
+ void push_range(R&& rg); // C++23
174
194
template <class... Args> void emplace(Args&&... args);
175
195
void pop();
176
196
@@ -189,6 +209,10 @@ template<class InputIterator,
189
209
priority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
190
210
-> priority_queue<iter-value-type<InputIterator>, Container, Compare>; // C++17
191
211
212
+ template<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>>
213
+ priority_queue(from_range_t, R&&, Compare = Compare())
214
+ -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>>, Compare>; // C++23
215
+
192
216
template<class Compare, class Container, class Allocator>
193
217
priority_queue(Compare, Container, Allocator)
194
218
-> priority_queue<typename Container::value_type, Container, Compare>; // C++17
@@ -208,6 +232,15 @@ template<class InputIterator, class Compare, class Container, class Allocator>
208
232
priority_queue(InputIterator, InputIterator, Compare, Container, Allocator)
209
233
-> priority_queue<typename Container::value_type, Container, Compare>; // C++17
210
234
235
+ template<ranges::input_range R, class Compare, class Allocator>
236
+ priority_queue(from_range_t, R&&, Compare, Allocator)
237
+ -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>,
238
+ Compare>; // C++23
239
+
240
+ template<ranges::input_range R, class Allocator>
241
+ priority_queue(from_range_t, R&&, Allocator)
242
+ -> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>>; // C++23
243
+
211
244
template <class T, class Container, class Compare>
212
245
void swap(priority_queue<T, Container, Compare>& x,
213
246
priority_queue<T, Container, Compare>& y)
@@ -220,11 +253,17 @@ template <class T, class Container, class Compare>
220
253
#include < __algorithm/make_heap.h>
221
254
#include < __algorithm/pop_heap.h>
222
255
#include < __algorithm/push_heap.h>
256
+ #include < __algorithm/ranges_copy.h>
223
257
#include < __assert> // all public C++ headers provide the assertion handler
224
258
#include < __config>
225
259
#include < __functional/operations.h>
260
+ #include < __iterator/back_insert_iterator.h>
226
261
#include < __iterator/iterator_traits.h>
227
262
#include < __memory/uses_allocator.h>
263
+ #include < __ranges/access.h>
264
+ #include < __ranges/concepts.h>
265
+ #include < __ranges/container_compatible_range.h>
266
+ #include < __ranges/from_range.h>
228
267
#include < __utility/forward.h>
229
268
#include < deque>
230
269
#include < vector>
@@ -283,12 +322,24 @@ public:
283
322
_LIBCPP_HIDE_FROM_ABI
284
323
queue (_InputIterator __first, _InputIterator __last) : c(__first, __last) {}
285
324
325
+ template <_ContainerCompatibleRange<_Tp> _Range>
326
+ _LIBCPP_HIDE_FROM_ABI
327
+ queue (from_range_t , _Range&& __range) : c(from_range, std::forward<_Range>(__range)) {}
328
+
286
329
template <class _InputIterator ,
287
330
class _Alloc ,
288
331
class = __enable_if_t <__has_input_iterator_category<_InputIterator>::value>,
289
332
class = __enable_if_t <uses_allocator<container_type, _Alloc>::value>>
290
333
_LIBCPP_HIDE_FROM_ABI
291
334
queue (_InputIterator __first, _InputIterator __second, const _Alloc& __alloc) : c(__first, __second, __alloc) {}
335
+
336
+ template <_ContainerCompatibleRange<_Tp> _Range,
337
+ class _Alloc ,
338
+ class = __enable_if_t <uses_allocator<container_type, _Alloc>::value>>
339
+ _LIBCPP_HIDE_FROM_ABI
340
+ queue (from_range_t , _Range&& __range, const _Alloc& __alloc)
341
+ : c(from_range, std::forward<_Range>(__range), __alloc) {}
342
+
292
343
#endif
293
344
294
345
_LIBCPP_INLINE_VISIBILITY
@@ -360,6 +411,21 @@ public:
360
411
#ifndef _LIBCPP_CXX03_LANG
361
412
_LIBCPP_INLINE_VISIBILITY
362
413
void push (value_type&& __v) {c.push_back (_VSTD::move (__v));}
414
+
415
+ #if _LIBCPP_STD_VER >= 23
416
+ template <_ContainerCompatibleRange<_Tp> _Range>
417
+ _LIBCPP_HIDE_FROM_ABI
418
+ void push_range (_Range&& __range) {
419
+ if constexpr (requires (container_type& __c) {
420
+ __c.append_range (std::forward<_Range>(__range));
421
+ }) {
422
+ c.append_range (std::forward<_Range>(__range));
423
+ } else {
424
+ ranges::copy (std::forward<_Range>(__range), std::back_inserter (c));
425
+ }
426
+ }
427
+ #endif
428
+
363
429
template <class ... _Args>
364
430
_LIBCPP_INLINE_VISIBILITY
365
431
#if _LIBCPP_STD_VER >= 17
@@ -418,12 +484,22 @@ template <class _InputIterator,
418
484
queue (_InputIterator, _InputIterator)
419
485
-> queue<__iter_value_type<_InputIterator>>;
420
486
487
+ template <ranges::input_range _Range>
488
+ queue (from_range_t , _Range&&)
489
+ -> queue<ranges::range_value_t<_Range>>;
490
+
421
491
template <class _InputIterator ,
422
492
class _Alloc ,
423
493
class = __enable_if_t <__has_input_iterator_category<_InputIterator>::value>,
424
494
class = __enable_if_t <__is_allocator<_Alloc>::value>>
425
495
queue (_InputIterator, _InputIterator, _Alloc)
426
496
-> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
497
+
498
+ template <ranges::input_range _Range,
499
+ class _Alloc ,
500
+ class = __enable_if_t <__is_allocator<_Alloc>::value>>
501
+ queue (from_range_t , _Range&&, _Alloc)
502
+ -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
427
503
#endif
428
504
429
505
template <class _Tp , class _Container >
@@ -557,6 +633,17 @@ public:
557
633
priority_queue (_InputIter __f, _InputIter __l,
558
634
const value_compare& __comp, container_type&& __c);
559
635
#endif // _LIBCPP_CXX03_LANG
636
+
637
+ #if _LIBCPP_STD_VER >= 23
638
+ template <_ContainerCompatibleRange<_Tp> _Range>
639
+ _LIBCPP_HIDE_FROM_ABI
640
+ priority_queue (from_range_t , _Range&& __range, const value_compare& __comp = value_compare())
641
+ : c(from_range, std::forward<_Range>(__range)),
642
+ comp(__comp) {
643
+ std::make_heap (c.begin (), c.end (), comp);
644
+ }
645
+ #endif
646
+
560
647
template <class _Alloc >
561
648
_LIBCPP_INLINE_VISIBILITY
562
649
explicit priority_queue (const _Alloc& __a,
@@ -611,6 +698,30 @@ public:
611
698
__enable_if_t <uses_allocator<container_type, _Alloc>::value>* = 0 );
612
699
#endif // _LIBCPP_CXX03_LANG
613
700
701
+ #if _LIBCPP_STD_VER >= 23
702
+
703
+ template <_ContainerCompatibleRange<_Tp> _Range,
704
+ class _Alloc ,
705
+ class = enable_if_t <uses_allocator<_Container, _Alloc>::value>>
706
+ _LIBCPP_HIDE_FROM_ABI
707
+ priority_queue (from_range_t , _Range&& __range, const value_compare& __comp, const _Alloc& __a)
708
+ : c(from_range, std::forward<_Range>(__range), __a),
709
+ comp(__comp) {
710
+ std::make_heap (c.begin (), c.end (), comp);
711
+ }
712
+
713
+ template <_ContainerCompatibleRange<_Tp> _Range,
714
+ class _Alloc ,
715
+ class = enable_if_t <uses_allocator<_Container, _Alloc>::value>>
716
+ _LIBCPP_HIDE_FROM_ABI
717
+ priority_queue (from_range_t , _Range&& __range, const _Alloc& __a)
718
+ : c(from_range, std::forward<_Range>(__range), __a),
719
+ comp() {
720
+ std::make_heap (c.begin (), c.end (), comp);
721
+ }
722
+
723
+ #endif
724
+
614
725
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
615
726
bool empty () const {return c.empty ();}
616
727
_LIBCPP_INLINE_VISIBILITY
@@ -623,6 +734,23 @@ public:
623
734
#ifndef _LIBCPP_CXX03_LANG
624
735
_LIBCPP_INLINE_VISIBILITY
625
736
void push (value_type&& __v);
737
+
738
+ #if _LIBCPP_STD_VER >= 23
739
+ template <_ContainerCompatibleRange<_Tp> _Range>
740
+ _LIBCPP_HIDE_FROM_ABI
741
+ void push_range (_Range&& __range) {
742
+ if constexpr (requires (container_type& __c) {
743
+ __c.append_range (std::forward<_Range>(__range));
744
+ }) {
745
+ c.append_range (std::forward<_Range>(__range));
746
+ } else {
747
+ ranges::copy (std::forward<_Range>(__range), std::back_inserter (c));
748
+ }
749
+
750
+ std::make_heap (c.begin (), c.end (), comp);
751
+ }
752
+ #endif
753
+
626
754
template <class ... _Args>
627
755
_LIBCPP_INLINE_VISIBILITY
628
756
void emplace (_Args&&... __args);
@@ -695,6 +823,31 @@ priority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc)
695
823
-> priority_queue<typename _Container::value_type, _Container, _Compare>;
696
824
#endif
697
825
826
+ #if _LIBCPP_STD_VER >= 23
827
+
828
+ template <ranges::input_range _Range,
829
+ class _Compare = less<ranges::range_value_t <_Range>>,
830
+ class = enable_if_t <!__is_allocator<_Compare>::value>>
831
+ priority_queue (from_range_t , _Range&&, _Compare = _Compare())
832
+ -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>>, _Compare>;
833
+
834
+ template <ranges::input_range _Range,
835
+ class _Compare ,
836
+ class _Alloc ,
837
+ class = enable_if_t <!__is_allocator<_Compare>::value>,
838
+ class = enable_if_t <__is_allocator<_Alloc>::value>>
839
+ priority_queue (from_range_t , _Range&&, _Compare, _Alloc)
840
+ -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>,
841
+ _Compare>;
842
+
843
+ template <ranges::input_range _Range,
844
+ class _Alloc ,
845
+ class = enable_if_t <__is_allocator<_Alloc>::value>>
846
+ priority_queue (from_range_t , _Range&&, _Alloc)
847
+ -> priority_queue<ranges::range_value_t<_Range>, vector<ranges::range_value_t<_Range>, _Alloc>>;
848
+
849
+ #endif
850
+
698
851
template <class _Tp , class _Container , class _Compare >
699
852
inline
700
853
priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,
0 commit comments