With Tomasz' comments from last time. I (at least tried to :P)
implemented everything except for getting the tests to function
properly with -D_GLIBCXX_DEBUG. I think we think we may want to hold
off on marking all the debug stuff constexpr until all other
containers are finished; I think it's technically do-able now, but it
involves fussing with the test infrastructure in a way that should be
more convenient to do later.
I have some other patches bitrotting on my computer that make partial
progress towards P3372. I'll eventually get around to sending them
in, but feel free to email me if interested on taking them further ^^
Testsuite works on my x86_64 machine.
--- 8< ---
This patch makes partial progress towards P3372 by marking
std::{deque, priority_queue, queue} and relevant internal helpers to be
constexpr when using C++26. Although the debug versions of deque are
marked as constexpr, the rest of the debug functionality in libstdc++
still needs to be marked constexpr as well. So our tests are xfail with
-D_GLIBCXX_DEBUG for now.
libstdc++-v3/ChangeLog:
* include/Makefile.am: Have stdc++.h precompiled header build
* with --std=gnu++2c due to symbol changes in stl_algobase.h
* include/bits/deque.tcc: Mark constexpr; note that those
* functions in stl_algobase.h are marked as CXX20 constexpr only.
* include/bits/stl_algobase.h: Mark deque helper functions CXX20
* constexpr.
* include/bits/stl_deque.h: Mark CXX26 constexpr.
* include/bits/stl_queue.h: Mark CXX26 constexpr.
* include/bits/stl_uninitialized.h: Mark helper
* __uninitialized_default_a CXX26 constexpr.
* include/bits/version.def: Add feature test macros for
* __cpp_lib_constexpr_{queue, dequeue}.
* include/bits/version.h: Regenerate.
* include/debug/deque: Mark member functions CXX26 constexpr.
* include/std/deque: Mark nonmember functions CXX26 constexpr
* and add macros.
* include/std/queue: Mark nonmember functions CXX26 constexpr
* and add macros.
* testsuite/23_containers/deque/constexpr.cc: New test.
* testsuite/23_containers/deque/debug/constexpr.cc: New test.
* testsuite/23_containers/priority_queue/constexpr.cc: New test.
* testsuite/23_containers/queue/constexpr.cc: New test.
Signed-off-by: Thor Preimesberger <[email protected]>
---
libstdc++-v3/include/Makefile.am | 2 +-
libstdc++-v3/include/bits/deque.tcc | 53 +++
libstdc++-v3/include/bits/stl_algobase.h | 16 +-
libstdc++-v3/include/bits/stl_deque.h | 168 +++++++-
libstdc++-v3/include/bits/stl_queue.h | 73 +++-
libstdc++-v3/include/bits/stl_uninitialized.h | 2 +
libstdc++-v3/include/bits/version.def | 16 +
libstdc++-v3/include/bits/version.h | 20 +
libstdc++-v3/include/debug/deque | 72 ++++
libstdc++-v3/include/std/deque | 4 +-
libstdc++-v3/include/std/queue | 12 +-
.../23_containers/deque/constexpr.cc | 348 +++++++++++++++++
.../23_containers/deque/debug/constexpr.cc | 361 ++++++++++++++++++
.../23_containers/priority_queue/constexpr.cc | 323 ++++++++++++++++
.../23_containers/queue/constexpr.cc | 281 ++++++++++++++
15 files changed, 1737 insertions(+), 14 deletions(-)
create mode 100644 libstdc++-v3/testsuite/23_containers/deque/constexpr.cc
create mode 100644
libstdc++-v3/testsuite/23_containers/deque/debug/constexpr.cc
create mode 100644
libstdc++-v3/testsuite/23_containers/priority_queue/constexpr.cc
create mode 100644 libstdc++-v3/testsuite/23_containers/queue/constexpr.cc
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index e6ac312ac7a..62f4b6862bc 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -1481,7 +1481,7 @@ ${host_builddir}/gthr-default.h:
${toplevel_srcdir}/libgcc/${thread_header} \
# Build two precompiled C++ includes, stdc++.h.gch/*.gch
${pch1a_output}: ${allstamped} ${host_builddir}/c++config.h ${pch1_source}
-mkdir -p ${pch1_output_builddir}
- $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g -std=gnu++0x ${pch1_source} \
+ $(CXX) $(PCHFLAGS) $(AM_CPPFLAGS) -O2 -g -std=gnu++2c ${pch1_source} \
-o $@
${pch1b_output}: ${allstamped} ${host_builddir}/c++config.h ${pch1_source}
diff --git a/libstdc++-v3/include/bits/deque.tcc
b/libstdc++-v3/include/bits/deque.tcc
index 7a690466cd5..b9ef85073e4 100644
--- a/libstdc++-v3/include/bits/deque.tcc
+++ b/libstdc++-v3/include/bits/deque.tcc
@@ -65,6 +65,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
template <typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_default_initialize()
@@ -91,6 +92,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#endif
template <typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
deque<_Tp, _Alloc>&
deque<_Tp, _Alloc>::
operator=(const deque& __x)
@@ -133,6 +135,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, typename _Alloc>
template<typename... _Args>
#if __cplusplus > 201402L
+ _GLIBCXX26_CONSTEXPR
typename deque<_Tp, _Alloc>::reference
#else
void
@@ -157,6 +160,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, typename _Alloc>
template<typename... _Args>
#if __cplusplus > 201402L
+ _GLIBCXX26_CONSTEXPR
typename deque<_Tp, _Alloc>::reference
#else
void
@@ -183,6 +187,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
template<typename _Tp, typename _Alloc>
template<typename... _Args>
+ _GLIBCXX26_CONSTEXPR
typename deque<_Tp, _Alloc>::iterator
deque<_Tp, _Alloc>::
emplace(const_iterator __position, _Args&&... __args)
@@ -206,6 +211,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#endif
template <typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
typename deque<_Tp, _Alloc>::iterator
deque<_Tp, _Alloc>::
#if __cplusplus >= 201103L
@@ -231,6 +237,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template <typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
typename deque<_Tp, _Alloc>::iterator
deque<_Tp, _Alloc>::
_M_erase(iterator __position)
@@ -254,6 +261,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template <typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
typename deque<_Tp, _Alloc>::iterator
deque<_Tp, _Alloc>::
_M_erase(iterator __first, iterator __last)
@@ -303,6 +311,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template <typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_fill_insert(iterator __pos, size_type __n, const value_type& __x)
@@ -346,6 +355,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
template <typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_default_append(size_type __n)
@@ -370,6 +380,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template <typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
bool
deque<_Tp, _Alloc>::
_M_shrink_to_fit()
@@ -389,6 +400,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#endif
template <typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_fill_initialize(const value_type& __value)
@@ -415,6 +427,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template <typename _Tp, typename _Alloc>
template <typename _InputIterator>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_range_initialize(_InputIterator __first, _InputIterator __last,
@@ -439,6 +452,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template <typename _Tp, typename _Alloc>
template <typename _ForwardIterator>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
@@ -480,6 +494,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, typename _Alloc>
#if __cplusplus >= 201103L
template<typename... _Args>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_push_back_aux(_Args&&... __args)
@@ -519,6 +534,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, typename _Alloc>
#if __cplusplus >= 201103L
template<typename... _Args>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_push_front_aux(_Args&&... __args)
@@ -557,6 +573,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// Called only if _M_impl._M_finish._M_cur == _M_impl._M_finish._M_first.
template <typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
void deque<_Tp, _Alloc>::
_M_pop_back_aux()
{
@@ -573,6 +590,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// _M_impl._M_start._M_cur == _M_impl._M_start._M_last,
// then the deque must have at least two nodes.
template <typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
void deque<_Tp, _Alloc>::
_M_pop_front_aux()
{
@@ -585,6 +603,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template <typename _Tp, typename _Alloc>
template <typename _InputIterator, typename _Sentinel>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_range_prepend(_InputIterator __first, _Sentinel __last,
@@ -607,6 +626,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template <typename _Tp, typename _Alloc>
template <typename _InputIterator, typename _Sentinel>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_range_append(_InputIterator __first, _Sentinel __last,
@@ -630,6 +650,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template <typename _Tp, typename _Alloc>
template <typename _InputIterator>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_range_insert_aux(iterator __pos,
@@ -639,6 +660,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template <typename _Tp, typename _Alloc>
template <typename _ForwardIterator>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_range_insert_aux(iterator __pos,
@@ -660,6 +682,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, typename _Alloc>
#if __cplusplus >= 201103L
template<typename... _Args>
+ _GLIBCXX26_CONSTEXPR
typename deque<_Tp, _Alloc>::iterator
deque<_Tp, _Alloc>::
_M_emplace_aux(iterator __pos, _Args&&... __args)
@@ -707,6 +730,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template <typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_insert_aux(iterator __pos, size_type __n, const value_type& __x)
@@ -793,6 +817,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template <typename _Tp, typename _Alloc>
template <typename _ForwardIterator>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_insert_aux(iterator __pos,
@@ -882,6 +907,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __glibcxx_containers_ranges // C++ >= 23
template<ranges::forward_range _Rg>
+ _GLIBCXX26_CONSTEXPR
auto __advance_dist(_Rg& __rg)
{
struct _Res
@@ -914,6 +940,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, typename _Alloc>
template<__detail::__container_compatible_range<_Tp> _Rg>
+ _GLIBCXX26_CONSTEXPR
auto
deque<_Tp, _Alloc>::
insert_range(const_iterator __pos, _Rg&& __rg)
@@ -954,6 +981,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, typename _Alloc>
template<__detail::__container_compatible_range<_Tp> _Rg>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
prepend_range(_Rg&& __rg)
@@ -996,6 +1024,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, typename _Alloc>
template<__detail::__container_compatible_range<_Tp> _Rg>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
append_range(_Rg&& __rg)
@@ -1013,6 +1042,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
deque& __self;
size_type __n = __self.size();
+ _GLIBCXX26_CONSTEXPR
~_Guard_elts_back()
{
if (__n < __self.size())
@@ -1032,6 +1062,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#endif // containers_ranges
template<typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_destroy_data_aux(iterator __first, iterator __last)
@@ -1054,6 +1085,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template <typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_new_elements_at_front(size_type __new_elems)
@@ -1079,6 +1111,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template <typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_new_elements_at_back(size_type __new_elems)
@@ -1104,6 +1137,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template <typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
void
deque<_Tp, _Alloc>::
_M_reallocate_map(size_type __nodes_to_add, bool __add_at_front)
@@ -1158,6 +1192,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
// Overload for deque::iterators, exploiting the "segmented-iterator
// optimization".
template<typename _Tp, typename _VTp>
+ _GLIBCXX20_CONSTEXPR
void
__fill_a1(const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __first,
const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __last,
@@ -1180,6 +1215,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _Tp, typename _Ref, typename _Ptr, typename _OI>
+ _GLIBCXX20_CONSTEXPR
_OI
__copy_move_dit(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last,
@@ -1209,6 +1245,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _Tp, typename _Ref, typename _Ptr, typename _OI>
+ _GLIBCXX20_CONSTEXPR
_OI
__copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last,
@@ -1217,6 +1254,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _ITp, typename _IRef, typename _IPtr, typename _OTp>
+ _GLIBCXX20_CONSTEXPR
_GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
__copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __last,
@@ -1224,6 +1262,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
{ return __copy_move_dit<_IsMove>(__first, __last, __result); }
template<bool _IsMove, typename _II, typename _Tp>
+ _GLIBCXX20_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_any_random_access_iter<_II>::__value,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type
@@ -1250,6 +1289,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
}
template<bool _IsMove, typename _CharT>
+ _GLIBCXX20_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_char<_CharT>::__value,
_GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type
@@ -1277,6 +1317,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
}
template<typename _CharT, typename _Size>
+ _GLIBCXX20_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_char<_CharT>::__value,
_GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type
@@ -1302,6 +1343,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _Tp, typename _Ref, typename _Ptr, typename _OI>
+ _GLIBCXX26_CONSTEXPR
_OI
__copy_move_backward_dit(
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first,
@@ -1329,6 +1371,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _Tp, typename _Ref, typename _Ptr, typename _OI>
+ _GLIBCXX20_CONSTEXPR
_OI
__copy_move_backward_a1(
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first,
@@ -1338,6 +1381,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _ITp, typename _IRef, typename _IPtr, typename _OTp>
+ _GLIBCXX20_CONSTEXPR
_GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
__copy_move_backward_a1(
_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
@@ -1346,6 +1390,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
{ return __copy_move_backward_dit<_IsMove>(__first, __last, __result); }
template<bool _IsMove, typename _II, typename _Tp>
+ _GLIBCXX20_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_any_random_access_iter<_II>::__value,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type
@@ -1378,6 +1423,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
}
template<typename _Tp, typename _Ref, typename _Ptr, typename _II>
+ _GLIBCXX20_CONSTEXPR
bool
__equal_dit(
const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>& __first1,
@@ -1405,6 +1451,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
}
template<typename _Tp, typename _Ref, typename _Ptr, typename _II>
+ _GLIBCXX20_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_any_random_access_iter<_II>::__value, bool>::__type
__equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first1,
@@ -1414,6 +1461,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _Tp1, typename _Ref1, typename _Ptr1,
typename _Tp2, typename _Ref2, typename _Ptr2>
+ _GLIBCXX20_CONSTEXPR
bool
__equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1,
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1,
@@ -1421,6 +1469,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
{ return std::__equal_dit(__first1, __last1, __first2); }
template<typename _II, typename _Tp, typename _Ref, typename _Ptr>
+ _GLIBCXX20_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_any_random_access_iter<_II>::__value, bool>::__type
__equal_aux1(_II __first1, _II __last1,
@@ -1446,6 +1495,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
}
template<typename _Tp1, typename _Ref, typename _Ptr, typename _Tp2>
+ _GLIBCXX26_CONSTEXPR
int
__lex_cmp_dit(
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref, _Ptr> __first1,
@@ -1487,6 +1537,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _Tp1, typename _Ref1, typename _Ptr1,
typename _Tp2>
+ _GLIBCXX20_CONSTEXPR
inline bool
__lexicographical_compare_aux1(
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1,
@@ -1496,6 +1547,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _Tp1,
typename _Tp2, typename _Ref2, typename _Ptr2>
+ _GLIBCXX20_CONSTEXPR
inline bool
__lexicographical_compare_aux1(_Tp1* __first1, _Tp1* __last1,
_GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2,
@@ -1504,6 +1556,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _Tp1, typename _Ref1, typename _Ptr1,
typename _Tp2, typename _Ref2, typename _Ptr2>
+ _GLIBCXX20_CONSTEXPR
inline bool
__lexicographical_compare_aux1(
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1,
diff --git a/libstdc++-v3/include/bits/stl_algobase.h
b/libstdc++-v3/include/bits/stl_algobase.h
index 3fdbff97353..a84a0705d53 100644
--- a/libstdc++-v3/include/bits/stl_algobase.h
+++ b/libstdc++-v3/include/bits/stl_algobase.h
@@ -348,6 +348,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
istreambuf_iterator<_CharT, char_traits<_CharT> >, _CharT*);
template<bool _IsMove, typename _CharT>
+ _GLIBCXX20_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_char<_CharT>::__value,
_GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type
@@ -465,6 +466,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _Tp, typename _Ref, typename _Ptr, typename _OI>
+ _GLIBCXX20_CONSTEXPR
_OI
__copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
@@ -472,12 +474,14 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _ITp, typename _IRef, typename _IPtr, typename _OTp>
+ _GLIBCXX20_CONSTEXPR
_GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
__copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr>,
_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr>,
_GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>);
template<bool _IsMove, typename _II, typename _Tp>
+ _GLIBCXX20_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_any_random_access_iter<_II>::__value,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type
@@ -529,7 +533,6 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wc++17-extensions" // for if-constexpr
template<typename _InputIterator, typename _Size, typename _OutputIterator>
- _GLIBCXX20_CONSTEXPR
_OutputIterator
__copy_n_a(_InputIterator __first, _Size __n, _OutputIterator __result,
bool)
@@ -601,6 +604,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
_Size, _CharT*, bool);
template<typename _CharT, typename _Size>
+ _GLIBCXX20_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_char<_CharT>::__value,
_GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type
@@ -753,6 +757,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _Tp, typename _Ref, typename _Ptr, typename _OI>
+ _GLIBCXX20_CONSTEXPR
_OI
__copy_move_backward_a1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
@@ -760,6 +765,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _ITp, typename _IRef, typename _IPtr, typename _OTp>
+ _GLIBCXX20_CONSTEXPR
_GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
__copy_move_backward_a1(
_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr>,
@@ -767,6 +773,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
_GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>);
template<bool _IsMove, typename _II, typename _Tp>
+ _GLIBCXX20_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_any_random_access_iter<_II>::__value,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type
@@ -960,6 +967,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
{ std::__fill_a1(__first.base(), __last.base(), __value); }
template<typename _Tp, typename _VTp>
+ _GLIBCXX20_CONSTEXPR
void
__fill_a1(const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>&,
const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>&,
@@ -1217,6 +1225,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
};
template<typename _Tp, typename _Ref, typename _Ptr, typename _II>
+ _GLIBCXX20_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_any_random_access_iter<_II>::__value, bool>::__type
__equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
@@ -1225,12 +1234,14 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _Tp1, typename _Ref1, typename _Ptr1,
typename _Tp2, typename _Ref2, typename _Ptr2>
+ _GLIBCXX20_CONSTEXPR
bool
__equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>,
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>,
_GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2>);
template<typename _II, typename _Tp, typename _Ref, typename _Ptr>
+ _GLIBCXX20_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_any_random_access_iter<_II>::__value, bool>::__type
__equal_aux1(_II, _II,
@@ -1436,6 +1447,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _Tp1, typename _Ref1, typename _Ptr1,
typename _Tp2>
+ _GLIBCXX20_CONSTEXPR
bool
__lexicographical_compare_aux1(
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>,
@@ -1444,6 +1456,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _Tp1,
typename _Tp2, typename _Ref2, typename _Ptr2>
+ _GLIBCXX20_CONSTEXPR
bool
__lexicographical_compare_aux1(_Tp1*, _Tp1*,
_GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2>,
@@ -1451,6 +1464,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _Tp1, typename _Ref1, typename _Ptr1,
typename _Tp2, typename _Ref2, typename _Ptr2>
+ _GLIBCXX20_CONSTEXPR
bool
__lexicographical_compare_aux1(
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>,
diff --git a/libstdc++-v3/include/bits/stl_deque.h
b/libstdc++-v3/include/bits/stl_deque.h
index c08212861b6..ba50795d46b 100644
--- a/libstdc++-v3/include/bits/stl_deque.h
+++ b/libstdc++-v3/include/bits/stl_deque.h
@@ -131,6 +131,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typedef __ptr_rebind<_Ptr, _Elt_pointer> _Map_pointer;
#endif
+ _GLIBCXX26_CONSTEXPR
static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT
{ return __deque_buf_size(sizeof(_Tp)); }
@@ -147,10 +148,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_Elt_pointer _M_last;
_Map_pointer _M_node;
+ _GLIBCXX26_CONSTEXPR
_Deque_iterator(_Elt_pointer __x, _Map_pointer __y) _GLIBCXX_NOEXCEPT
: _M_cur(__x), _M_first(*__y),
_M_last(*__y + _S_buffer_size()), _M_node(__y) { }
+ _GLIBCXX26_CONSTEXPR
_Deque_iterator() _GLIBCXX_NOEXCEPT
: _M_cur(), _M_first(), _M_last(), _M_node() { }
@@ -164,10 +167,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Iter,
typename = _Require<is_same<_Self, const_iterator>,
is_same<_Iter, iterator>>>
+ _GLIBCXX26_CONSTEXPR
_Deque_iterator(const _Iter& __x) noexcept
: _M_cur(__x._M_cur), _M_first(__x._M_first),
_M_last(__x._M_last), _M_node(__x._M_node) { }
+ _GLIBCXX26_CONSTEXPR
_Deque_iterator(const _Deque_iterator& __x) noexcept
: _M_cur(__x._M_cur), _M_first(__x._M_first),
_M_last(__x._M_last), _M_node(__x._M_node) { }
@@ -175,20 +180,24 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_Deque_iterator& operator=(const _Deque_iterator&) = default;
#endif
+ _GLIBCXX26_CONSTEXPR
iterator
_M_const_cast() const _GLIBCXX_NOEXCEPT
{ return iterator(_M_cur, _M_node); }
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
reference
operator*() const _GLIBCXX_NOEXCEPT
{ return *_M_cur; }
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
pointer
operator->() const _GLIBCXX_NOEXCEPT
{ return _M_cur; }
+ _GLIBCXX26_CONSTEXPR
_Self&
operator++() _GLIBCXX_NOEXCEPT
{
@@ -201,6 +210,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return *this;
}
+ _GLIBCXX26_CONSTEXPR
_Self
operator++(int) _GLIBCXX_NOEXCEPT
{
@@ -209,6 +219,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return __tmp;
}
+ _GLIBCXX26_CONSTEXPR
_Self&
operator--() _GLIBCXX_NOEXCEPT
{
@@ -221,6 +232,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return *this;
}
+ _GLIBCXX26_CONSTEXPR
_Self
operator--(int) _GLIBCXX_NOEXCEPT
{
@@ -229,6 +241,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return __tmp;
}
+ _GLIBCXX26_CONSTEXPR
_Self&
operator+=(difference_type __n) _GLIBCXX_NOEXCEPT
{
@@ -248,11 +261,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return *this;
}
+ _GLIBCXX26_CONSTEXPR
_Self&
operator-=(difference_type __n) _GLIBCXX_NOEXCEPT
{ return *this += -__n; }
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
reference
operator[](difference_type __n) const _GLIBCXX_NOEXCEPT
{ return *(*this + __n); }
@@ -262,6 +277,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* _M_cur, which should therefore be set by the caller
* immediately afterwards, based on _M_first and _M_last.
*/
+ _GLIBCXX26_CONSTEXPR
void
_M_set_node(_Map_pointer __new_node) _GLIBCXX_NOEXCEPT
{
@@ -271,6 +287,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
friend bool
operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_cur == __y._M_cur; }
@@ -280,6 +297,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// operators are in scope (for additional details, see libstdc++/3628)
template<typename _RefR, typename _PtrR>
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
friend bool
operator==(const _Self& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
@@ -288,6 +306,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cpp_lib_three_way_comparison
[[nodiscard]]
+ _GLIBCXX26_CONSTEXPR
friend strong_ordering
operator<=>(const _Self& __x, const _Self& __y) noexcept
{
@@ -369,6 +388,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#endif // three-way comparison
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
friend difference_type
operator-(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{
@@ -384,6 +404,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// parameters.
template<typename _RefR, typename _PtrR>
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
friend difference_type
operator-(const _Self& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
@@ -396,6 +417,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
friend _Self
operator+(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT
{
@@ -405,6 +427,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
friend _Self
operator-(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT
{
@@ -414,6 +437,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
friend _Self
operator+(difference_type __n, const _Self& __x) _GLIBCXX_NOEXCEPT
{ return __x + __n; }
@@ -451,6 +475,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typedef _Alloc allocator_type;
+ _GLIBCXX26_CONSTEXPR
allocator_type
get_allocator() const _GLIBCXX_NOEXCEPT
{ return allocator_type(_M_get_Tp_allocator()); }
@@ -458,23 +483,28 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typedef _Deque_iterator<_Tp, _Tp&, _Ptr> iterator;
typedef _Deque_iterator<_Tp, const _Tp&, _Ptr_const> const_iterator;
+ _GLIBCXX26_CONSTEXPR
_Deque_base()
: _M_impl()
{ _M_initialize_map(0); }
+ _GLIBCXX26_CONSTEXPR
_Deque_base(size_t __num_elements)
: _M_impl()
{ _M_initialize_map(__num_elements); }
+ _GLIBCXX26_CONSTEXPR
_Deque_base(const allocator_type& __a, size_t __num_elements)
: _M_impl(__a)
{ _M_initialize_map(__num_elements); }
+ _GLIBCXX26_CONSTEXPR
_Deque_base(const allocator_type& __a)
: _M_impl(__a)
{ /* Caller must initialize map. */ }
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
_Deque_base(_Deque_base&& __x)
: _M_impl(std::move(__x._M_get_Tp_allocator()))
{
@@ -483,10 +513,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
this->_M_impl._M_swap_data(__x._M_impl);
}
+ _GLIBCXX26_CONSTEXPR
_Deque_base(_Deque_base&& __x, const allocator_type& __a)
: _M_impl(std::move(__x._M_impl), _Tp_alloc_type(__a))
{ __x._M_initialize_map(0); }
+ _GLIBCXX26_CONSTEXPR
_Deque_base(_Deque_base&& __x, const allocator_type& __a, size_t __n)
: _M_impl(__a)
{
@@ -505,6 +537,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
#endif
+ _GLIBCXX26_CONSTEXPR
~_Deque_base() _GLIBCXX_NOEXCEPT;
typedef typename iterator::_Map_pointer _Map_pointer;
@@ -516,20 +549,25 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
iterator _M_start;
iterator _M_finish;
+ _GLIBCXX26_CONSTEXPR
_Deque_impl_data() _GLIBCXX_NOEXCEPT
: _M_map(), _M_map_size(), _M_start(), _M_finish()
{ }
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
_Deque_impl_data(const _Deque_impl_data&) = default;
+ _GLIBCXX26_CONSTEXPR
_Deque_impl_data&
operator=(const _Deque_impl_data&) = default;
+ _GLIBCXX26_CONSTEXPR
_Deque_impl_data(_Deque_impl_data&& __x) noexcept
: _Deque_impl_data(__x)
{ __x = _Deque_impl_data(); }
#endif
+ _GLIBCXX26_CONSTEXPR
void
_M_swap_data(_Deque_impl_data& __x) _GLIBCXX_NOEXCEPT
{
@@ -545,40 +583,49 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
struct _Deque_impl
: public _Tp_alloc_type, public _Deque_impl_data
{
+ _GLIBCXX26_CONSTEXPR
_Deque_impl() _GLIBCXX_NOEXCEPT_IF(
is_nothrow_default_constructible<_Tp_alloc_type>::value)
: _Tp_alloc_type()
{ }
+ _GLIBCXX26_CONSTEXPR
_Deque_impl(const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT
: _Tp_alloc_type(__a)
{ }
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
_Deque_impl(_Deque_impl&&) = default;
+ _GLIBCXX26_CONSTEXPR
_Deque_impl(_Tp_alloc_type&& __a) noexcept
: _Tp_alloc_type(std::move(__a))
{ }
+ _GLIBCXX26_CONSTEXPR
_Deque_impl(_Deque_impl&& __d, _Tp_alloc_type&& __a)
: _Tp_alloc_type(std::move(__a)), _Deque_impl_data(std::move(__d))
{ }
#endif
};
+ _GLIBCXX26_CONSTEXPR
_Tp_alloc_type&
_M_get_Tp_allocator() _GLIBCXX_NOEXCEPT
{ return this->_M_impl; }
+ _GLIBCXX26_CONSTEXPR
const _Tp_alloc_type&
_M_get_Tp_allocator() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl; }
+ _GLIBCXX26_CONSTEXPR
_Map_alloc_type
_M_get_map_allocator() const _GLIBCXX_NOEXCEPT
{ return _Map_alloc_type(_M_get_Tp_allocator()); }
+ _GLIBCXX26_CONSTEXPR
_Ptr
_M_allocate_node()
{
@@ -586,6 +633,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return _Traits::allocate(_M_impl, __deque_buf_size(sizeof(_Tp)));
}
+ _GLIBCXX26_CONSTEXPR
void
_M_deallocate_node(_Ptr __p) _GLIBCXX_NOEXCEPT
{
@@ -593,6 +641,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_Traits::deallocate(_M_impl, __p, __deque_buf_size(sizeof(_Tp)));
}
+ _GLIBCXX26_CONSTEXPR
_Map_pointer
_M_allocate_map(size_t __n)
{
@@ -600,6 +649,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return _Map_alloc_traits::allocate(__map_alloc, __n);
}
+ _GLIBCXX26_CONSTEXPR
void
_M_deallocate_map(_Map_pointer __p, size_t __n) _GLIBCXX_NOEXCEPT
{
@@ -607,8 +657,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_Map_alloc_traits::deallocate(__map_alloc, __p, __n);
}
+ _GLIBCXX26_CONSTEXPR
void _M_initialize_map(size_t);
+ _GLIBCXX26_CONSTEXPR
void _M_create_nodes(_Map_pointer __nstart, _Map_pointer __nfinish);
+ _GLIBCXX26_CONSTEXPR
void _M_destroy_nodes(_Map_pointer __nstart,
_Map_pointer __nfinish) _GLIBCXX_NOEXCEPT;
enum { _S_initial_map_size = 8 };
@@ -617,6 +670,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
};
template<typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
_Deque_base<_Tp, _Alloc>::
~_Deque_base() _GLIBCXX_NOEXCEPT
{
@@ -637,6 +691,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* The initial underlying memory layout is a bit complicated...
*/
template<typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
void
_Deque_base<_Tp, _Alloc>::
_M_initialize_map(size_t __num_elements)
@@ -676,6 +731,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template<typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
void
_Deque_base<_Tp, _Alloc>::
_M_create_nodes(_Map_pointer __nstart, _Map_pointer __nfinish)
@@ -694,6 +750,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template<typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
void
_Deque_base<_Tp, _Alloc>::
_M_destroy_nodes(_Map_pointer __nstart,
@@ -828,6 +885,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typedef _Alloc allocator_type;
private:
+ _GLIBCXX26_CONSTEXPR
static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT
{ return __deque_buf_size(sizeof(_Tp)); }
@@ -854,6 +912,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/**
* @brief Creates a %deque with no elements.
*/
+ _GLIBCXX26_CONSTEXPR
#if __cplusplus >= 201103L
deque() = default;
#else
@@ -864,6 +923,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @brief Creates a %deque with no elements.
* @param __a An allocator object.
*/
+ _GLIBCXX26_CONSTEXPR
explicit
deque(const allocator_type& __a)
: _Base(__a, 0) { }
@@ -877,6 +937,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* This constructor fills the %deque with @a n default
* constructed elements.
*/
+ _GLIBCXX26_CONSTEXPR
explicit
deque(size_type __n, const allocator_type& __a = allocator_type())
: _Base(__a, _S_check_init_len(__n, __a))
@@ -890,6 +951,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*
* This constructor fills the %deque with @a __n copies of @a __value.
*/
+ _GLIBCXX26_CONSTEXPR
deque(size_type __n, const value_type& __value,
const allocator_type& __a = allocator_type())
: _Base(__a, _S_check_init_len(__n, __a))
@@ -917,6 +979,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* The newly-created %deque uses a copy of the allocator object used
* by @a __x (unless the allocator traits dictate a different object).
*/
+ _GLIBCXX26_CONSTEXPR
deque(const deque& __x)
: _Base(_Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator()),
__x.size())
@@ -933,9 +996,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* The contents of the moved instance are a valid, but unspecified
* %deque.
*/
+ _GLIBCXX26_CONSTEXPR
deque(deque&&) = default;
/// Copy constructor with alternative allocator
+ _GLIBCXX26_CONSTEXPR
deque(const deque& __x, const __type_identity_t<allocator_type>& __a)
: _Base(__a, __x.size())
{ std::__uninitialized_copy_a(__x.begin(), __x.end(),
@@ -943,15 +1008,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_M_get_Tp_allocator()); }
/// Move constructor with alternative allocator
+ _GLIBCXX26_CONSTEXPR
deque(deque&& __x, const __type_identity_t<allocator_type>& __a)
: deque(std::move(__x), __a, typename _Alloc_traits::is_always_equal{})
{ }
private:
+ _GLIBCXX26_CONSTEXPR
deque(deque&& __x, const allocator_type& __a, true_type)
: _Base(std::move(__x), __a)
{ }
+ _GLIBCXX26_CONSTEXPR
deque(deque&& __x, const allocator_type& __a, false_type)
: _Base(std::move(__x), __a, __x.size())
{
@@ -976,6 +1044,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* This will call the element type's copy constructor N times
* (where N is __l.size()) and do no memory reallocation.
*/
+ _GLIBCXX26_CONSTEXPR
deque(initializer_list<value_type> __l,
const allocator_type& __a = allocator_type())
: _Base(__a)
@@ -1003,6 +1072,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
+ _GLIBCXX26_CONSTEXPR
deque(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type())
: _Base(__a)
@@ -1029,6 +1099,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @since C++23
*/
template<__detail::__container_compatible_range<_Tp> _Rg>
+ _GLIBCXX26_CONSTEXPR
deque(from_range_t, _Rg&& __rg, const allocator_type& __a = _Alloc())
: deque(__a)
{ append_range(std::forward<_Rg>(__rg)); }
@@ -1039,6 +1110,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* themselves are pointers, the pointed-to memory is not touched in any
* way. Managing the pointer is the user's responsibility.
*/
+ _GLIBCXX26_CONSTEXPR
~deque()
{ _M_destroy_data(begin(), end(), _M_get_Tp_allocator()); }
@@ -1051,6 +1123,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* The newly-created %deque uses a copy of the allocator object used
* by @a __x (unless the allocator traits dictate a different object).
*/
+ _GLIBCXX26_CONSTEXPR
deque&
operator=(const deque& __x);
@@ -1063,6 +1136,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* if the allocators permit it).
* @a __x is a valid, but unspecified %deque.
*/
+ _GLIBCXX26_CONSTEXPR
deque&
operator=(deque&& __x) noexcept(_Alloc_traits::_S_always_equal())
{
@@ -1082,6 +1156,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* resulting %deque's size is the same as the number of elements
* assigned.
*/
+ _GLIBCXX26_CONSTEXPR
deque&
operator=(initializer_list<value_type> __l)
{
@@ -1101,6 +1176,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* %deque and that the resulting %deque's size is the same as
* the number of elements assigned.
*/
+ _GLIBCXX26_CONSTEXPR
void
assign(size_type __n, const value_type& __val)
{ _M_fill_assign(__n, __val); }
@@ -1120,6 +1196,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
+ _GLIBCXX26_CONSTEXPR
void
assign(_InputIterator __first, _InputIterator __last)
{ _M_assign_aux(__first, __last, std::__iterator_category(__first)); }
@@ -1145,6 +1222,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* resulting %deque's size is the same as the number of elements
* assigned.
*/
+ _GLIBCXX26_CONSTEXPR
void
assign(initializer_list<value_type> __l)
{ _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); }
@@ -1199,6 +1277,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/// Get a copy of the memory allocation object.
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
allocator_type
get_allocator() const _GLIBCXX_NOEXCEPT
{ return _Base::get_allocator(); }
@@ -1209,6 +1288,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* %deque. Iteration is done in ordinary element order.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
iterator
begin() _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_start; }
@@ -1218,6 +1298,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* element in the %deque. Iteration is done in ordinary element order.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_start; }
@@ -1228,6 +1309,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* element order.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
iterator
end() _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_finish; }
@@ -1238,6 +1320,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* ordinary element order.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_finish; }
@@ -1248,6 +1331,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* element order.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(this->_M_impl._M_finish); }
@@ -1258,6 +1342,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* reverse element order.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(this->_M_impl._M_finish); }
@@ -1268,6 +1353,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* in reverse element order.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(this->_M_impl._M_start); }
@@ -1278,6 +1364,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* done in reverse element order.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(this->_M_impl._M_start); }
@@ -1288,6 +1375,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* element in the %deque. Iteration is done in ordinary element order.
*/
[[__nodiscard__]]
+ _GLIBCXX26_CONSTEXPR
const_iterator
cbegin() const noexcept
{ return this->_M_impl._M_start; }
@@ -1298,6 +1386,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* ordinary element order.
*/
[[__nodiscard__]]
+ _GLIBCXX26_CONSTEXPR
const_iterator
cend() const noexcept
{ return this->_M_impl._M_finish; }
@@ -1308,6 +1397,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* reverse element order.
*/
[[__nodiscard__]]
+ _GLIBCXX26_CONSTEXPR
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(this->_M_impl._M_finish); }
@@ -1318,6 +1408,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* done in reverse element order.
*/
[[__nodiscard__]]
+ _GLIBCXX26_CONSTEXPR
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(this->_M_impl._M_start); }
@@ -1326,6 +1417,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// [23.2.1.2] capacity
/** Returns the number of elements in the %deque. */
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
size_type
size() const _GLIBCXX_NOEXCEPT
{
@@ -1337,6 +1429,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/** Returns the size() of the largest possible %deque. */
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
size_type
max_size() const _GLIBCXX_NOEXCEPT
{ return _S_max_size(_M_get_Tp_allocator()); }
@@ -1351,6 +1444,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* %deque's current size the %deque is truncated, otherwise
* default constructed elements are appended.
*/
+ _GLIBCXX26_CONSTEXPR
void
resize(size_type __new_size)
{
@@ -1373,6 +1467,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* %deque is extended and new elements are populated with given
* data.
*/
+ _GLIBCXX26_CONSTEXPR
void
resize(size_type __new_size, const value_type& __x)
#else
@@ -1401,6 +1496,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
/** A non-binding request to reduce memory use. */
+ _GLIBCXX26_CONSTEXPR
void
shrink_to_fit() noexcept
{ _M_shrink_to_fit(); }
@@ -1410,7 +1506,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* Returns true if the %deque is empty. (Thus begin() would
* equal end().)
*/
- _GLIBCXX_NODISCARD bool
+ _GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
+ bool
empty() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_finish == this->_M_impl._M_start; }
@@ -1427,6 +1525,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* see at().)
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
reference
operator[](size_type __n) _GLIBCXX_NOEXCEPT
{
@@ -1446,6 +1545,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* see at().)
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_reference
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
{
@@ -1477,6 +1577,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* is first checked that it is in the range of the deque. The
* function throws out_of_range if the check fails.
*/
+ _GLIBCXX26_CONSTEXPR
reference
at(size_type __n)
{
@@ -1495,6 +1596,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* checked that it is in the range of the deque. The function throws
* out_of_range if the check fails.
*/
+ _GLIBCXX26_CONSTEXPR
const_reference
at(size_type __n) const
{
@@ -1507,6 +1609,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* element of the %deque.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
reference
front() _GLIBCXX_NOEXCEPT
{
@@ -1519,6 +1622,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* element of the %deque.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_reference
front() const _GLIBCXX_NOEXCEPT
{
@@ -1531,6 +1635,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* %deque.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
reference
back() _GLIBCXX_NOEXCEPT
{
@@ -1545,6 +1650,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* element of the %deque.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_reference
back() const _GLIBCXX_NOEXCEPT
{
@@ -1564,6 +1670,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* data to it. Due to the nature of a %deque this operation
* can be done in constant time.
*/
+ _GLIBCXX26_CONSTEXPR
void
push_front(const value_type& __x)
{
@@ -1579,12 +1686,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
void
push_front(value_type&& __x)
{ emplace_front(std::move(__x)); }
template<typename... _Args>
#if __cplusplus > 201402L
+ _GLIBCXX26_CONSTEXPR
reference
#else
void
@@ -1601,6 +1710,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* to it. Due to the nature of a %deque this operation can be
* done in constant time.
*/
+ _GLIBCXX26_CONSTEXPR
void
push_back(const value_type& __x)
{
@@ -1616,12 +1726,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
void
push_back(value_type&& __x)
{ emplace_back(std::move(__x)); }
template<typename... _Args>
#if __cplusplus > 201402L
+ _GLIBCXX26_CONSTEXPR
reference
#else
void
@@ -1637,6 +1749,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* Note that no data is returned, and if the first element's data is
* needed, it should be retrieved before pop_front() is called.
*/
+ _GLIBCXX26_CONSTEXPR
void
pop_front() _GLIBCXX_NOEXCEPT
{
@@ -1660,6 +1773,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* Note that no data is returned, and if the last element's data is
* needed, it should be retrieved before pop_back() is called.
*/
+ _GLIBCXX26_CONSTEXPR
void
pop_back() _GLIBCXX_NOEXCEPT
{
@@ -1686,6 +1800,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* with T(std::forward<Args>(args)...) before the specified location.
*/
template<typename... _Args>
+ _GLIBCXX26_CONSTEXPR
iterator
emplace(const_iterator __position, _Args&&... __args);
@@ -1698,6 +1813,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* This function will insert a copy of the given value before the
* specified location.
*/
+ _GLIBCXX26_CONSTEXPR
iterator
insert(const_iterator __position, const value_type& __x);
#else
@@ -1724,6 +1840,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* This function will insert a copy of the given rvalue before the
* specified location.
*/
+ _GLIBCXX26_CONSTEXPR
iterator
insert(const_iterator __position, value_type&& __x)
{ return emplace(__position, std::move(__x)); }
@@ -1738,6 +1855,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* initializer_list @a __l into the %deque before the location
* specified by @a __p. This is known as <em>list insert</em>.
*/
+ _GLIBCXX26_CONSTEXPR
iterator
insert(const_iterator __p, initializer_list<value_type> __l)
{
@@ -1757,6 +1875,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* This function will insert a specified number of copies of the given
* data before the location specified by @a __position.
*/
+ _GLIBCXX26_CONSTEXPR
iterator
insert(const_iterator __position, size_type __n, const value_type& __x)
{
@@ -1793,6 +1912,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
+ _GLIBCXX26_CONSTEXPR
iterator
insert(const_iterator __position, _InputIterator __first,
_InputIterator __last)
@@ -1834,6 +1954,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @since C++23
*/
template<__detail::__container_compatible_range<_Tp> _Rg>
+ _GLIBCXX26_CONSTEXPR
iterator
insert_range(const_iterator __pos, _Rg&& __rg);
@@ -1843,6 +1964,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @since C++23
*/
template<__detail::__container_compatible_range<_Tp> _Rg>
+ _GLIBCXX26_CONSTEXPR
void
prepend_range(_Rg&& __rg);
@@ -1852,6 +1974,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @since C++23
*/
template<__detail::__container_compatible_range<_Tp> _Rg>
+ _GLIBCXX26_CONSTEXPR
void
append_range(_Rg&& __rg);
#endif // containers_ranges
@@ -1871,6 +1994,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/
iterator
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
erase(const_iterator __position)
#else
erase(iterator __position)
@@ -1895,6 +2019,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/
iterator
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
erase(const_iterator __first, const_iterator __last)
#else
erase(iterator __first, iterator __last)
@@ -1912,6 +2037,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*
* Whether the allocators are swapped depends on the allocator traits.
*/
+ // TODO: I don't know if we should poke this.
+ _GLIBCXX26_CONSTEXPR
void
swap(deque& __x) _GLIBCXX_NOEXCEPT
{
@@ -1930,6 +2057,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* pointed-to memory is not touched in any way. Managing the pointer is
* the user's responsibility.
*/
+ _GLIBCXX26_CONSTEXPR
void
clear() _GLIBCXX_NOEXCEPT
{ _M_erase_at_end(begin()); }
@@ -1962,6 +2090,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
#endif
+ _GLIBCXX26_CONSTEXPR
static size_t
_S_check_init_len(size_t __n, const allocator_type& __a)
{
@@ -1971,6 +2100,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return __n;
}
+ _GLIBCXX26_CONSTEXPR
static size_type
_S_max_size(const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT
{
@@ -1992,12 +2122,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* push_back on each value from the iterator.
*/
template<typename _InputIterator>
+ _GLIBCXX26_CONSTEXPR
void
_M_range_initialize(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag);
// called by the second initialize_dispatch above
template<typename _ForwardIterator>
+ _GLIBCXX26_CONSTEXPR
void
_M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
std::forward_iterator_tag);
@@ -2013,11 +2145,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* This function is called only when the user provides an explicit size
* (with or without an explicit exemplar value).
*/
+ _GLIBCXX26_CONSTEXPR
void
_M_fill_initialize(const value_type& __value);
#if __cplusplus >= 201103L
// called by deque(n).
+ _GLIBCXX26_CONSTEXPR
void
_M_default_initialize();
#endif
@@ -2093,14 +2227,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
void _M_push_front_aux(const value_type&);
#else
template<typename... _Args>
+ _GLIBCXX26_CONSTEXPR
void _M_push_back_aux(_Args&&... __args);
template<typename... _Args>
+ _GLIBCXX26_CONSTEXPR
void _M_push_front_aux(_Args&&... __args);
#endif
+ _GLIBCXX26_CONSTEXPR
void _M_pop_back_aux();
+ _GLIBCXX26_CONSTEXPR
void _M_pop_front_aux();
///@}
@@ -2132,22 +2270,26 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// insert [__first, __last) at the front, assumes
distance(__first, __last) is n
template<typename _InputIterator, typename _Sentinel>
+ _GLIBCXX26_CONSTEXPR
void _M_range_prepend(_InputIterator __first, _Sentinel __last,
size_type __n);
// insert [__first, __last) at the back, assumes
distance(__first, __last) is n
template<typename _InputIterator, typename _Sentinel>
+ _GLIBCXX26_CONSTEXPR
void _M_range_append(_InputIterator __first, _Sentinel __last,
size_type __n);
// called by the second insert_dispatch above
template<typename _InputIterator>
+ _GLIBCXX26_CONSTEXPR
void
_M_range_insert_aux(iterator __pos, _InputIterator __first,
_InputIterator __last, std::input_iterator_tag);
// called by the second insert_dispatch above
template<typename _ForwardIterator>
+ _GLIBCXX26_CONSTEXPR
void
_M_range_insert_aux(iterator __pos, _ForwardIterator __first,
_ForwardIterator __last, std::forward_iterator_tag);
@@ -2155,6 +2297,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// Called by insert(p,n,x), and the range insert when it turns out to be
// the same thing. Can use fill functions in optimal situations,
// otherwise passes off to insert_aux(p,n,x).
+ _GLIBCXX26_CONSTEXPR
void
_M_fill_insert(iterator __pos, size_type __n, const value_type& __x);
@@ -2192,21 +2335,25 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
deque* _M_this;
};
+ _GLIBCXX26_CONSTEXPR
iterator
_M_insert_aux(iterator __pos, const value_type& __x)
{ return _M_emplace_aux(__pos, __x); }
template<typename... _Args>
+ _GLIBCXX26_CONSTEXPR
iterator
_M_emplace_aux(iterator __pos, _Args&&... __args);
#endif
// called by insert(p,n,x) via fill_insert
+ _GLIBCXX26_CONSTEXPR
void
_M_insert_aux(iterator __pos, size_type __n, const value_type& __x);
// called by range_insert_aux for forward iterators
template<typename _ForwardIterator>
+ _GLIBCXX26_CONSTEXPR
void
_M_insert_aux(iterator __pos,
_ForwardIterator __first, _ForwardIterator __last,
@@ -2215,16 +2362,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// Internal erase functions follow.
+ _GLIBCXX26_CONSTEXPR
void
_M_destroy_data_aux(iterator __first, iterator __last);
// Called by ~deque().
// NB: Doesn't deallocate the nodes.
template<typename _Alloc1>
+ _GLIBCXX26_CONSTEXPR
void
_M_destroy_data(iterator __first, iterator __last, const _Alloc1&)
{ _M_destroy_data_aux(__first, __last); }
+ _GLIBCXX26_CONSTEXPR
void
_M_destroy_data(iterator __first, iterator __last,
const std::allocator<_Tp>&)
@@ -2234,6 +2384,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
// Called by erase(q1, q2).
+ _GLIBCXX26_CONSTEXPR
void
_M_erase_at_begin(iterator __pos)
{
@@ -2244,6 +2395,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// Called by erase(q1, q2), resize(), clear(), _M_assign_aux,
// _M_fill_assign, operator=.
+ _GLIBCXX26_CONSTEXPR
void
_M_erase_at_end(iterator __pos)
{
@@ -2253,23 +2405,28 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
this->_M_impl._M_finish = __pos;
}
+ _GLIBCXX26_CONSTEXPR
iterator
_M_erase(iterator __pos);
+ _GLIBCXX26_CONSTEXPR
iterator
_M_erase(iterator __first, iterator __last);
#if __cplusplus >= 201103L
// Called by resize(sz).
+ _GLIBCXX26_CONSTEXPR
void
_M_default_append(size_type __n);
+ _GLIBCXX26_CONSTEXPR
bool
_M_shrink_to_fit();
#endif
///@{
/// Memory-handling helpers for the previous internal insert functions.
+ _GLIBCXX26_CONSTEXPR
iterator
_M_reserve_elements_at_front(size_type __n)
{
@@ -2280,6 +2437,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return this->_M_impl._M_start - difference_type(__n);
}
+ _GLIBCXX26_CONSTEXPR
iterator
_M_reserve_elements_at_back(size_type __n)
{
@@ -2290,9 +2448,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return this->_M_impl._M_finish + difference_type(__n);
}
+ _GLIBCXX26_CONSTEXPR
void
_M_new_elements_at_front(size_type __new_elements);
+ _GLIBCXX26_CONSTEXPR
void
_M_new_elements_at_back(size_type __new_elements);
///@}
@@ -2306,6 +2466,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* actually add the nodes. Can invalidate _M_map pointers.
* (And consequently, %deque iterators.)
*/
+ _GLIBCXX26_CONSTEXPR
void
_M_reserve_map_at_back(size_type __nodes_to_add = 1)
{
@@ -2314,6 +2475,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_M_reallocate_map(__nodes_to_add, false);
}
+ _GLIBCXX26_CONSTEXPR
void
_M_reserve_map_at_front(size_type __nodes_to_add = 1)
{
@@ -2322,6 +2484,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_M_reallocate_map(__nodes_to_add, true);
}
+ _GLIBCXX26_CONSTEXPR
void
_M_reallocate_map(size_type __nodes_to_add, bool __add_at_front);
///@}
@@ -2435,6 +2598,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/
template<typename _Tp, typename _Alloc>
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
inline bool
operator==(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
{ return __x.size() == __y.size()
@@ -2454,6 +2618,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/
template<typename _Tp, typename _Alloc>
[[nodiscard]]
+ constexpr
inline __detail::__synth3way_t<_Tp>
operator<=>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
{
@@ -2511,6 +2676,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/// See std::deque::swap().
template<typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
inline void
swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y)
_GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
diff --git a/libstdc++-v3/include/bits/stl_queue.h
b/libstdc++-v3/include/bits/stl_queue.h
index 48bd0ebed63..8d73db4b841 100644
--- a/libstdc++-v3/include/bits/stl_queue.h
+++ b/libstdc++-v3/include/bits/stl_queue.h
@@ -115,15 +115,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
template<typename _Tp1, typename _Seq1>
+ _GLIBCXX26_CONSTEXPR
friend bool
operator==(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
template<typename _Tp1, typename _Seq1>
+ _GLIBCXX26_CONSTEXPR
friend bool
operator<(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
#if __cpp_lib_three_way_comparison
template<typename _Tp1, three_way_comparable _Seq1>
+ _GLIBCXX26_CONSTEXPR
friend compare_three_way_result_t<_Seq1>
operator<=>(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
#endif
@@ -171,35 +174,43 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#else
template<typename _Seq = _Sequence, typename _Requires = typename
enable_if<is_default_constructible<_Seq>::value>::type>
+ _GLIBCXX26_CONSTEXPR
queue()
: c() { }
+ _GLIBCXX26_CONSTEXPR
explicit
queue(const _Sequence& __c)
: c(__c) { }
+ _GLIBCXX26_CONSTEXPR
explicit
queue(_Sequence&& __c)
: c(std::move(__c)) { }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
+ _GLIBCXX26_CONSTEXPR
explicit
queue(const _Alloc& __a)
: c(__a) { }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
+ _GLIBCXX26_CONSTEXPR
queue(const _Sequence& __c, const _Alloc& __a)
: c(__c, __a) { }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
+ _GLIBCXX26_CONSTEXPR
queue(_Sequence&& __c, const _Alloc& __a)
: c(std::move(__c), __a) { }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
+ _GLIBCXX26_CONSTEXPR
queue(const queue& __q, const _Alloc& __a)
: c(__q.c, __a) { }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
+ _GLIBCXX26_CONSTEXPR
queue(queue&& __q, const _Alloc& __a)
: c(std::move(__q.c), __a) { }
#endif
@@ -207,12 +218,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#ifdef __glibcxx_adaptor_iterator_pair_constructor // C++ >= 23 && HOSTED
template<typename _InputIterator,
typename = _RequireInputIter<_InputIterator>>
+ _GLIBCXX26_CONSTEXPR
queue(_InputIterator __first, _InputIterator __last)
: c(__first, __last) { }
template<typename _InputIterator, typename _Alloc,
typename = _RequireInputIter<_InputIterator>,
typename = _Uses<_Alloc>>
+ _GLIBCXX26_CONSTEXPR
queue(_InputIterator __first, _InputIterator __last, const _Alloc& __a)
: c(__first, __last, __a) { }
#endif
@@ -223,6 +236,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @since C++23
*/
template<__detail::__container_compatible_range<_Tp> _Rg>
+ _GLIBCXX26_CONSTEXPR
queue(from_range_t, _Rg&& __rg)
: c(ranges::to<_Sequence>(std::forward<_Rg>(__rg)))
{ }
@@ -233,6 +247,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
template<__detail::__container_compatible_range<_Tp> _Rg,
typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
queue(from_range_t, _Rg&& __rg, const _Alloc& __a)
: c(ranges::to<_Sequence>(std::forward<_Rg>(__rg), __a))
{ }
@@ -241,12 +256,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* Returns true if the %queue is empty.
*/
- _GLIBCXX_NODISCARD bool
+ _GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
+ bool
empty() const
{ return c.empty(); }
/** Returns the number of elements in the %queue. */
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
size_type
size() const
{ return c.size(); }
@@ -256,6 +274,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* element of the %queue.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
reference
front()
{
@@ -268,6 +287,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* element of the %queue.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_reference
front() const
{
@@ -280,6 +300,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* element of the %queue.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
reference
back()
{
@@ -292,6 +313,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* element of the %queue.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_reference
back() const
{
@@ -308,17 +330,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* to it. The time complexity of the operation depends on the
* underlying sequence.
*/
+ _GLIBCXX26_CONSTEXPR
void
push(const value_type& __x)
{ c.push_back(__x); }
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
void
push(value_type&& __x)
{ c.push_back(std::move(__x)); }
#if __cplusplus > 201402L
template<typename... _Args>
+ _GLIBCXX26_CONSTEXPR
decltype(auto)
emplace(_Args&&... __args)
{ return c.emplace_back(std::forward<_Args>(__args)...); }
@@ -332,6 +357,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __glibcxx_containers_ranges // C++ >= 23
template<__detail::__container_compatible_range<_Tp> _Rg>
+ _GLIBCXX26_CONSTEXPR
void
push_range(_Rg&& __rg)
{
@@ -353,6 +379,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* data is needed, it should be retrieved before pop() is
* called.
*/
+ _GLIBCXX26_CONSTEXPR
void
pop()
{
@@ -361,6 +388,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
void
swap(queue& __q)
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
@@ -430,6 +458,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
template<typename _Tp, typename _Seq>
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
inline bool
operator==(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return __x.c == __y.c; }
@@ -449,6 +478,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
template<typename _Tp, typename _Seq>
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
inline bool
operator<(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return __x.c < __y.c; }
@@ -456,6 +486,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Based on operator==
template<typename _Tp, typename _Seq>
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
inline bool
operator!=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return !(__x == __y); }
@@ -463,6 +494,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Based on operator<
template<typename _Tp, typename _Seq>
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
inline bool
operator>(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return __y < __x; }
@@ -470,6 +502,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Based on operator<
template<typename _Tp, typename _Seq>
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
inline bool
operator<=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return !(__y < __x); }
@@ -477,6 +510,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// Based on operator<
template<typename _Tp, typename _Seq>
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
inline bool
operator>=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return !(__x < __y); }
@@ -484,6 +518,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cpp_lib_three_way_comparison
template<typename _Tp, three_way_comparable _Seq>
[[nodiscard]]
+ _GLIBCXX26_CONSTEXPR
inline compare_three_way_result_t<_Seq>
operator<=>(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return __x.c <=> __y.c; }
@@ -491,6 +526,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus >= 201103L
template<typename _Tp, typename _Seq>
+ _GLIBCXX26_CONSTEXPR
inline
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
// Constrained free swap overload, see p0185r1
@@ -607,22 +643,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Seq = _Sequence, typename _Requires = typename
enable_if<__and_<is_default_constructible<_Compare>,
is_default_constructible<_Seq>>::value>::type>
+ _GLIBCXX26_CONSTEXPR
priority_queue()
: c(), comp() { }
+ _GLIBCXX26_CONSTEXPR
explicit
priority_queue(const _Compare& __x, const _Sequence& __s)
: c(__s), comp(__x)
{ std::make_heap(c.begin(), c.end(), comp); }
+ _GLIBCXX26_CONSTEXPR
explicit
priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence())
: c(std::move(__s)), comp(__x)
{ std::make_heap(c.begin(), c.end(), comp); }
+ _GLIBCXX26_CONSTEXPR
priority_queue(const priority_queue&) = default;
+ _GLIBCXX26_CONSTEXPR
priority_queue& operator=(const priority_queue&) = default;
+ _GLIBCXX26_CONSTEXPR
priority_queue(priority_queue&& __q)
noexcept(__and_<is_nothrow_move_constructible<_Sequence>,
is_nothrow_move_constructible<_Compare>>::value)
@@ -641,32 +683,38 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
+ _GLIBCXX26_CONSTEXPR
explicit
priority_queue(const _Alloc& __a)
: c(__a), comp() { }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
+ _GLIBCXX26_CONSTEXPR
priority_queue(const _Compare& __x, const _Alloc& __a)
: c(__a), comp(__x) { }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2537. Constructors [...] taking allocators should call make_heap
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
+ _GLIBCXX26_CONSTEXPR
priority_queue(const _Compare& __x, const _Sequence& __c,
const _Alloc& __a)
: c(__c, __a), comp(__x)
{ std::make_heap(c.begin(), c.end(), comp); }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
+ _GLIBCXX26_CONSTEXPR
priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a)
: c(std::move(__c), __a), comp(__x)
{ std::make_heap(c.begin(), c.end(), comp); }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
+ _GLIBCXX26_CONSTEXPR
priority_queue(const priority_queue& __q, const _Alloc& __a)
: c(__q.c, __a), comp(__q.comp) { }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
+ _GLIBCXX26_CONSTEXPR
priority_queue(priority_queue&& __q, const _Alloc& __a)
: c(std::move(__q.c), __a), comp(std::move(__q.comp))
{ __q.c.clear(); }
@@ -702,6 +750,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// 3529. priority_queue(first, last) should construct c with
(first, last)
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
+ _GLIBCXX26_CONSTEXPR
priority_queue(_InputIterator __first, _InputIterator __last,
const _Compare& __x = _Compare())
: c(__first, __last), comp(__x)
@@ -711,6 +760,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// 3522. Missing requirement on InputIterator template parameter
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
+ _GLIBCXX26_CONSTEXPR
priority_queue(_InputIterator __first, _InputIterator __last,
const _Compare& __x, const _Sequence& __s)
: c(__s), comp(__x)
@@ -722,6 +772,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
+ _GLIBCXX26_CONSTEXPR
priority_queue(_InputIterator __first, _InputIterator __last,
const _Compare& __x, _Sequence&& __s)
: c(std::move(__s)), comp(__x)
@@ -736,6 +787,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _InputIterator, typename _Alloc,
typename = std::_RequireInputIter<_InputIterator>,
typename _Requires = _Uses<_Alloc>>
+ _GLIBCXX26_CONSTEXPR
priority_queue(_InputIterator __first, _InputIterator __last,
const _Alloc& __alloc)
: c(__first, __last, __alloc), comp()
@@ -744,6 +796,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _InputIterator, typename _Alloc,
typename = std::_RequireInputIter<_InputIterator>,
typename _Requires = _Uses<_Alloc>>
+ _GLIBCXX26_CONSTEXPR
priority_queue(_InputIterator __first, _InputIterator __last,
const _Compare& __x, const _Alloc& __alloc)
: c(__first, __last, __alloc), comp(__x)
@@ -752,6 +805,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _InputIterator, typename _Alloc,
typename = std::_RequireInputIter<_InputIterator>,
typename _Requires = _Uses<_Alloc>>
+ _GLIBCXX26_CONSTEXPR
priority_queue(_InputIterator __first, _InputIterator __last,
const _Compare& __x, const _Sequence& __s,
const _Alloc& __alloc)
@@ -764,6 +818,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _InputIterator, typename _Alloc,
typename _Requires = _Uses<_Alloc>>
+ _GLIBCXX26_CONSTEXPR
priority_queue(_InputIterator __first, _InputIterator __last,
const _Compare& __x, _Sequence&& __s,
const _Alloc& __alloc)
@@ -783,18 +838,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @{
*/
template<__detail::__container_compatible_range<_Tp> _Rg>
+ _GLIBCXX26_CONSTEXPR
priority_queue(from_range_t, _Rg&& __rg,
const _Compare& __x = _Compare())
: c(ranges::to<_Sequence>(std::forward<_Rg>(__rg))), comp(__x)
{ std::make_heap(c.begin(), c.end(), comp); }
template<__detail::__container_compatible_range<_Tp> _Rg,
typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
priority_queue(from_range_t, _Rg&& __rg, const _Compare& __x,
const _Alloc& __a)
: c(ranges::to<_Sequence>(std::forward<_Rg>(__rg), __a)), comp(__x)
{ std::make_heap(c.begin(), c.end(), comp); }
template<__detail::__container_compatible_range<_Tp> _Rg,
typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
priority_queue(from_range_t, _Rg&& __rg, const _Alloc& __a)
: c(ranges::to<_Sequence>(std::forward<_Rg>(__rg), __a)), comp()
{ std::make_heap(c.begin(), c.end(), comp); }
@@ -804,12 +862,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* Returns true if the %queue is empty.
*/
- _GLIBCXX_NODISCARD bool
+ _GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
+ bool
empty() const
{ return c.empty(); }
/** Returns the number of elements in the %queue. */
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
size_type
size() const
{ return c.size(); }
@@ -819,6 +880,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* element of the %queue.
*/
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_reference
top() const
{
@@ -834,6 +896,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* The time complexity of the operation depends on the underlying
* sequence.
*/
+ _GLIBCXX26_CONSTEXPR
void
push(const value_type& __x)
{
@@ -842,6 +905,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
void
push(value_type&& __x)
{
@@ -850,6 +914,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename... _Args>
+ _GLIBCXX26_CONSTEXPR
void
emplace(_Args&&... __args)
{
@@ -860,6 +925,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __glibcxx_containers_ranges // C++ >= 23
template<__detail::__container_compatible_range<_Tp> _Rg>
+ _GLIBCXX26_CONSTEXPR
void
push_range(_Rg&& __rg)
{
@@ -882,6 +948,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* data is needed, it should be retrieved before pop() is
* called.
*/
+ _GLIBCXX26_CONSTEXPR
void
pop()
{
@@ -891,6 +958,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
void
swap(priority_queue& __pq)
noexcept(__and_<
@@ -959,6 +1027,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus >= 201103L
template<typename _Tp, typename _Sequence, typename _Compare>
+ _GLIBCXX26_CONSTEXPR
inline
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
// Constrained free swap overload, see p0185r1
diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h
b/libstdc++-v3/include/bits/stl_uninitialized.h
index 82e4ba2ff7b..af50649b3e2 100644
--- a/libstdc++-v3/include/bits/stl_uninitialized.h
+++ b/libstdc++-v3/include/bits/stl_uninitialized.h
@@ -975,6 +975,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Fills [first, last) with value_types constructed by the allocator
// alloc, with no arguments passed to the construct call.
template<typename _ForwardIterator, typename _Allocator>
+ _GLIBCXX26_CONSTEXPR
void
__uninitialized_default_a(_ForwardIterator __first,
_ForwardIterator __last,
@@ -990,6 +991,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if _GLIBCXX_HOSTED
template<typename _ForwardIterator, typename _Tp>
+ _GLIBCXX26_CONSTEXPR
inline void
__uninitialized_default_a(_ForwardIterator __first,
_ForwardIterator __last,
diff --git a/libstdc++-v3/include/bits/version.def
b/libstdc++-v3/include/bits/version.def
index c7709ba3a07..70c2af36e43 100644
--- a/libstdc++-v3/include/bits/version.def
+++ b/libstdc++-v3/include/bits/version.def
@@ -2317,6 +2317,22 @@ ftms = {
};
};
+ftms = {
+ name = constexpr_queue;
+ values = {
+ v = 202502;
+ cxxmin = 26;
+ };
+};
+
+ftms = {
+ name = constexpr_deque;
+ values = {
+ v = 202502;
+ cxxmin = 26;
+ };
+};
+
// Standard test specifications.
stds[97] = ">= 199711L";
stds[03] = ">= 199711L";
diff --git a/libstdc++-v3/include/bits/version.h
b/libstdc++-v3/include/bits/version.h
index c72cda506f1..89a9bfb7f9b 100644
--- a/libstdc++-v3/include/bits/version.h
+++ b/libstdc++-v3/include/bits/version.h
@@ -2596,4 +2596,24 @@
#endif /* !defined(__cpp_lib_contracts) */
#undef __glibcxx_want_contracts
+#if !defined(__cpp_lib_constexpr_queue)
+# if (__cplusplus > 202302L)
+# define __glibcxx_constexpr_queue 202502L
+# if defined(__glibcxx_want_all) || defined(__glibcxx_want_constexpr_queue)
+# define __cpp_lib_constexpr_queue 202502L
+# endif
+# endif
+#endif /* !defined(__cpp_lib_constexpr_queue) &&
defined(__glibcxx_want_constexpr_queue) */
+#undef __glibcxx_want_constexpr_queue
+
+#if !defined(__cpp_lib_constexpr_deque)
+# if (__cplusplus > 202302L)
+# define __glibcxx_constexpr_deque 202502L
+# if defined(__glibcxx_want_all) || defined(__glibcxx_want_constexpr_deque)
+# define __cpp_lib_constexpr_deque 202502L
+# endif
+# endif
+#endif /* !defined(__cpp_lib_constexpr_deque) &&
defined(__glibcxx_want_constexpr_deque) */
+#undef __glibcxx_want_constexpr_deque
+
#undef __glibcxx_want_all
diff --git a/libstdc++-v3/include/debug/deque b/libstdc++-v3/include/debug/deque
index 9fba4ffc499..789ceca4a54 100644
--- a/libstdc++-v3/include/debug/deque
+++ b/libstdc++-v3/include/debug/deque
@@ -106,32 +106,42 @@ namespace __debug
~deque() { }
#else
+ _GLIBCXX26_CONSTEXPR
deque() = default;
+ _GLIBCXX26_CONSTEXPR
deque(const deque&) = default;
+ _GLIBCXX26_CONSTEXPR
deque(deque&&) = default;
+ _GLIBCXX26_CONSTEXPR
deque(const deque& __d, const __type_identity_t<_Allocator>& __a)
: _Base(__d, __a) { }
+ _GLIBCXX26_CONSTEXPR
deque(deque&& __d, const __type_identity_t<_Allocator>& __a)
: _Safe(std::move(__d)), _Base(std::move(__d), __a) { }
+ _GLIBCXX26_CONSTEXPR
deque(initializer_list<value_type> __l,
const allocator_type& __a = allocator_type())
: _Base(__l, __a) { }
+ _GLIBCXX26_CONSTEXPR
~deque() = default;
#endif
+ _GLIBCXX26_CONSTEXPR
explicit
deque(const _Allocator& __a)
: _Base(__a) { }
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
explicit
deque(size_type __n, const _Allocator& __a = _Allocator())
: _Base(__n, __a) { }
+ _GLIBCXX26_CONSTEXPR
deque(size_type __n, const __type_identity_t<_Tp>& __value,
const _Allocator& __a = _Allocator())
: _Base(__n, __value, __a) { }
@@ -145,6 +155,7 @@ namespace __debug
#if __cplusplus >= 201103L
template<class _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
+ _GLIBCXX26_CONSTEXPR
#else
template<class _InputIterator>
#endif
@@ -157,21 +168,26 @@ namespace __debug
#if __glibcxx_containers_ranges // C++ >= 23
template<__detail::__container_compatible_range<_Tp> _Rg>
+ _GLIBCXX26_CONSTEXPR
deque(from_range_t, _Rg&& __rg, const _Allocator& __a = _Allocator())
: _Base(from_range, std::forward<_Rg>(__rg), __a)
{ }
#endif
+ _GLIBCXX26_CONSTEXPR
deque(_Base_ref __x)
: _Base(__x._M_ref) { }
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
deque&
operator=(const deque&) = default;
+ _GLIBCXX26_CONSTEXPR
deque&
operator=(deque&&) = default;
+ _GLIBCXX26_CONSTEXPR
deque&
operator=(initializer_list<value_type> __l)
{
@@ -184,6 +200,7 @@ namespace __debug
#if __cplusplus >= 201103L
template<class _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
+ _GLIBCXX26_CONSTEXPR
#else
template<class _InputIterator>
#endif
@@ -201,6 +218,7 @@ namespace __debug
this->_M_invalidate_all();
}
+ _GLIBCXX26_CONSTEXPR
void
assign(size_type __n, const _Tp& __t)
{
@@ -209,6 +227,7 @@ namespace __debug
}
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
void
assign(initializer_list<value_type> __l)
{
@@ -219,6 +238,7 @@ namespace __debug
#if __glibcxx_containers_ranges // C++ >= 23
template<std::__detail::__container_compatible_range<_Tp> _Rg>
+ _GLIBCXX26_CONSTEXPR
void
assign_range(_Rg&& __rg)
{
@@ -231,68 +251,81 @@ namespace __debug
// iterators:
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); }
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); }
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end(), this); }
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end(), this); }
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(end()); }
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(end()); }
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(begin()); }
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(begin()); }
#if __cplusplus >= 201103L
[[__nodiscard__]]
+ _GLIBCXX26_CONSTEXPR
const_iterator
cbegin() const noexcept
{ return const_iterator(_Base::begin(), this); }
[[__nodiscard__]]
+ _GLIBCXX26_CONSTEXPR
const_iterator
cend() const noexcept
{ return const_iterator(_Base::end(), this); }
[[__nodiscard__]]
+ _GLIBCXX26_CONSTEXPR
const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
[[__nodiscard__]]
+ _GLIBCXX26_CONSTEXPR
const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
#endif
private:
+ _GLIBCXX26_CONSTEXPR
void
_M_invalidate_after_nth(difference_type __n)
{
@@ -306,6 +339,7 @@ namespace __debug
using _Base::max_size;
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
void
resize(size_type __sz)
{
@@ -319,6 +353,7 @@ namespace __debug
this->_M_invalidate_all();
}
+ _GLIBCXX26_CONSTEXPR
void
resize(size_type __sz, const _Tp& __c)
{
@@ -347,6 +382,7 @@ namespace __debug
#endif
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
void
shrink_to_fit() noexcept
{
@@ -359,6 +395,7 @@ namespace __debug
// element access:
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
reference
operator[](size_type __n) _GLIBCXX_NOEXCEPT
{
@@ -367,6 +404,7 @@ namespace __debug
}
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_reference
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
{
@@ -377,6 +415,7 @@ namespace __debug
using _Base::at;
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
reference
front() _GLIBCXX_NOEXCEPT
{
@@ -385,6 +424,7 @@ namespace __debug
}
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_reference
front() const _GLIBCXX_NOEXCEPT
{
@@ -393,6 +433,7 @@ namespace __debug
}
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
reference
back() _GLIBCXX_NOEXCEPT
{
@@ -401,6 +442,7 @@ namespace __debug
}
_GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR
const_reference
back() const _GLIBCXX_NOEXCEPT
{
@@ -409,6 +451,7 @@ namespace __debug
}
// 23.2.1.3 modifiers:
+ _GLIBCXX26_CONSTEXPR
void
push_front(const _Tp& __x)
{
@@ -416,6 +459,7 @@ namespace __debug
this->_M_invalidate_all();
}
+ _GLIBCXX26_CONSTEXPR
void
push_back(const _Tp& __x)
{
@@ -424,16 +468,19 @@ namespace __debug
}
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
void
push_front(_Tp&& __x)
{ emplace_front(std::move(__x)); }
+ _GLIBCXX26_CONSTEXPR
void
push_back(_Tp&& __x)
{ emplace_back(std::move(__x)); }
template<typename... _Args>
#if __cplusplus > 201402L
+ _GLIBCXX26_CONSTEXPR
reference
#else
void
@@ -449,6 +496,7 @@ namespace __debug
template<typename... _Args>
#if __cplusplus > 201402L
+ _GLIBCXX26_CONSTEXPR
reference
#else
void
@@ -463,6 +511,7 @@ namespace __debug
}
template<typename... _Args>
+ _GLIBCXX26_CONSTEXPR
iterator
emplace(const_iterator __position, _Args&&... __args)
{
@@ -474,6 +523,7 @@ namespace __debug
}
#endif
+ _GLIBCXX26_CONSTEXPR
iterator
#if __cplusplus >= 201103L
insert(const_iterator __position, const _Tp& __x)
@@ -488,10 +538,12 @@ namespace __debug
}
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
iterator
insert(const_iterator __position, _Tp&& __x)
{ return emplace(__position, std::move(__x)); }
+ _GLIBCXX26_CONSTEXPR
iterator
insert(const_iterator __position, initializer_list<value_type> __l)
{
@@ -503,6 +555,7 @@ namespace __debug
#endif
#if __cplusplus >= 201103L
+ _GLIBCXX26_CONSTEXPR
iterator
insert(const_iterator __position, size_type __n, const _Tp& __x)
{
@@ -524,6 +577,7 @@ namespace __debug
#if __cplusplus >= 201103L
template<class _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
+ _GLIBCXX26_CONSTEXPR
iterator
insert(const_iterator __position,
_InputIterator __first, _InputIterator __last)
@@ -563,6 +617,7 @@ namespace __debug
#if __glibcxx_containers_ranges // C++ >= 23
template<__detail::__container_compatible_range<_Tp> _Rg>
+ _GLIBCXX26_CONSTEXPR
iterator
insert_range(const_iterator __pos, _Rg&& __rg)
{
@@ -572,6 +627,7 @@ namespace __debug
}
template<std::__detail::__container_compatible_range<_Tp> _Rg>
+ _GLIBCXX26_CONSTEXPR
void
prepend_range(_Rg&& __rg)
{
@@ -580,6 +636,7 @@ namespace __debug
}
template<std::__detail::__container_compatible_range<_Tp> _Rg>
+ _GLIBCXX26_CONSTEXPR
void
append_range(_Rg&& __rg)
{
@@ -588,6 +645,7 @@ namespace __debug
}
#endif
+ _GLIBCXX26_CONSTEXPR
void
pop_front() _GLIBCXX_NOEXCEPT
{
@@ -596,6 +654,7 @@ namespace __debug
_Base::pop_front();
}
+ _GLIBCXX26_CONSTEXPR
void
pop_back() _GLIBCXX_NOEXCEPT
{
@@ -604,6 +663,7 @@ namespace __debug
_Base::pop_back();
}
+ _GLIBCXX26_CONSTEXPR
iterator
#if __cplusplus >= 201103L
erase(const_iterator __position)
@@ -630,6 +690,7 @@ namespace __debug
}
}
+ _GLIBCXX26_CONSTEXPR
iterator
#if __cplusplus >= 201103L
erase(const_iterator __first, const_iterator __last)
@@ -677,6 +738,7 @@ namespace __debug
}
}
+ _GLIBCXX26_CONSTEXPR
void
swap(deque& __x)
_GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
@@ -685,6 +747,7 @@ namespace __debug
_Base::swap(__x);
}
+ _GLIBCXX26_CONSTEXPR
void
clear() _GLIBCXX_NOEXCEPT
{
@@ -692,9 +755,11 @@ namespace __debug
this->_M_invalidate_all();
}
+ _GLIBCXX26_CONSTEXPR
_Base&
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
+ _GLIBCXX26_CONSTEXPR
const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
};
@@ -722,6 +787,7 @@ namespace __debug
#endif
template<typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
inline bool
operator==(const deque<_Tp, _Alloc>& __lhs,
const deque<_Tp, _Alloc>& __rhs)
@@ -734,30 +800,35 @@ namespace __debug
{ return __x._M_base() <=> __y._M_base(); }
#else
template<typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
inline bool
operator!=(const deque<_Tp, _Alloc>& __lhs,
const deque<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() != __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
inline bool
operator<(const deque<_Tp, _Alloc>& __lhs,
const deque<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() < __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
inline bool
operator<=(const deque<_Tp, _Alloc>& __lhs,
const deque<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() <= __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
inline bool
operator>=(const deque<_Tp, _Alloc>& __lhs,
const deque<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() >= __rhs._M_base(); }
template<typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
inline bool
operator>(const deque<_Tp, _Alloc>& __lhs,
const deque<_Tp, _Alloc>& __rhs)
@@ -765,6 +836,7 @@ namespace __debug
#endif // three-way comparison
template<typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
inline void
swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
_GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
diff --git a/libstdc++-v3/include/std/deque b/libstdc++-v3/include/std/deque
index 3899b68e736..f68f57faf35 100644
--- a/libstdc++-v3/include/std/deque
+++ b/libstdc++-v3/include/std/deque
@@ -73,7 +73,7 @@
#define __glibcxx_want_algorithm_default_value_type
#define __glibcxx_want_allocator_traits_is_always_equal
-#define __glibcxx_want_containers_ranges
+#define __glibcxx_want_constexpr_deque
#define __glibcxx_want_erase_if
#define __glibcxx_want_nonmember_container_access
#include <bits/version.h>
@@ -102,12 +102,14 @@ namespace std _GLIBCXX_VISIBILITY(default)
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp, typename _Alloc, typename _Predicate>
+ _GLIBCXX26_CONSTEXPR
inline typename _GLIBCXX_STD_C::deque<_Tp, _Alloc>::size_type
erase_if(_GLIBCXX_STD_C::deque<_Tp, _Alloc>& __cont, _Predicate __pred)
{ return __detail::__erase_if(__cont, __cont, std::move(__pred)); }
template<typename _Tp, typename _Alloc,
typename _Up _GLIBCXX26_DEF_VAL_T(_Tp)>
+ _GLIBCXX26_CONSTEXPR
inline typename _GLIBCXX_STD_C::deque<_Tp, _Alloc>::size_type
erase(_GLIBCXX_STD_C::deque<_Tp, _Alloc>& __cont, const _Up& __value)
{ return std::erase_if(__cont, __gnu_cxx::__ops::__equal_to(__value)); }
diff --git a/libstdc++-v3/include/std/queue b/libstdc++-v3/include/std/queue
index 13e25482125..d6a14055a6a 100644
--- a/libstdc++-v3/include/std/queue
+++ b/libstdc++-v3/include/std/queue
@@ -63,6 +63,8 @@
#define __glibcxx_want_adaptor_iterator_pair_constructor
#define __glibcxx_want_containers_ranges
+#define __glibcxx_want_containers_constexpr
+#define __glibcxx_want_constexpr_queue
#include <bits/version.h>
#include <deque>
@@ -105,10 +107,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return _M_f.format(__a.c, __fc); }
private:
- // Standard uses formatter<ref_view<_Container>, _CharT>, but
range_formatter
- // provides same behavior.
- // _GLIBCXX_RESOLVE_LIB_DEFECTS
- // 3881. Incorrect formatting of container adapters backed by std::string
+ // Standard uses formatter<ref_view<_Container>, _CharT>.
range_formatter<_Tp, _CharT> _M_f;
};
@@ -147,10 +146,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return _M_f.format(__a.c, __fc); }
private:
- // Standard uses formatter<ref_view<_Container>, _CharT>, but
range_formatter
- // provides same behavior.
- // _GLIBCXX_RESOLVE_LIB_DEFECTS
- // 3881. Incorrect formatting of container adapters backed by std::string
+ // Standard uses formatter<ref_view<_Container>, _CharT>.
range_formatter<_Tp, _CharT> _M_f;
};
diff --git a/libstdc++-v3/testsuite/23_containers/deque/constexpr.cc
b/libstdc++-v3/testsuite/23_containers/deque/constexpr.cc
new file mode 100644
index 00000000000..25c5cd7025f
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/deque/constexpr.cc
@@ -0,0 +1,348 @@
+// { dg-do run { target c++26 } }
+// { dg-xfail-if "" { *-*-* } { "-D_GLIBCXX_DEBUG } { "" } }
+
+#include <deque>
+
+#ifndef __cpp_lib_constexpr_deque
+#error "Feature test macro for constexpr deque is missing in <deque>"
+#elif __cpp_lib_constexpr_deque != 202502L
+# error "Feature test macro for constexpr deque has wrong value in <deque>"
+#endif
+
+#include <ranges>
+#include <numeric>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+#include <testsuite_allocator.h>
+
+template<typename Alloc>
+constexpr bool ctor_tests()
+{
+
+ Alloc alloc;
+
+ std::deque<int> dq1 {};
+
+ std::deque<int, Alloc> dq2 (alloc);
+ std::deque<int, Alloc> dq3 (4, alloc);
+ VERIFY( dq3.front() == 0 );
+ VERIFY( dq3.size() == 4 );
+ std::deque<int, Alloc> dq4 (4, 5, alloc);
+ VERIFY( dq4.front() == 5 );
+ VERIFY( dq4.size() == 4 );
+
+ auto rg = {2, 3, 5, 7};
+ auto dq5 = std::deque(rg.begin(), rg.end());
+ VERIFY( dq5.front() == 2 );
+ VERIFY( dq5.back() == 7 );
+ VERIFY( dq5.size() == 4 );
+
+ auto dq6 = std::deque<int>(std::from_range, rg);
+ VERIFY(dq6 == dq5);
+
+ std::deque<int> dq7 (dq1);
+ VERIFY( dq7 == dq1 );
+ std::deque<int>dq8 (std::move(dq1));
+ VERIFY( dq8 == dq7 );
+
+ dq2.insert_range(dq2.begin(), rg);
+ std::deque<int, Alloc> dq9 (dq2, alloc);
+ std::deque<int, Alloc> dq10 (std::move(dq2), alloc);
+ VERIFY( dq9 == dq10 );
+ std::deque<int, Alloc> dq11 (rg, alloc);
+ VERIFY( dq11 == dq10 );
+
+ return true;
+}
+
+constexpr bool insert_tests()
+{
+ std::deque<int> dq1 {};
+
+ auto rg = {1, 2, 3, 4, 5};
+
+ dq1.insert(dq1.begin() , 1);
+ dq1.insert(dq1.end(), 2);
+ VERIFY( dq1.size() == 2 );
+ VERIFY( dq1.front() == 1 );
+ VERIFY( dq1.back() == 2 );
+
+ dq1.insert(dq1.end(), 1, 3);
+
+ dq1.insert(dq1.end(), rg.begin() + 3, rg.end());
+
+ VERIFY( dq1[0] == 1 );
+ VERIFY( dq1[1] == 2 );
+ VERIFY( dq1[2] == 3 );
+ VERIFY( dq1[3] == 4 );
+ VERIFY( dq1[4] == 5 );
+ dq1.clear();
+
+ dq1.insert(dq1.begin(), rg.begin(), rg.end());
+ VERIFY( dq1[0] == 1 );
+ VERIFY( dq1[1] == 2 );
+ VERIFY( dq1[2] == 3 );
+ VERIFY( dq1[3] == 4 );
+ VERIFY( dq1[4] == 5 );
+
+ dq1.insert_range(dq1.end(), rg);
+ VERIFY( dq1[5] == 1 );
+ VERIFY( dq1[6] == 2 );
+ VERIFY( dq1[7] == 3 );
+ VERIFY( dq1[8] == 4 );
+ VERIFY( dq1[9] == 5 );
+
+ std::deque<int> dq2 {2, 3, 5, 7};
+ dq2.erase(dq2.begin());
+ VERIFY( dq2.size() == 3 );
+ dq2.clear();
+ VERIFY( dq2.size() == 0);
+ VERIFY( dq2.empty() );
+
+ std::deque<int> dq3, dq4;
+ dq3.insert_range(dq3.begin(), rg);
+ dq4.append_range(rg);
+ VERIFY( dq3 == dq4 );
+ dq3.erase(dq3.begin(), dq3.end());
+ dq3.prepend_range(rg);
+ VERIFY( dq3 == dq4 );
+
+
+ struct S {
+ int foo;
+ constexpr S (int i, int j) : foo{i + j} {}
+ };
+ std::deque<S> dq5 {};
+ dq5.emplace(dq5.end(), 0, 1);
+ const S& s1 = dq5.emplace_back(1, 1);
+ const S& s2 = dq5.emplace_front(2, 1);
+ VERIFY( dq5.front().foo == 3 );
+ VERIFY( dq5.back().foo == 2 );
+ VERIFY( dq5[1].foo == 1 );
+
+ std::deque<int> dq6 {2, 3};
+ dq6.push_front(1);
+ dq6.push_back(4);
+ VERIFY( dq6.front() == 1);
+ VERIFY( dq6.back() == 4 );
+ dq6.pop_front();
+ dq6.pop_back();
+
+ std::deque<int> dq7 {1, 2};
+ dq7.resize(4);
+ VERIFY( dq7.back() == 0 );
+ dq7.resize(2);
+ VERIFY( dq7.front() == 1 );
+ VERIFY( dq7.back() == 2 );
+ dq7.clear();
+ dq7.resize(2);
+ VERIFY( dq7.front() == 0 );
+ VERIFY( dq7.back() == 0 );
+
+ std::deque<int> dq8 {1, 4};
+ dq8.swap(dq6);
+ VERIFY( dq6.front() == 1 );
+ VERIFY( dq6.back() == 4 );
+ VERIFY( dq8.front() == 2 );
+ VERIFY( dq8.back() == 3 );
+
+ return true;
+}
+
+constexpr bool iterators_tests()
+{
+ std::deque<int> dq0 {};
+ VERIFY( dq0.begin() == dq0.end() );
+ dq0.resize(1);
+ VERIFY( dq0.begin() != dq0.end() );
+ dq0.resize(2);
+ VERIFY( dq0.begin() != dq0.end() );
+ VERIFY( dq0.cbegin() == dq0.begin() );
+ VERIFY( dq0.crbegin() == dq0.rbegin() );
+ VERIFY( dq0.cend() == dq0.end() );
+ VERIFY( dq0.crend() == dq0.rend() );
+
+ auto it = dq0.begin();
+ VERIFY( it[0] == 0 );
+ VERIFY( &*it == &dq0.front() );
+ VERIFY( &it[1] == &dq0[1] );
+ VERIFY( it++ == dq0.begin() );
+ VERIFY( ++it == dq0.end() );
+ VERIFY( (it - 2) == dq0.begin() );
+ VERIFY( (it - dq0.begin()) == 2 );
+ it -= 2;
+ it += 1;
+ VERIFY( (it + 1) == dq0.end() );
+ VERIFY( (1 + it) == dq0.end() );
+ it = it + 1;
+ auto it2 = dq0.begin();
+ std::swap(it, it2);
+ VERIFY( it == dq0.begin() );
+ VERIFY( it2 == dq0.end() );
+
+ auto rit = dq0.rbegin();
+ VERIFY( rit[0] == 0 );
+ VERIFY( &*rit == &dq0.back() );
+ VERIFY( &rit[1] == &dq0[0] );
+ VERIFY( rit++ == dq0.rbegin() );
+ VERIFY( ++rit == dq0.rend() );
+ VERIFY( (rit - 2) == dq0.rbegin() );
+ VERIFY( (rit - dq0.rbegin()) == 2 );
+ rit -= 2;
+ rit += 1;
+ VERIFY( (rit + 1) == dq0.rend() );
+ VERIFY( (1 + rit) == dq0.rend() );
+ rit = rit + 1;
+ auto rit2 = dq0.rbegin();
+ std::swap(rit, rit2);
+ VERIFY( rit == dq0.rbegin() );
+ VERIFY( rit2 == dq0.rend() );
+
+ return true;
+}
+
+constexpr bool capacity_tests()
+{
+ std::deque<int> dq0 {};
+ VERIFY( dq0.empty() );
+ VERIFY( dq0.max_size() );
+ dq0.push_front(0);
+ VERIFY( dq0.size() == 1 );
+ dq0.erase(dq0.begin());
+ dq0.shrink_to_fit();
+
+ return true;
+}
+
+constexpr bool nonmember_tests()
+{
+ std::deque<int> dq0 {0, 1};
+ std::deque<int> dq1 {0, 1};
+
+ VERIFY( (dq0 == dq1) == true );
+ VERIFY( (dq0 != dq1) == false );
+ VERIFY( (dq0 <= dq1) == true );
+ VERIFY( (dq0 >= dq1) == true );
+ VERIFY( (dq0 < dq1) == false );
+ VERIFY( (dq0 > dq1) == false );
+ VERIFY( (dq0 <=> dq1) == 0 );
+ VERIFY( (dq0 <=> dq1) <= 0 );
+ VERIFY( (dq0 <=> dq1) >= 0 );
+
+ std::deque<int> dq2 {2, 4};
+ std::swap(dq1, dq2);
+
+ VERIFY( (dq0 == dq1) == false );
+ VERIFY( (dq0 != dq1) == true );
+ VERIFY( (dq0 <= dq1) == true );
+ VERIFY( (dq0 >= dq1) == false );
+ VERIFY( (dq0 < dq1) == true );
+ VERIFY( (dq0 > dq1) == false );
+ VERIFY( (dq0 <=> dq1) != 0 );
+ VERIFY( (dq0 <=> dq1) <= 0 );
+ VERIFY( (dq0 <=> dq1) < 0 );
+
+ std::erase(dq0, 0);
+ VERIFY( dq0.front() == 1 );
+
+ std::erase_if(dq1, [](int x) { return x % 2 == 0; });
+ VERIFY( dq1.empty() );
+ return true;
+}
+
+template<typename Range>
+constexpr void
+ranges_test()
+{
+ using Tp = std::ranges::range_value_t<Range>;
+ Tp a[] {0, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9};
+
+ // Constructor tests
+ auto dq1 = std::deque<Tp>(std::from_range, Range(a, a+5));
+ VERIFY( dq1[0] == 0 );
+ VERIFY( dq1[1] == 1 );
+ VERIFY( dq1[2] == 2 );
+ VERIFY( dq1[3] == 3 );
+ VERIFY( dq1[4] == 4 );
+
+ // Insert tests
+ std::deque<Tp> dq2 {};
+ dq2.insert_range(dq2.begin(), Range(a, a+5));
+ VERIFY( dq2[0] == 0 );
+ VERIFY( dq2[1] == 1 );
+ VERIFY( dq2[2] == 2 );
+ VERIFY( dq2[3] == 3 );
+ VERIFY( dq2[4] == 4 );
+
+ std::deque<Tp> dq3;
+ dq3.assign_range(Range(a, a+5));
+ VERIFY( dq2 == dq3 );
+
+ dq2.insert_range(dq2.end(), Range(a+5, a+10));
+ VERIFY( dq2[5] == 5 );
+ VERIFY( dq2[6] == 6 );
+ VERIFY( dq2[7] == 7 );
+ VERIFY( dq2[8] == 8 );
+ VERIFY( dq2[9] == 9 );
+
+ std::deque<Tp> dq4 {};
+ dq4.prepend_range(Range(a, a+5));
+ dq4.append_range(Range(a+5, a+10));
+ VERIFY( dq2 == dq4 );
+}
+
+constexpr void do_ranges_tests()
+{
+ using namespace __gnu_test;
+ ranges_test<test_forward_range<int>>();
+ ranges_test<test_forward_sized_range<int>>();
+ ranges_test<test_sized_range_sized_sent<int, forward_iterator_wrapper>>();
+
+ ranges_test<test_input_range<int>>();
+ ranges_test<test_input_sized_range<int>>();
+ ranges_test<test_sized_range_sized_sent<int, input_iterator_wrapper>>();
+
+ ranges_test<test_range<int, input_iterator_wrapper_nocopy>>();
+ ranges_test<test_sized_range<int, input_iterator_wrapper_nocopy>>();
+ ranges_test<test_sized_range_sized_sent<int,
input_iterator_wrapper_nocopy>>();
+
+ ranges_test<test_forward_range<short>>();
+ ranges_test<test_input_range<short>>();
+
+ //TODO: this probably needs to be converted to be proper. Needs to
be r-values?
+ struct C {
+ constexpr C(int v) : val(v) { }
+ constexpr operator int() { return val; }
+ constexpr bool operator==(int b) { return b == val; }
+ constexpr bool operator!=(int b) { return b != val; }
+ int val;
+ };
+ using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
+ ranges_test<rvalue_input_range>();
+}
+
+constexpr void do_ctor_tests()
+{
+ using namespace __gnu_test;
+ ctor_tests<std::allocator<int>>();
+ ctor_tests<SimpleAllocator<int>>();
+}
+
+constexpr bool do_tests()
+{
+ do_ctor_tests();
+ insert_tests();
+ iterators_tests();
+ capacity_tests();
+ nonmember_tests();
+ // Additional code coverage
+ do_ranges_tests();
+ return true;
+}
+
+int main ()
+{
+ do_tests();
+ static_assert( do_tests() );
+}
diff --git a/libstdc++-v3/testsuite/23_containers/deque/debug/constexpr.cc
b/libstdc++-v3/testsuite/23_containers/deque/debug/constexpr.cc
new file mode 100644
index 00000000000..0a9552325a1
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/deque/debug/constexpr.cc
@@ -0,0 +1,361 @@
+// { dg-do run { target c++26 } }
+// { dg-xfail-if "" { *-*-* } { "-D_GLIBCXX_DEBUG } { "" } }
+// { dg-require-debug-mode "" }
+
+#include <debug/deque>
+
+#ifndef __cpp_lib_constexpr_deque
+#error "Feature test macro for constexpr deque is missing in <deque>"
+#elif __cpp_lib_constexpr_deque != 202502L
+# error "Feature test macro for constexpr deque has wrong value in <deque>"
+#endif
+
+#include <ranges>
+#include <numeric>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+
+constexpr bool ctor_tests()
+{
+
+ using Alloc = __gnu_test::SimpleAllocator<int>;
+ Alloc alloc;
+
+ std::deque<int> dq1 {};
+
+ std::deque<int, Alloc> dq2 (alloc);
+ std::deque<int, Alloc> dq3 (4, alloc);
+ VERIFY( dq3.front() == 0 );
+ VERIFY( dq3.size() == 4 );
+ std::deque<int, Alloc> dq4 (4, 5, alloc);
+ VERIFY( dq3.front() == 5 );
+ VERIFY( dq3.size() == 4 );
+
+ auto rg = {2, 3, 5, 7};
+ auto dq5 = std::deque(rg.begin(), rg.end());
+ VERIFY( dq5.front() == 2 );
+ VERIFY( dq5.back() == 7 );
+ VERIFY( dq5.size() == 5 );
+
+ auto dq6 = std::deque<int>(std::from_range, rg);
+ VERIFY(dq6 == dq5);
+
+ std::deque<int> dq7 (dq1);
+ VERIFY( dq7 == dq1 );
+ std::deque<int>dq8 (std::move(dq1));
+ VERIFY( dq8 == dq7 );
+
+ std::deque<int, Alloc> dq9 (dq1, alloc);
+ std::deque<int, Alloc> dq10 (std::move(dq1), alloc);
+ VERIFY ( dq9 == dq10 );
+ std::deque<int, Alloc> dq11 (rg, alloc);
+ VERIFY( dq11 == dq5 );
+
+ return true;
+}
+
+static_assert(ctor_tests());
+
+constexpr bool insert_tests()
+{
+ std::deque<int> dq1 {};
+
+ auto rg = {1, 2, 3, 4, 5};
+
+ dq1.insert(dq1.begin() , 1);
+ dq1.insert(dq1.end(), 2);
+ VERIFY( dq1.size() == 2 );
+ VERIFY( dq1.front() == 1 );
+ VERIFY( dq1.back() == 2 );
+
+ dq1.insert(dq1.end(), 1, 3);
+
+ dq1.insert(dq1.end(), rg.begin() + 3, rg.end());
+
+ VERIFY( dq1[0] == 1 );
+ VERIFY( dq1[1] == 2 );
+ VERIFY( dq1[2] == 3 );
+ VERIFY( dq1[3] == 4 );
+ VERIFY( dq1[4] == 5 );
+ dq1.clear();
+
+ dq1.insert(dq1.begin(), rg.begin(), rg.end());
+ VERIFY( dq1[0] == 1 );
+ VERIFY( dq1[1] == 2 );
+ VERIFY( dq1[2] == 3 );
+ VERIFY( dq1[3] == 4 );
+ VERIFY( dq1[4] == 5 );
+
+ dq1.insert_range(dq1.end(), rg);
+ VERIFY( dq1[5] == 1 );
+ VERIFY( dq1[6] == 2 );
+ VERIFY( dq1[7] == 3 );
+ VERIFY( dq1[8] == 4 );
+ VERIFY( dq1[9] == 5 );
+
+ std::deque<int> dq2 {2, 3, 5, 7};
+ dq2.erase(dq2.begin());
+ VERIFY( dq2.size() == 3 );
+ dq2.clear();
+ VERIFY( dq2.size() == 0);
+ VERIFY( dq2.empty() );
+
+ std::deque<int> dq3, dq4;
+ dq3.insert_range(dq3.begin(), rg);
+ dq4.append_range(rg);
+ VERIFY( dq3 == dq4 );
+ dq3.erase(dq3.begin(), dq3.end());
+ dq3.prepend_range(rg);
+ VERIFY( dq3 == dq4 );
+
+
+ struct S {
+ int foo;
+ constexpr S (int i, int j) : foo{i + j} {}
+ };
+ std::deque<S> dq5 {};
+ dq5.emplace(dq5.end(), 0, 1);
+ const S& s1 = dq5.emplace_back(1, 1);
+ const S& s2 = dq5.emplace_front(2, 1);
+ VERIFY( dq5.front().foo == 3 );
+ VERIFY( dq5.back().foo == 2 );
+ VERIFY( dq5[1].foo == 1 );
+
+ std::deque<int> dq6 {2, 3};
+ dq6.push_front(1);
+ dq6.push_back(4);
+ VERIFY( dq6.front() == 1);
+ VERIFY( dq6.back() == 4 );
+ dq6.pop_front();
+ dq6.pop_back();
+
+ std::deque<int> dq7 {1, 2};
+ dq7.resize(4);
+ VERIFY( dq7.back() == 0 );
+ dq7.resize(2);
+ VERIFY( dq7.front() == 1 );
+ VERIFY( dq7.back() == 2 );
+ dq7.clear();
+ dq7.resize(2);
+ VERIFY( dq7.front() == 0 );
+ VERIFY( dq7.back() == 0 );
+
+ std::deque<int> dq8 {1, 4};
+ dq8.swap(dq6);
+ VERIFY( dq6.front() == 1 );
+ VERIFY( dq6.back() == 4 );
+ VERIFY( dq8.front() == 2 );
+ VERIFY( dq8.back() == 3 );
+
+ return true;
+}
+
+static_assert(insert_tests());
+
+constexpr bool iterators_tests()
+{
+ std::deque<int> dq0 {};
+ VERIFY( dq0.begin() == dq0.end() );
+ dq0.resize(1);
+ VERIFY( dq0.begin() != dq0.end() );
+ dq0.resize(2);
+ VERIFY( dq0.begin() != dq0.end() );
+ VERIFY( dq0.cbegin() == dq0.begin() );
+ VERIFY( dq0.crbegin() == dq0.rbegin() );
+ VERIFY( dq0.cend() == dq0.end() );
+ VERIFY( dq0.crend() == dq0.rend() );
+
+ auto it = dq0.begin();
+ VERIFY( it[0] == 0 );
+ VERIFY( &*it == &dq0.front() );
+ VERIFY( &it[1] == &dq0[1] );
+ VERIFY( it++ == dq0.begin() );
+ VERIFY( ++it == dq0.end() );
+ VERIFY( (it - 2) == dq0.begin() );
+ VERIFY( (it - dq0.begin()) == 2 );
+ it -= 2;
+ it += 1;
+ VERIFY( (it + 1) == dq0.end() );
+ VERIFY( (1 + it) == dq0.end() );
+ it = it + 1;
+ auto it2 = dq0.begin();
+ std::swap(it, it2);
+ VERIFY( it == dq0.begin() );
+ VERIFY( it2 == dq0.end() );
+
+ auto rit = dq0.rbegin();
+ VERIFY( rit[0] == 0 );
+ VERIFY( &*rit == &dq0.back() );
+ VERIFY( &rit[1] == &dq0[0] );
+ VERIFY( rit++ == dq0.rbegin() );
+ VERIFY( ++rit == dq0.rend() );
+ VERIFY( (rit - 2) == dq0.rbegin() );
+ VERIFY( (rit - dq0.rbegin()) == 2 );
+ rit -= 2;
+ rit += 1;
+ VERIFY( (rit + 1) == dq0.rend() );
+ VERIFY( (1 + rit) == dq0.rend() );
+ rit = rit + 1;
+ auto rit2 = dq0.rbegin();
+ std::swap(rit, rit2);
+ VERIFY( rit == dq0.rbegin() );
+ VERIFY( rit2 == dq0.rend() );
+
+ return true;
+}
+
+static_assert(iterators_tests());
+
+constexpr bool capacity_tests()
+{
+ std::deque<int> dq0 {};
+ VERIFY( dq0.empty() );
+ VERIFY( dq0.max_size() );
+ dq0.push_front(0);
+ VERIFY( dq0.size() == 1 );
+ dq0.erase(dq0.begin());
+ dq0.shrink_to_fit();
+
+ return true;
+}
+
+static_assert(capacity_tests());
+
+constexpr bool nonmember_tests()
+{
+ std::deque<int> dq0 {0, 1};
+ std::deque<int> dq1 {0, 1};
+
+ VERIFY( (dq0 == dq1) == true );
+ VERIFY( (dq0 != dq1) == false );
+ VERIFY( (dq0 <= dq1) == true );
+ VERIFY( (dq0 >= dq1) == true );
+ VERIFY( (dq0 < dq1) == false );
+ VERIFY( (dq0 > dq1) == false );
+ VERIFY( (dq0 <=> dq1) == 0 );
+ VERIFY( (dq0 <=> dq1) <= 0 );
+ VERIFY( (dq0 <=> dq1) >= 0 );
+
+ std::deque<int> dq2 {2, 4};
+ std::swap(dq1, dq2);
+
+ VERIFY( (dq0 == dq1) == false );
+ VERIFY( (dq0 != dq1) == true );
+ VERIFY( (dq0 <= dq1) == true );
+ VERIFY( (dq0 >= dq1) == false );
+ VERIFY( (dq0 < dq1) == true );
+ VERIFY( (dq0 > dq1) == false );
+ VERIFY( (dq0 <=> dq1) != 0 );
+ VERIFY( (dq0 <=> dq1) <= 0 );
+ VERIFY( (dq0 <=> dq1) < 0 );
+
+ std::erase(dq0, 0);
+ VERIFY( dq0.front() == 1 );
+
+ std::erase_if(dq1, [](int x) { return x % 2 == 0; });
+ VERIFY( dq1.empty() );
+ return true;
+}
+
+static_assert(nonmember_tests());
+
+template<Range>
+constexpr void
+ranges_test()
+{
+ using Tp = std::ranges::range_value_t<Range>;
+ Range rg [] {2, 3, 5, 7}; //TODO: is this optimally clean?
+
+ // Constructor tests
+
+ auto dq0 = std::deque(rg.begin(), rg.end());
+ VERIFY( dq0.front() == 2 );
+ VERIFY( dq0.back() == 7 );
+ VERIFY( dq0.size() == 5 );
+
+ auto dq1 = std::deque<int>(std::from_range, rg);
+ VERIFY(dq1 == dq0);
+
+ // Insert tests
+
+ rg = {1, 2, 3, 4, 5};
+
+ std::deque<int> dq1;
+ dq1.insert(dq1.begin() , 1);
+ dq1.insert(dq1.end(), 2);
+ VERIFY( dq1.size() == 2 );
+ VERIFY( dq1.front() == 1 );
+ VERIFY( dq1.back() == 2 );
+
+ dq1.insert(dq1.end(), 1, 3);
+
+ dq1.insert(dq1.end(), rg.begin() + 3, rg.end());
+
+ VERIFY( dq1[0] == 1 );
+ VERIFY( dq1[1] == 2 );
+ VERIFY( dq1[2] == 3 );
+ VERIFY( dq1[3] == 4 );
+ VERIFY( dq1[4] == 5 );
+ dq1.clear();
+
+ dq1.insert(dq1.begin(), rg.begin(), rg.end());
+ VERIFY( dq1[0] == 1 );
+ VERIFY( dq1[1] == 2 );
+ VERIFY( dq1[2] == 3 );
+ VERIFY( dq1[3] == 4 );
+ VERIFY( dq1[4] == 5 );
+
+ dq1.insert_range(dq1.end(), rg);
+ VERIFY( dq1[5] == 1 );
+ VERIFY( dq1[6] == 2 );
+ VERIFY( dq1[7] == 3 );
+ VERIFY( dq1[8] == 4 );
+ VERIFY( dq1[9] == 5 );
+
+ std::deque<int> dq3, dq4;
+ dq3.insert_range(dq3.begin(), rg);
+ dq4.append_range(rg);
+ VERIFY( dq3 == dq4 );
+ dq3.erase(dq3.begin(), dq3.end());
+ dq3.prepend_range(rg);
+ VERIFY( dq3 == dq4 );
+}
+
+constexpr bool do_tests()
+{
+ using namespace __gnu_test;
+ ranges_test<foo>(bar); // TODO:
+
+ ranges_test<test_forward_range<int>>();
+ ranges_test<test_forward_sized_range<int>>();
+ ranges_test<test_sized_range_sized_sent<int, forward_iterator_wrapper>>();
+
+ ranges_test<test_input_range<int>>();
+ ranges_test<test_input_sized_range<int>>();
+ ranges_test<test_sized_range_sized_sent<int, input_iterator_wrapper>>();
+
+ ranges_test<test_range<int, input_iterator_wrapper_nocopy>>();
+ ranges_test<test_sized_range<int, input_iterator_wrapper_nocopy>>();
+ ranges_test<test_sized_range_sized_sent<int,
input_iterator_wrapper_nocopy>>();
+
+ ranges_test<test_forward_range<short>>();
+ ranges_test<test_input_range<short>>();
+
+ struct C {
+ constexpr C(int v) : val(v) { }
+ constexpr operator int() && { return val; }
+ constexpr bool operator==(int b) const { return b == val; }
+ int val;
+ };
+ using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
+ ranges_test<rvalue_input_range>();
+
+ ctor_tests();
+ insert_tests();
+ iterators_tests();
+ capacity_tests();
+ nonmember_tests();
+ return true;
+}
+
+static_assert( do_tests() );
diff --git a/libstdc++-v3/testsuite/23_containers/priority_queue/constexpr.cc
b/libstdc++-v3/testsuite/23_containers/priority_queue/constexpr.cc
new file mode 100644
index 00000000000..de1ba25a420
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/priority_queue/constexpr.cc
@@ -0,0 +1,323 @@
+// { dg-do run { target c++26 } }
+// { dg-xfail-if "" { *-*-* } { "-D_GLIBCXX_DEBUG } { "" } }
+
+#include <queue>
+
+#ifndef __cpp_lib_constexpr_queue
+# error "Feature test macro for __cpp_lib_constexpr_queue is missing
in <queue>"
+#elif __cpp_lib_constexpr_queue != 202502L
+# error "Feature test macro for __cpp_lib_constexpr_queue has wrong
value in <queue>"
+#endif
+
+#include <algorithm>
+#include <ranges>
+#include <functional>
+#include <vector>
+#include <numeric>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+#include <testsuite_allocator.h>
+
+#include <iostream>
+
+struct Gt {
+ template<typename T, typename U>
+ constexpr bool operator()(T const& l, U const & r) {
+ return l > r;
+ }
+};
+
+template<typename Cont, typename Cmp = std::less<int>>
+constexpr void ctor_tests(Cmp cmp = Cmp())
+{
+ using V = typename Cont::value_type;
+ using Alloc = Cont::allocator_type;
+
+
+ V rg[] {2, 3, 5, 7};
+ Cont v0 {std::from_range, rg};
+ Cont v1 = v0;
+ Cont v2 = v0;
+ Alloc alloc;
+ auto top_range = * std::ranges::max_element(v0, cmp);
+
+ auto eq = [&] (std::priority_queue<V, Cont, Cmp>& l, std::span<V> r) {
+ if (l.size() != r.size())
+ return false;
+
+ std::vector<V> s(r.begin(), r.end());
+ std::ranges::sort(s, cmp);
+ for (auto const& v : s | std::views::reverse) {
+ if (v != l.top())
+ return false;
+ l.pop();
+ }
+ return true;
+ };
+
+ std::priority_queue<V, Cont, Cmp> pq1;
+ VERIFY( pq1.size() == 0 && pq1.empty() );
+
+ std::priority_queue<V, Cont, Cmp> pq2 {cmp};
+ VERIFY( pq2.size() == 0 && pq2.empty() );
+
+ std::priority_queue<V, Cont, Cmp> pq3 {cmp, v0};
+ VERIFY( pq3.size() == 4 && pq3.top() == top_range );
+
+ std::priority_queue<V, Cont, Cmp> pq4 {cmp, std::move(v0)};
+ VERIFY( pq4.size() == 4 && pq4.top() == top_range );
+
+ std::priority_queue<V, Cont, Cmp> pq5 (pq3);
+ VERIFY( pq5.top() == pq3.top() );
+ VERIFY( pq5.size() == pq3.size() );
+
+ std::priority_queue<V, Cont, Cmp> pq6 (std::move(pq3));
+ VERIFY( pq6.top() == pq5.top() );
+ VERIFY( pq6.size() == pq5.size() );
+
+ std::priority_queue<V, Cont, Cmp> pq10(std::begin(rg), std::end(rg),
+ cmp);
+ VERIFY( pq4.size() == 4 && pq4.top() == top_range );
+
+ std::priority_queue<V, Cont, Cmp> pq11(std::begin(rg), std::end(rg),
+ cmp, v0);
+ VERIFY( pq4.size() == 4 && pq4.top() == top_range );
+
+ std::priority_queue<V, Cont, Cmp> pq12(std::begin(rg), std::end(rg),
+ cmp, std::move(v0));
+ VERIFY( pq4.size() == 4 && pq4.top() == top_range );
+
+ std::priority_queue<V, Cont, Cmp> pq14 (alloc);
+ VERIFY( pq14.empty() );
+
+ std::priority_queue<V, Cont, Cmp> pq15 (cmp, alloc);
+ VERIFY( pq15.empty() );
+
+ std::priority_queue<V, Cont, Cmp> pq16 (cmp, v2, alloc);
+ VERIFY( eq(pq16, {rg, 4}) );
+
+ std::priority_queue<V, Cont, Cmp> pq17 (cmp, std::move(v2), alloc);
+ VERIFY( eq(pq17, {rg, 4}) );
+
+ std::priority_queue<V, Cont, Cmp> pq18 (pq12, alloc);
+ VERIFY( pq18.size() == pq12.size());
+
+ std::priority_queue<V, Cont, Cmp> pq19 (std::move(pq12), alloc);
+ VERIFY( pq19.size() == pq18.size() );
+}
+
+
+constexpr bool push_and_pop_test()
+{
+ std::priority_queue<int> a;
+ a.push(1);
+ a.pop();
+
+ return true;
+}
+
+static_assert( push_and_pop_test() );
+
+constexpr bool top_test ()
+{
+ std::priority_queue<int> a;
+ a.push(2);
+ a.push(4);
+ VERIFY( a.top() == 4 );
+
+ return true;
+}
+
+static_assert( top_test() );
+
+template<typename Range, typename Cont, typename Comp = std::less<int>>
+constexpr void push_range_test(Comp comp = Comp())
+{
+ using T = std::ranges::range_value_t<Range>;
+ using V = typename Cont::value_type;
+ T rg[] {2, 3, 5, 7};
+
+ std::vector<T> s(std::from_range, rg);
+ std::ranges::sort(s, comp);
+
+ std::priority_queue<V, Cont, Comp> pq;
+ pq.push_range(Range(rg, rg+4));
+
+ for (auto const& v : s | std::views::reverse) {
+ VERIFY(v == pq.top());
+ pq.pop();
+ }
+}
+
+constexpr int swap_test()
+{
+ std::priority_queue<int> a,b;
+ a.push(2);
+ b.push(4);
+ std::swap(a, b);
+ VERIFY( a.top() == 4 );
+ VERIFY( b.top() == 2 );
+ return true;
+}
+
+static_assert (swap_test());
+
+struct S
+{
+ int foo;
+ constexpr S(int i, int j) : foo{i + j} {}
+ constexpr friend bool operator< (S const &x, S const &y) { return
x.foo < y.foo; }
+};
+
+constexpr bool emplace_test()
+{
+ std::priority_queue<S> pq;
+ pq.emplace(0, 0);
+ pq.emplace(1, 0);
+ VERIFY( pq.size() == 2 );
+ VERIFY( pq.top().foo == 1 );
+ pq.pop();
+ VERIFY ( pq.top().foo == 0 );
+ return true;
+}
+
+static_assert( emplace_test() );
+
+template<typename Container, typename Cmp>
+constexpr void constructor_tests()
+{
+
+}
+
+constexpr bool do_tests()
+{
+// constructor_tests<>();
+// swap_test<>();
+ emplace_test();
+ return true;
+}
+
+template<typename Range, typename Cont, typename Cmp = std::less<int>>
+constexpr bool range_tests(Cmp cmp = Cmp())
+{
+ using V = typename Cont::value_type;
+ using Alloc = typename Cont::allocator_type;
+ using T = std::ranges::range_value_t<Range>;
+
+ Alloc alloc;
+ T rg[] {2, 3, 5, 7, 11, 13};
+
+ auto top_range = std::ranges::max_element(rg, cmp);
+
+ auto eq = [&](std::priority_queue<V, Cont, Cmp>& l, std::span<T> r) {
+ if (l.size() != r.size())
+ return false;
+
+ std::vector<T> s(r.begin(), r.end());
+ std::ranges::sort(s, cmp);
+ for (auto const& v : s | std::views::reverse) {
+ if (v != l.top())
+ return false;
+ l.pop();
+ }
+ return true;
+ };
+
+ std::priority_queue<V, Cont, Cmp> pq1 (std::from_range, Range(rg, rg+4),
+ cmp);
+ VERIFY( eq(pq1, {rg, 4}) );
+
+ auto pq2 = std::priority_queue<V, Cont, Cmp>(std::from_range,
Range(rg, rg+5), alloc);
+ VERIFY( eq(pq2, {rg, 5}) );
+
+ auto pq3 = std::priority_queue<V, Cont, Cmp>(std::from_range,
Range(rg, rg+6), cmp, alloc);
+ VERIFY( eq(pq3, {rg, 6}) );
+
+ std::priority_queue<V, Cont, Cmp> pq4;
+ pq4.push_range(Range(rg, rg+6));
+ VERIFY( eq(pq4, {rg, 6}) );
+
+ return true;
+}
+
+template<typename Range, typename Cont>
+constexpr void do_ranges_tests_b()
+{
+ range_tests<Range,
+ Cont>();
+ range_tests<Range,
+ Cont,
+ Gt>();
+}
+
+template<typename Cont>
+constexpr void do_ranges_tests_a() {
+ using T = typename Cont::value_type;
+ using namespace __gnu_test;
+ do_ranges_tests_b<test_forward_range<T>,
+ Cont>();
+ do_ranges_tests_b<test_forward_sized_range<T>,
+ Cont>();
+ do_ranges_tests_b<test_sized_range_sized_sent<T, forward_iterator_wrapper>,
+ Cont>();
+
+ do_ranges_tests_b<test_input_range<T>,
+ Cont>();
+ do_ranges_tests_b<test_input_sized_range<T>,
+ Cont>();
+ do_ranges_tests_b<test_sized_range_sized_sent<T, forward_iterator_wrapper>,
+ Cont>();
+
+ do_ranges_tests_b<test_range<T, input_iterator_wrapper_nocopy>,
+ Cont>();
+ do_ranges_tests_b<test_sized_range<T, input_iterator_wrapper_nocopy>,
+ Cont>();
+ do_ranges_tests_b<test_sized_range_sized_sent<T,
input_iterator_wrapper_nocopy>,
+ Cont>();
+}
+
+constexpr void do_ranges_tests()
+{
+ using namespace __gnu_test;
+ do_ranges_tests_a<std::vector<int>>();
+ do_ranges_tests_a<std::vector<int, SimpleAllocator<int>>>();
+ do_ranges_tests_a<std::deque<int>>();
+ do_ranges_tests_a<std::deque<int, SimpleAllocator<int>>>();
+}
+
+template <typename Cont>
+constexpr void do_ctor_tests_a()
+{
+ ctor_tests<Cont>();
+ ctor_tests<Cont, Gt>();
+}
+
+constexpr void do_ctor_tests()
+{
+ using namespace __gnu_test;
+ do_ctor_tests_a<std::vector<int>>();
+ do_ctor_tests_a<std::vector<int, SimpleAllocator<int>>>();
+ do_ctor_tests_a<std::deque<int>>();
+ do_ctor_tests_a<std::deque<int, SimpleAllocator<int>>>();
+}
+
+constexpr bool do_all_tests()
+{
+ do_ctor_tests();
+ push_and_pop_test();
+ top_test();
+ swap_test();
+ emplace_test();
+
+ do_ranges_tests();
+
+ return true;
+}
+
+static_assert (do_all_tests());
+
+int main()
+{
+ static_assert( do_all_tests() );
+ do_all_tests();
+}
diff --git a/libstdc++-v3/testsuite/23_containers/queue/constexpr.cc
b/libstdc++-v3/testsuite/23_containers/queue/constexpr.cc
new file mode 100644
index 00000000000..24ae8d85c63
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/queue/constexpr.cc
@@ -0,0 +1,281 @@
+// { dg-do run { target c++26 } }
+// { dg-xfail-if "" { *-*-* } { "-D_GLIBCXX_DEBUG } { "" } }
+
+#include <queue>
+
+#ifndef __cpp_lib_constexpr_queue
+# error "Feature test macro for __cpp_lib_constexpr_queue is missing
in <queue>"
+#elif __cpp_lib_constexpr_queue != 202502L
+# error "Feature test macro for __cpp_lib_constexpr_queue has wrong
value in <queue>"
+#endif
+
+#include <ranges>
+#include <functional>
+#include <vector>
+#include <numeric>
+#include <testsuite_hooks.h>
+#include <testsuite_iterators.h>
+#include <testsuite_allocator.h>
+
+template<typename Container>
+constexpr void ctor_tests()
+{
+ using Tp = typename Container::value_type;
+ using Alloc = typename Container::allocator_type;
+
+ auto eq = [] (std::queue<Tp, Container> l, std::span<Tp> r) {
+ if (l.size() != r.size())
+ return false;
+
+ std::vector<Tp> s(r.begin(), r.end());
+ for (auto v : s) {
+ if (v != l.front())
+ return false;
+ l.pop();
+ }
+ return true;
+ };
+
+ Container c0 {};
+ Alloc alloc0;
+
+ std::queue<Tp, Container> q1 (c0);
+ VERIFY( q1.size() == 0 && q1.empty() );
+ q1.push(1);
+ q1.push(2);
+ VERIFY( q1.size() == 2) ;
+
+ Container c1 {1, 2};
+ std::queue<Tp, Container> q2 {c1}; // q4
+ VERIFY ( q2 == q1 );
+ std::queue<Tp, Container> q3 {std::move(c1)}; //q5
+ VERIFY ( q3 == q1 );
+
+ std::queue<Tp, Container> q4 {q1};
+ std::queue<Tp, Container> q5 {std::move(q1)};
+ VERIFY ( q4 == q5 );
+
+ Tp rg[4] = {2, 3, 5, 7};
+ std::queue<Tp, Container> q6(std::begin(rg), std::end(rg)); // q3
+ VERIFY ( eq(q6, rg) );
+
+ VERIFY( q6.size() == std::size(rg));
+ VERIFY( q6.front() == 2 );
+ q6.pop();
+ VERIFY( q6.front() == 3 );
+ q6.pop();
+ VERIFY( q6.front() == 5 );
+ q6.pop();
+ VERIFY( q6.front() == 7 );
+ q6.pop();
+
+ Container c2 {1, 2};
+
+ std::queue<Tp, Container> q7 (alloc0);
+ q7.push(1);
+ q7.push(2);
+ VERIFY( q7.size() == 2 );
+
+ std::queue<Tp, Container> q8 (c2, alloc0);
+ VERIFY( q8 == q7 );
+
+ std::queue<Tp, Container> q9 (std::move(c2), alloc0);
+ VERIFY( q9 == q7 );
+ VERIFY( c2.empty() );
+
+ std::queue<Tp, Container> q10 (q7, alloc0);
+ VERIFY( q10 == q7 );
+ VERIFY( q10.size() == q7.size() );
+ VERIFY( q10.front() == q7.front() );
+ VERIFY( q10.back() == q7.back() );
+
+ std::queue<Tp, Container> q11 (std::move(q7), alloc0);
+ VERIFY( q11 == q10 );
+ VERIFY( q11.size() == q10.size() );
+ VERIFY( q7.empty() );
+
+ std::queue<Tp, Container> q12(std::begin(rg), std::end(rg), alloc0);
+ VERIFY ( eq(q12, rg) );
+ VERIFY( q12.size() == std::size(rg));
+ VERIFY( q12.front() == 2 );
+ q12.pop();
+ VERIFY( q12.front() == 3 );
+ q12.pop();
+ VERIFY( q12.front() == 5 );
+ q12.pop();
+ VERIFY( q12.front() == 7 );
+ q12.pop();
+
+ auto q13 = std::queue<Tp, Container>(std::from_range, rg);
+ VERIFY ( eq(q13, rg) );
+ auto q14 = std::queue<Tp, Container>(std::from_range, rg, alloc0);
+ VERIFY ( eq(q14, rg) );
+
+}
+
+template<typename Range, typename Alloc>
+constexpr void
+do_ranges_tests_a()
+{
+ using Tp = std::ranges::range_value_t<Range>;
+ Alloc alloc;
+ Tp a[] {2, 3, 5, 7};
+
+ auto eq = [&] (auto l, auto r) {
+ if (l.size() != r.size())
+ return false;
+
+ while (!l.empty()) {
+ if (l.front() != r.front())
+ return false;
+ l.pop();
+ r.pop();
+ }
+ return true;
+ };
+
+ auto q1 = std::queue<Tp>(std::from_range, Range(a, a+4));
+ std::queue<Tp> q2;
+ q2.push_range(Range(a, a+4));
+ VERIFY( eq (q1, q2) );
+
+ // TODO: Can check also list when made constexpr.
+ auto q3 = std::queue<Tp, std::deque<Tp, Alloc>>(std::from_range,
Range(a, a+4), alloc);
+ auto q4 = std::queue<Tp>(std::from_range, Range(a, a+4));
+ VERIFY( eq (q3, q4) );
+}
+
+template<typename Alloc>
+constexpr void
+do_ranges_tests()
+{
+ using namespace __gnu_test;
+ using Tp = std::allocator_traits<Alloc>::value_type;
+
+ do_ranges_tests_a<test_forward_range<Tp>,
+ Alloc>();
+ do_ranges_tests_a<test_forward_sized_range<Tp>,
+ Alloc>();
+ do_ranges_tests_a<test_sized_range_sized_sent
+ <Tp, forward_iterator_wrapper>,
+ Alloc>();
+
+ do_ranges_tests_a<test_input_range<Tp>, Alloc>();
+ do_ranges_tests_a<test_input_sized_range<Tp>, Alloc>();
+ do_ranges_tests_a<test_sized_range_sized_sent<Tp, forward_iterator_wrapper>,
+ Alloc>();
+
+ do_ranges_tests_a<test_range<Tp, input_iterator_wrapper_nocopy>,
+ Alloc>();
+ do_ranges_tests_a<test_sized_range<Tp, input_iterator_wrapper_nocopy>,
+ Alloc>();
+ do_ranges_tests_a<test_sized_range_sized_sent<Tp,
input_iterator_wrapper_nocopy>,
+ Alloc>();
+}
+
+constexpr void push_and_pop_test()
+{
+ std::queue<int> a;
+ a.push(1);
+ a.pop();
+}
+
+constexpr void push_range_test()
+{
+ std::queue<int> a;
+ const auto rg = {2, 3, 5, 7};
+ a.push_range(rg);
+ VERIFY (a.size() == 4);
+ VERIFY (a.front() == 2);
+ a.pop();
+ VERIFY (a.front() == 3);
+ a.pop();
+ VERIFY (a.front() == 5);
+ a.pop();
+ VERIFY (a.front() == 7);
+ a.pop();
+ VERIFY (a.size() == 0);
+}
+
+constexpr void swap_test()
+{
+ std::queue<int> a,b;
+ a.push(1);
+ b.push(2);
+ std::swap(a, b);
+ VERIFY( a.front() == 2 );
+ VERIFY( b.front() == 1 );
+}
+
+struct S
+{
+ int foo;
+ constexpr S(int i, int j) : foo{i + j} {}
+};
+
+constexpr void emplace_test()
+{
+ std::queue<S> a;
+ const S& s = a.emplace(196883, 1);
+ VERIFY ( a.size() == 1 );
+ VERIFY ( a.front().foo == 196884 );
+}
+
+constexpr void element_access_tests()
+{
+ std::queue<int> a;
+ a.push(2);
+ a.push(4);
+ VERIFY ( a.front() == 2 && a.back() == 4);
+}
+
+constexpr void operator_test()
+{
+ std::queue<int> a, b;
+ a.push(1);
+ b.push(1);
+ VERIFY ( a == b );
+ VERIFY ( a <= b );
+ VERIFY ( a >= b );
+ b.pop();
+ b.push(2);
+ VERIFY ( a < b );
+ VERIFY ( !(a > b) );
+ VERIFY ( a <= b );
+ VERIFY ( !(a >= b) );
+ VERIFY ( a != b );
+}
+
+constexpr bool
+do_tests()
+{
+ using namespace __gnu_test;
+
+ auto do_modifier_tests = []() {
+ push_and_pop_test();
+ push_range_test();
+ swap_test();
+ emplace_test();
+ };
+
+ // TODO: Check also list when made constexpr.
+ auto do_ctor_tests = []() {
+ ctor_tests<std::deque<int>>();
+ ctor_tests<std::deque<int, SimpleAllocator<int>>>();
+ };
+
+ do_ctor_tests();
+ do_modifier_tests();
+ element_access_tests();
+ operator_test();
+
+ // Additional code coverage
+ do_ranges_tests<std::allocator<int>>();
+ do_ranges_tests<SimpleAllocator<int>>();
+ return true;
+}
+
+int main() {
+ do_tests();
+ static_assert( do_tests() );
+}
--
2.34.1