[gcc r17-3426] libstdc++: Mark <queue>, <deque> constexpr
Tomasz Kaminski
tkaminsk@gcc.gnu.org
Wed Aug 19 14:00:46 GMT 2026
https://gcc.gnu.org/g:fd060914702256fb7884b287bd21598c9bd47c71
commit r17-3426-gfd060914702256fb7884b287bd21598c9bd47c71
Author: Tomasz Kamiński <tkaminsk@redhat.com>
Date: Thu Aug 6 13:18:14 2026 +0200
libstdc++: Mark <queue>, <deque> constexpr
This patch makes partial progress towards P3372 by marking deque, queue,
and relevant internal helpers to be constexpr when using C++26
(priority_queue was made constexr by r17-1233-g5a6ae2b286a730).
The formatter specializations for queue and priority_queue are also
made constexpr, implementing corresponding parts of 3391R2, "constexpr
format".
For debug version we use similar approach as is used for vector in
r14-6553-g7d00a59229ee17, and disable safe iterator instrumentation
and checking during constant evaluation, because of mutex locks
and call to non-inline functions.
The __uninitialized_default_a overloads that do not depend on
_Deque_iterator, are marked as _GLIBCXX20_CONSTEXPR for that reason.
libstdc++-v3/ChangeLog:
* include/bits/deque.tcc (deque): Declare out of line member
defintions as _GLIBCXX26_CONSTEXPR.
(std::__fill_a1, std::__copy_move_dit, std::__copy_move_a1)
(std::__copy_move_a2, std::__copy_n_a)
(std::__copy_move_backward_dit, std::__copy_move_backward_a1)
(std::__equal_dit, std::__equal_aux1, std::__lex_cmp_dit)
(std::__lexicographical_compare_aux1, std::__uninitialized_copy_a)
(std::__uninitialized_move_a): Declare as _GLIBCXX26_CONSTEXPR.
* include/bits/stl_algobase.h (std::__fill_a1, std::__copy_n_a)
(std::__copy_move_a1, std::__copy_move_backward_a1)
(std::__equal_aux1, __lexicographical_compare_aux1): Declare
overloads accepting _Deque_iterator as _GLIBCXX26_CONSTEXPR.
* include/bits/stl_deque.h (std::_Deque_iterator, std::_Deque_base)
(std::deque): Declare members as _GLIBCXX26_CONSTEXPR.
(std::operator==, std::operator<=>, std::swap): Declare as
_GLIBCXX26_CONSTEXPR.
* include/bits/stl_queue.h (std::queue): Declare members as
_GLIBCXX26_CONSTEXPR.
(std::priority_queue): Make _GLIBCXX26_CONSTEXPR placement
consistient.
(std::operator==, std::operator!=, std::operator<, std::operator>)
(std::operator<=, std::operator>=, std::operator<=>, std::swap):
Declare as _GLIBCXX26_CONSTEXPR.
* include/bits/stl_uninitialized.h (std::__uninitialized_copy_a):
Declare overloads accepting _Deque_iterator as _GLIBCXX26_CONSTEXPR.
(std::__uninitialized_default_a): Declare as _GLIBCXX20_CONSTEXPR.
* include/bits/version.def (constexpr_deque, constexpr_queue):
Define.
* include/bits/version.h: Regenerate.
* include/debug/deque (__debug::deque): Declare members as
_GLIBCXX26_CONSTEXPR.
(__debug::operator==, __debug::operator<=>, __debug::swap)
(__debug::erase, __debug::__erase_if): Declare as
_GLIBCXX26_CONSTEXPR.
* include/std/deque (__cpp_lib_constexpr_deque): Define.
(std::erase, std::erase_if): Declare as _GLIBCXX26_CONSTEXPR.
* include/std/queue (__cpp_lib_constexpr_queue): Define.
(_GLIBCXX_CONSTEXPR_FORMAT): Define locally.
(std::formatter<priority_queue<...>, _CharT>::format)
(std::formatter<queue<...>, _CharT>::format): Declare as
_GLIBCXX_CONSTEXPR_FORMAT.
* testsuite/23_containers/deque/constexpr.cc: New test.
* testsuite/23_containers/headers/deque/synopsis.cc: Update
declarations.
* testsuite/23_containers/headers/queue/synopsis.cc: Likewise.
* testsuite/23_containers/queue/constexpr.cc: New test.
* testsuite/23_containers/priority_queue/constexpr.cc: Replace
existing test with expanded suite.
* testsuite/std/format/ranges/adaptors.cc: Test at compile
time.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Co-authored-by: Thor Preimesberger <tcpreimesberger@gmail.com>
Signed-off-by: Thor Preimesberger <tcpreimesberger@gmail.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
Diff:
---
libstdc++-v3/include/bits/deque.tcc | 97 +++---
libstdc++-v3/include/bits/stl_algobase.h | 22 +-
libstdc++-v3/include/bits/stl_deque.h | 364 ++++++++++++---------
libstdc++-v3/include/bits/stl_queue.h | 107 +++---
libstdc++-v3/include/bits/stl_uninitialized.h | 7 +-
libstdc++-v3/include/bits/version.def | 18 +
libstdc++-v3/include/bits/version.h | 20 ++
libstdc++-v3/include/debug/deque | 210 +++++++-----
libstdc++-v3/include/std/deque | 7 +-
libstdc++-v3/include/std/queue | 11 +
.../testsuite/23_containers/deque/constexpr.cc | 334 +++++++++++++++++++
.../23_containers/headers/deque/synopsis.cc | 26 +-
.../23_containers/headers/queue/synopsis.cc | 32 +-
.../23_containers/priority_queue/constexpr.cc | 253 ++++++++++++--
.../testsuite/23_containers/queue/constexpr.cc | 242 ++++++++++++++
.../testsuite/std/format/ranges/adaptors.cc | 34 +-
16 files changed, 1390 insertions(+), 394 deletions(-)
diff --git a/libstdc++-v3/include/bits/deque.tcc b/libstdc++-v3/include/bits/deque.tcc
index df4be0802124..cf260a5269c8 100644
--- a/libstdc++-v3/include/bits/deque.tcc
+++ b/libstdc++-v3/include/bits/deque.tcc
@@ -65,7 +65,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
template <typename _Tp, typename _Alloc>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_default_initialize()
{
@@ -91,6 +91,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 +134,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 +159,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 +186,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 +210,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 +236,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 +260,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)
@@ -287,7 +294,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template <typename _Tp, class _Alloc>
template <typename _InputIterator>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_assign_aux(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag)
@@ -303,7 +310,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template <typename _Tp, typename _Alloc>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_fill_insert(iterator __pos, size_type __n, const value_type& __x)
{
@@ -346,7 +353,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
template <typename _Tp, typename _Alloc>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_default_append(size_type __n)
{
@@ -370,7 +377,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template <typename _Tp, typename _Alloc>
- bool
+ _GLIBCXX26_CONSTEXPR bool
deque<_Tp, _Alloc>::
_M_shrink_to_fit()
{
@@ -389,7 +396,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#endif
template <typename _Tp, typename _Alloc>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_fill_initialize(const value_type& __value)
{
@@ -415,7 +422,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template <typename _Tp, typename _Alloc>
template <typename _InputIterator>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_range_initialize(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag)
@@ -439,7 +446,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template <typename _Tp, typename _Alloc>
template <typename _ForwardIterator>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
std::forward_iterator_tag)
@@ -480,7 +487,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, typename _Alloc>
#if __cplusplus >= 201103L
template<typename... _Args>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_push_back_aux(_Args&&... __args)
#else
@@ -519,7 +526,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, typename _Alloc>
#if __cplusplus >= 201103L
template<typename... _Args>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_push_front_aux(_Args&&... __args)
#else
@@ -557,7 +564,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// Called only if _M_impl._M_finish._M_cur == _M_impl._M_finish._M_first.
template <typename _Tp, typename _Alloc>
- void deque<_Tp, _Alloc>::
+ _GLIBCXX26_CONSTEXPR void
+ deque<_Tp, _Alloc>::
_M_pop_back_aux()
{
_M_deallocate_node(this->_M_impl._M_finish._M_first);
@@ -573,7 +581,8 @@ _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>
- void deque<_Tp, _Alloc>::
+ _GLIBCXX26_CONSTEXPR void
+ deque<_Tp, _Alloc>::
_M_pop_front_aux()
{
_Alloc_traits::destroy(_M_get_Tp_allocator(),
@@ -585,7 +594,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template <typename _Tp, typename _Alloc>
template <typename _InputIterator, typename _Sentinel>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_range_prepend(_InputIterator __first, _Sentinel __last,
size_type __n)
@@ -607,7 +616,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template <typename _Tp, typename _Alloc>
template <typename _InputIterator, typename _Sentinel>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_range_append(_InputIterator __first, _Sentinel __last,
size_type __n)
@@ -630,7 +639,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template <typename _Tp, typename _Alloc>
template <typename _InputIterator>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_range_insert_aux(iterator __pos,
_InputIterator __first, _InputIterator __last,
@@ -639,7 +648,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template <typename _Tp, typename _Alloc>
template <typename _ForwardIterator>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_range_insert_aux(iterator __pos,
_ForwardIterator __first, _ForwardIterator __last,
@@ -660,6 +669,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,7 +717,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template <typename _Tp, typename _Alloc>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_insert_aux(iterator __pos, size_type __n, const value_type& __x)
{
@@ -793,7 +803,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template <typename _Tp, typename _Alloc>
template <typename _ForwardIterator>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_insert_aux(iterator __pos,
_ForwardIterator __first, _ForwardIterator __last,
@@ -882,7 +892,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __glibcxx_containers_ranges // C++ >= 23
template<ranges::forward_range _Rg>
- auto __advance_dist(_Rg& __rg)
+ _GLIBCXX26_CONSTEXPR auto
+ __advance_dist(_Rg& __rg)
{
struct _Res
{
@@ -914,7 +925,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, typename _Alloc>
template<__detail::__container_compatible_range<_Tp> _Rg>
- auto
+ _GLIBCXX26_CONSTEXPR auto
deque<_Tp, _Alloc>::
insert_range(const_iterator __pos, _Rg&& __rg)
-> iterator
@@ -954,7 +965,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, typename _Alloc>
template<__detail::__container_compatible_range<_Tp> _Rg>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
prepend_range(_Rg&& __rg)
{
@@ -996,7 +1007,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, typename _Alloc>
template<__detail::__container_compatible_range<_Tp> _Rg>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
append_range(_Rg&& __rg)
{
@@ -1013,6 +1024,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
deque& __self;
size_type __n = __self.size();
+ _GLIBCXX26_CONSTEXPR
~_Guard_elts_back()
{
if (__n < __self.size())
@@ -1032,7 +1044,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#endif // containers_ranges
template<typename _Tp, typename _Alloc>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_destroy_data_aux(iterator __first, iterator __last)
{
@@ -1054,7 +1066,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template <typename _Tp, typename _Alloc>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_new_elements_at_front(size_type __new_elems)
{
@@ -1079,7 +1091,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template <typename _Tp, typename _Alloc>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_new_elements_at_back(size_type __new_elems)
{
@@ -1104,7 +1116,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template <typename _Tp, typename _Alloc>
- void
+ _GLIBCXX26_CONSTEXPR void
deque<_Tp, _Alloc>::
_M_reallocate_map(size_type __nodes_to_add, bool __add_at_front)
{
@@ -1158,7 +1170,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
// Overload for deque::iterators, exploiting the "segmented-iterator
// optimization".
template<typename _Tp, typename _VTp>
- void
+ _GLIBCXX26_CONSTEXPR void
__fill_a1(const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __first,
const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __last,
const _VTp& __value)
@@ -1180,7 +1192,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _Tp, typename _Ref, typename _Ptr, typename _OI>
- _OI
+ _GLIBCXX26_CONSTEXPR _OI
__copy_move_dit(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last,
_OI __result)
@@ -1209,7 +1221,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _Tp, typename _Ref, typename _Ptr, typename _OI>
- _OI
+ _GLIBCXX26_CONSTEXPR _OI
__copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last,
_OI __result)
@@ -1217,6 +1229,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _ITp, typename _IRef, typename _IPtr, typename _OTp>
+ _GLIBCXX26_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 +1237,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
{ return __copy_move_dit<_IsMove>(__first, __last, __result); }
template<bool _IsMove, typename _II, typename _Tp>
+ _GLIBCXX26_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_any_random_access_iter<_II>::__value,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type
@@ -1250,6 +1264,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
}
template<bool _IsMove, typename _CharT>
+ _GLIBCXX26_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_char<_CharT>::__value,
_GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type
@@ -1277,6 +1292,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
}
template<typename _CharT, typename _Size>
+ _GLIBCXX26_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_char<_CharT>::__value,
_GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type
@@ -1302,7 +1318,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _Tp, typename _Ref, typename _Ptr, typename _OI>
- _OI
+ _GLIBCXX26_CONSTEXPR _OI
__copy_move_backward_dit(
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last,
@@ -1329,7 +1345,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _Tp, typename _Ref, typename _Ptr, typename _OI>
- _OI
+ _GLIBCXX26_CONSTEXPR _OI
__copy_move_backward_a1(
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __first,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr> __last,
@@ -1338,6 +1354,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _ITp, typename _IRef, typename _IPtr, typename _OTp>
+ _GLIBCXX26_CONSTEXPR
_GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
__copy_move_backward_a1(
_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
@@ -1346,6 +1363,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
{ return __copy_move_backward_dit<_IsMove>(__first, __last, __result); }
template<bool _IsMove, typename _II, typename _Tp>
+ _GLIBCXX26_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_any_random_access_iter<_II>::__value,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type
@@ -1378,7 +1396,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
}
template<typename _Tp, typename _Ref, typename _Ptr, typename _II>
- bool
+ _GLIBCXX26_CONSTEXPR bool
__equal_dit(
const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>& __first1,
const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>& __last1,
@@ -1405,6 +1423,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
}
template<typename _Tp, typename _Ref, typename _Ptr, typename _II>
+ _GLIBCXX26_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,13 +1433,14 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _Tp1, typename _Ref1, typename _Ptr1,
typename _Tp2, typename _Ref2, typename _Ptr2>
- bool
+ _GLIBCXX26_CONSTEXPR bool
__equal_aux1(_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1,
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1,
_GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2)
{ return std::__equal_dit(__first1, __last1, __first2); }
template<typename _II, typename _Tp, typename _Ref, typename _Ptr>
+ _GLIBCXX26_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_any_random_access_iter<_II>::__value, bool>::__type
__equal_aux1(_II __first1, _II __last1,
@@ -1446,7 +1466,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
}
template<typename _Tp1, typename _Ref, typename _Ptr, typename _Tp2>
- int
+ _GLIBCXX26_CONSTEXPR int
__lex_cmp_dit(
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref, _Ptr> __first1,
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref, _Ptr> __last1,
@@ -1487,7 +1507,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _Tp1, typename _Ref1, typename _Ptr1,
typename _Tp2>
- inline bool
+ inline _GLIBCXX26_CONSTEXPR bool
__lexicographical_compare_aux1(
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1,
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1,
@@ -1496,7 +1516,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _Tp1,
typename _Tp2, typename _Ref2, typename _Ptr2>
- inline bool
+ inline _GLIBCXX26_CONSTEXPR bool
__lexicographical_compare_aux1(_Tp1* __first1, _Tp1* __last1,
_GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __first2,
_GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2> __last2)
@@ -1504,7 +1524,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _Tp1, typename _Ref1, typename _Ptr1,
typename _Tp2, typename _Ref2, typename _Ptr2>
- inline bool
+ inline _GLIBCXX26_CONSTEXPR bool
__lexicographical_compare_aux1(
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __first1,
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1> __last1,
@@ -1554,6 +1574,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
template<typename _ITp, typename _IRef, typename _IPtr, typename _OTp,
typename _Tp>
+ _GLIBCXX26_CONSTEXPR
_GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
__uninitialized_copy_a(
_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
@@ -1583,6 +1604,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
}
template<typename _Iter, typename _OTp, typename _Tp>
+ _GLIBCXX26_CONSTEXPR
__enable_if_t<__is_random_access_iter<_Iter>::value,
_GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>>
__uninitialized_copy_a(_Iter __first, _Iter __last,
@@ -1607,6 +1629,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _ITp, typename _IRef, typename _IPtr, typename _OTp,
typename _Tp>
+ _GLIBCXX26_CONSTEXPR
_GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
__uninitialized_move_a(
_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
diff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h
index 33b1177810a9..1df48418c425 100644
--- a/libstdc++-v3/include/bits/stl_algobase.h
+++ b/libstdc++-v3/include/bits/stl_algobase.h
@@ -347,6 +347,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
istreambuf_iterator<_CharT, char_traits<_CharT> >, _CharT*);
template<bool _IsMove, typename _CharT>
+ _GLIBCXX26_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_char<_CharT>::__value,
_GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type
@@ -464,19 +465,21 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _Tp, typename _Ref, typename _Ptr, typename _OI>
- _OI
+ _GLIBCXX26_CONSTEXPR _OI
__copy_move_a1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
_OI);
template<bool _IsMove,
typename _ITp, typename _IRef, typename _IPtr, typename _OTp>
+ _GLIBCXX26_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>
+ _GLIBCXX26_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_any_random_access_iter<_II>::__value,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type
@@ -600,6 +603,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
_Size, _CharT*, bool);
template<typename _CharT, typename _Size>
+ _GLIBCXX26_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_char<_CharT>::__value,
_GLIBCXX_STD_C::_Deque_iterator<_CharT, _CharT&, _CharT*> >::__type
@@ -752,13 +756,14 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<bool _IsMove,
typename _Tp, typename _Ref, typename _Ptr, typename _OI>
- _OI
+ _GLIBCXX26_CONSTEXPR _OI
__copy_move_backward_a1(_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Ref, _Ptr>,
_OI);
template<bool _IsMove,
typename _ITp, typename _IRef, typename _IPtr, typename _OTp>
+ _GLIBCXX26_CONSTEXPR
_GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
__copy_move_backward_a1(
_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr>,
@@ -766,6 +771,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
_GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>);
template<bool _IsMove, typename _II, typename _Tp>
+ _GLIBCXX26_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_any_random_access_iter<_II>::__value,
_GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*> >::__type
@@ -959,7 +965,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
{ std::__fill_a1(__first.base(), __last.base(), __value); }
template<typename _Tp, typename _VTp>
- void
+ _GLIBCXX26_CONSTEXPR void
__fill_a1(const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>&,
const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>&,
const _VTp&);
@@ -1215,6 +1221,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
};
template<typename _Tp, typename _Ref, typename _Ptr, typename _II>
+ _GLIBCXX26_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>,
@@ -1223,12 +1230,13 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _Tp1, typename _Ref1, typename _Ptr1,
typename _Tp2, typename _Ref2, typename _Ptr2>
- bool
+ _GLIBCXX26_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>
+ _GLIBCXX26_CONSTEXPR
typename __gnu_cxx::__enable_if<
__is_any_random_access_iter<_II>::__value, bool>::__type
__equal_aux1(_II, _II,
@@ -1434,7 +1442,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _Tp1, typename _Ref1, typename _Ptr1,
typename _Tp2>
- bool
+ _GLIBCXX26_CONSTEXPR bool
__lexicographical_compare_aux1(
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>,
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>,
@@ -1442,14 +1450,14 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
template<typename _Tp1,
typename _Tp2, typename _Ref2, typename _Ptr2>
- bool
+ _GLIBCXX26_CONSTEXPR bool
__lexicographical_compare_aux1(_Tp1*, _Tp1*,
_GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2>,
_GLIBCXX_STD_C::_Deque_iterator<_Tp2, _Ref2, _Ptr2>);
template<typename _Tp1, typename _Ref1, typename _Ptr1,
typename _Tp2, typename _Ref2, typename _Ptr2>
- bool
+ _GLIBCXX26_CONSTEXPR bool
__lexicographical_compare_aux1(
_GLIBCXX_STD_C::_Deque_iterator<_Tp1, _Ref1, _Ptr1>,
_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 b51342e1751d..0555c0d55be3 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,21 +180,21 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_Deque_iterator& operator=(const _Deque_iterator&) = default;
#endif
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
_M_const_cast() const _GLIBCXX_NOEXCEPT
{ return iterator(_M_cur, _M_node); }
_GLIBCXX_NODISCARD
- reference
+ _GLIBCXX26_CONSTEXPR reference
operator*() const _GLIBCXX_NOEXCEPT
{ return *_M_cur; }
_GLIBCXX_NODISCARD
- pointer
+ _GLIBCXX26_CONSTEXPR pointer
operator->() const _GLIBCXX_NOEXCEPT
{ return _M_cur; }
- _Self&
+ _GLIBCXX26_CONSTEXPR _Self&
operator++() _GLIBCXX_NOEXCEPT
{
++_M_cur;
@@ -201,7 +206,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return *this;
}
- _Self
+ _GLIBCXX26_CONSTEXPR _Self
operator++(int) _GLIBCXX_NOEXCEPT
{
_Self __tmp = *this;
@@ -209,7 +214,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return __tmp;
}
- _Self&
+ _GLIBCXX26_CONSTEXPR _Self&
operator--() _GLIBCXX_NOEXCEPT
{
if (_M_cur == _M_first)
@@ -221,7 +226,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return *this;
}
- _Self
+ _GLIBCXX26_CONSTEXPR _Self
operator--(int) _GLIBCXX_NOEXCEPT
{
_Self __tmp = *this;
@@ -229,7 +234,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return __tmp;
}
- _Self&
+ _GLIBCXX26_CONSTEXPR _Self&
operator+=(difference_type __n) _GLIBCXX_NOEXCEPT
{
const difference_type __offset = __n + (_M_cur - _M_first);
@@ -248,12 +253,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return *this;
}
- _Self&
+ _GLIBCXX26_CONSTEXPR _Self&
operator-=(difference_type __n) _GLIBCXX_NOEXCEPT
{ return *this += -__n; }
_GLIBCXX_NODISCARD
- reference
+ _GLIBCXX26_CONSTEXPR reference
operator[](difference_type __n) const _GLIBCXX_NOEXCEPT
{ return *(*this + __n); }
@@ -262,7 +267,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* _M_cur, which should therefore be set by the caller
* immediately afterwards, based on _M_first and _M_last.
*/
- void
+ _GLIBCXX26_CONSTEXPR void
_M_set_node(_Map_pointer __new_node) _GLIBCXX_NOEXCEPT
{
_M_node = __new_node;
@@ -271,7 +276,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
_GLIBCXX_NODISCARD
- friend bool
+ friend _GLIBCXX26_CONSTEXPR bool
operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_cur == __y._M_cur; }
@@ -280,7 +285,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// operators are in scope (for additional details, see libstdc++/3628)
template<typename _RefR, typename _PtrR>
_GLIBCXX_NODISCARD
- friend bool
+ friend _GLIBCXX26_CONSTEXPR bool
operator==(const _Self& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
_GLIBCXX_NOEXCEPT
@@ -288,7 +293,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cpp_lib_three_way_comparison
[[nodiscard]]
- friend strong_ordering
+ friend _GLIBCXX26_CONSTEXPR strong_ordering
operator<=>(const _Self& __x, const _Self& __y) noexcept
{
if (const auto __cmp = __x._M_node <=> __y._M_node; __cmp != 0)
@@ -297,20 +302,20 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
#else
_GLIBCXX_NODISCARD
- friend bool
+ friend _GLIBCXX26_CONSTEXPR bool
operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{ return !(__x == __y); }
template<typename _RefR, typename _PtrR>
_GLIBCXX_NODISCARD
- friend bool
+ friend _GLIBCXX26_CONSTEXPR bool
operator!=(const _Self& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
_GLIBCXX_NOEXCEPT
{ return !(__x == __y); }
_GLIBCXX_NODISCARD
- friend bool
+ friend _GLIBCXX26_CONSTEXPR bool
operator<(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{
return (__x._M_node == __y._M_node)
@@ -319,7 +324,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _RefR, typename _PtrR>
_GLIBCXX_NODISCARD
- friend bool
+ friend _GLIBCXX26_CONSTEXPR bool
operator<(const _Self& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
_GLIBCXX_NOEXCEPT
@@ -329,39 +334,39 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
_GLIBCXX_NODISCARD
- friend bool
+ friend _GLIBCXX26_CONSTEXPR bool
operator>(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{ return __y < __x; }
template<typename _RefR, typename _PtrR>
_GLIBCXX_NODISCARD
- friend bool
+ friend _GLIBCXX26_CONSTEXPR bool
operator>(const _Self& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
_GLIBCXX_NOEXCEPT
{ return __y < __x; }
_GLIBCXX_NODISCARD
- friend bool
+ friend _GLIBCXX26_CONSTEXPR bool
operator<=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{ return !(__y < __x); }
template<typename _RefR, typename _PtrR>
_GLIBCXX_NODISCARD
- friend bool
+ friend _GLIBCXX26_CONSTEXPR bool
operator<=(const _Self& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
_GLIBCXX_NOEXCEPT
{ return !(__y < __x); }
_GLIBCXX_NODISCARD
- friend bool
+ friend _GLIBCXX26_CONSTEXPR bool
operator>=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{ return !(__x < __y); }
template<typename _RefR, typename _PtrR>
_GLIBCXX_NODISCARD
- friend bool
+ friend _GLIBCXX26_CONSTEXPR bool
operator>=(const _Self& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
_GLIBCXX_NOEXCEPT
@@ -369,7 +374,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#endif // three-way comparison
_GLIBCXX_NODISCARD
- friend difference_type
+ friend _GLIBCXX26_CONSTEXPR difference_type
operator-(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
{
return difference_type(_S_buffer_size())
@@ -384,7 +389,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// parameters.
template<typename _RefR, typename _PtrR>
_GLIBCXX_NODISCARD
- friend difference_type
+ friend _GLIBCXX26_CONSTEXPR difference_type
operator-(const _Self& __x,
const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
_GLIBCXX_NOEXCEPT
@@ -396,7 +401,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
_GLIBCXX_NODISCARD
- friend _Self
+ friend _GLIBCXX26_CONSTEXPR _Self
operator+(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT
{
_Self __tmp = __x;
@@ -405,7 +410,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
_GLIBCXX_NODISCARD
- friend _Self
+ friend _GLIBCXX26_CONSTEXPR _Self
operator-(const _Self& __x, difference_type __n) _GLIBCXX_NOEXCEPT
{
_Self __tmp = __x;
@@ -414,7 +419,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
_GLIBCXX_NODISCARD
- friend _Self
+ friend _GLIBCXX26_CONSTEXPR _Self
operator+(difference_type __n, const _Self& __x) _GLIBCXX_NOEXCEPT
{ return __x + __n; }
@@ -488,30 +493,35 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typedef _Alloc allocator_type;
- allocator_type
+ _GLIBCXX26_CONSTEXPR allocator_type
get_allocator() const _GLIBCXX_NOEXCEPT
{ return allocator_type(_M_get_Tp_allocator()); }
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()))
{
@@ -520,10 +530,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)
{
@@ -542,6 +554,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
#endif
+ _GLIBCXX26_CONSTEXPR
~_Deque_base() _GLIBCXX_NOEXCEPT;
typedef typename iterator::_Map_pointer _Map_pointer;
@@ -553,6 +566,7 @@ _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()
{ }
@@ -562,12 +576,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_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
- void
+ _GLIBCXX26_CONSTEXPR void
_M_swap_data(_Deque_impl_data& __x) _GLIBCXX_NOEXCEPT
{
// Do not use std::swap(_M_start, __x._M_start), etc as it loses
@@ -582,11 +597,13 @@ _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)
{ }
@@ -594,66 +611,75 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
_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
};
- _Tp_alloc_type&
+ _GLIBCXX26_CONSTEXPR _Tp_alloc_type&
_M_get_Tp_allocator() _GLIBCXX_NOEXCEPT
{ return this->_M_impl; }
- const _Tp_alloc_type&
+ _GLIBCXX26_CONSTEXPR const _Tp_alloc_type&
_M_get_Tp_allocator() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl; }
- _Map_alloc_type
+ _GLIBCXX26_CONSTEXPR _Map_alloc_type
_M_get_map_allocator() const _GLIBCXX_NOEXCEPT
{ return _Map_alloc_type(_M_get_Tp_allocator()); }
- _Ptr
+ _GLIBCXX26_CONSTEXPR _Ptr
_M_allocate_node()
{
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Traits;
return _Traits::allocate(_M_impl, __deque_buf_size(sizeof(_Tp)));
}
- void
+ _GLIBCXX26_CONSTEXPR void
_M_deallocate_node(_Ptr __p) _GLIBCXX_NOEXCEPT
{
typedef __gnu_cxx::__alloc_traits<_Tp_alloc_type> _Traits;
_Traits::deallocate(_M_impl, __p, __deque_buf_size(sizeof(_Tp)));
}
- _Map_pointer
+ _GLIBCXX26_CONSTEXPR _Map_pointer
_M_allocate_map(size_t __n)
{
_Map_alloc_type __map_alloc = _M_get_map_allocator();
return _Map_alloc_traits::allocate(__map_alloc, __n);
}
- void
+ _GLIBCXX26_CONSTEXPR void
_M_deallocate_map(_Map_pointer __p, size_t __n) _GLIBCXX_NOEXCEPT
{
_Map_alloc_type __map_alloc = _M_get_map_allocator();
_Map_alloc_traits::deallocate(__map_alloc, __p, __n);
}
- void _M_initialize_map(size_t);
- void _M_create_nodes(_Map_pointer __nstart, _Map_pointer __nfinish);
- void _M_destroy_nodes(_Map_pointer __nstart,
- _Map_pointer __nfinish) _GLIBCXX_NOEXCEPT;
+ _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 };
_Deque_impl _M_impl;
};
template<typename _Tp, typename _Alloc>
+ _GLIBCXX26_CONSTEXPR
_Deque_base<_Tp, _Alloc>::
~_Deque_base() _GLIBCXX_NOEXCEPT
{
@@ -673,7 +699,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* The initial underlying memory layout is a bit complicated...
*/
template<typename _Tp, typename _Alloc>
- void
+ _GLIBCXX26_CONSTEXPR void
_Deque_base<_Tp, _Alloc>::
_M_initialize_map(size_t __num_elements)
{
@@ -712,7 +738,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template<typename _Tp, typename _Alloc>
- void
+ _GLIBCXX26_CONSTEXPR void
_Deque_base<_Tp, _Alloc>::
_M_create_nodes(_Map_pointer __nstart, _Map_pointer __nfinish)
{
@@ -730,7 +756,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
template<typename _Tp, typename _Alloc>
- void
+ _GLIBCXX26_CONSTEXPR void
_Deque_base<_Tp, _Alloc>::
_M_destroy_nodes(_Map_pointer __nstart,
_Map_pointer __nfinish) _GLIBCXX_NOEXCEPT
@@ -864,7 +890,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typedef _Alloc allocator_type;
private:
- static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT
+ static _GLIBCXX26_CONSTEXPR size_t
+ _S_buffer_size() _GLIBCXX_NOEXCEPT
{ return __deque_buf_size(sizeof(_Tp)); }
// Functions controlling memory layout, and nothing else.
@@ -900,7 +927,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @brief Creates a %deque with no elements.
* @param __a An allocator object.
*/
- explicit
+ explicit _GLIBCXX26_CONSTEXPR
deque(const allocator_type& __a)
: _Base(__a, 0) { }
@@ -913,7 +940,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* This constructor fills the %deque with @a n default
* constructed elements.
*/
- explicit
+ explicit _GLIBCXX26_CONSTEXPR
deque(size_type __n, const allocator_type& __a = allocator_type())
: _Base(__a, _S_check_init_len(__n, __a))
{ _M_default_initialize(); }
@@ -926,6 +953,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))
@@ -953,6 +981,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())
@@ -972,6 +1001,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
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(),
@@ -979,15 +1009,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())
{
@@ -1012,6 +1045,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)
@@ -1039,6 +1073,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)
@@ -1065,6 +1100,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)); }
@@ -1075,6 +1111,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()); }
@@ -1087,7 +1124,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).
*/
- deque&
+ _GLIBCXX26_CONSTEXPR deque&
operator=(const deque& __x);
#if __cplusplus >= 201103L
@@ -1099,7 +1136,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* if the allocators permit it).
* @a __x is a valid, but unspecified %deque.
*/
- deque&
+ _GLIBCXX26_CONSTEXPR deque&
operator=(deque&& __x) noexcept(_Alloc_traits::_S_always_equal())
{
using __always_equal = typename _Alloc_traits::is_always_equal;
@@ -1118,7 +1155,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* resulting %deque's size is the same as the number of elements
* assigned.
*/
- deque&
+ _GLIBCXX26_CONSTEXPR deque&
operator=(initializer_list<value_type> __l)
{
_M_assign_aux(__l.begin(), __l.end(),
@@ -1137,7 +1174,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* %deque and that the resulting %deque's size is the same as
* the number of elements assigned.
*/
- void
+ _GLIBCXX26_CONSTEXPR void
assign(size_type __n, const value_type& __val)
{ _M_fill_assign(__n, __val); }
@@ -1156,7 +1193,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
- void
+ _GLIBCXX26_CONSTEXPR void
assign(_InputIterator __first, _InputIterator __last)
{ _M_assign_aux(__first, __last, std::__iterator_category(__first)); }
#else
@@ -1181,7 +1218,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* resulting %deque's size is the same as the number of elements
* assigned.
*/
- void
+ _GLIBCXX26_CONSTEXPR void
assign(initializer_list<value_type> __l)
{ _M_assign_aux(__l.begin(), __l.end(), random_access_iterator_tag()); }
#endif
@@ -1235,7 +1272,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/// Get a copy of the memory allocation object.
_GLIBCXX_NODISCARD
- allocator_type
+ _GLIBCXX26_CONSTEXPR allocator_type
get_allocator() const _GLIBCXX_NOEXCEPT
{ return _Base::get_allocator(); }
@@ -1245,7 +1282,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* %deque. Iteration is done in ordinary element order.
*/
_GLIBCXX_NODISCARD
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
begin() _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_start; }
@@ -1254,7 +1291,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* element in the %deque. Iteration is done in ordinary element order.
*/
_GLIBCXX_NODISCARD
- const_iterator
+ _GLIBCXX26_CONSTEXPR const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_start; }
@@ -1264,7 +1301,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* element order.
*/
_GLIBCXX_NODISCARD
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
end() _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_finish; }
@@ -1274,7 +1311,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* ordinary element order.
*/
_GLIBCXX_NODISCARD
- const_iterator
+ _GLIBCXX26_CONSTEXPR const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return this->_M_impl._M_finish; }
@@ -1284,7 +1321,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* element order.
*/
_GLIBCXX_NODISCARD
- reverse_iterator
+ _GLIBCXX26_CONSTEXPR reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(this->_M_impl._M_finish); }
@@ -1294,7 +1331,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* reverse element order.
*/
_GLIBCXX_NODISCARD
- const_reverse_iterator
+ _GLIBCXX26_CONSTEXPR const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(this->_M_impl._M_finish); }
@@ -1304,7 +1341,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* in reverse element order.
*/
_GLIBCXX_NODISCARD
- reverse_iterator
+ _GLIBCXX26_CONSTEXPR reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(this->_M_impl._M_start); }
@@ -1314,7 +1351,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* done in reverse element order.
*/
_GLIBCXX_NODISCARD
- const_reverse_iterator
+ _GLIBCXX26_CONSTEXPR const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(this->_M_impl._M_start); }
@@ -1324,7 +1361,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* element in the %deque. Iteration is done in ordinary element order.
*/
[[__nodiscard__]]
- const_iterator
+ _GLIBCXX26_CONSTEXPR const_iterator
cbegin() const noexcept
{ return this->_M_impl._M_start; }
@@ -1334,7 +1371,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* ordinary element order.
*/
[[__nodiscard__]]
- const_iterator
+ _GLIBCXX26_CONSTEXPR const_iterator
cend() const noexcept
{ return this->_M_impl._M_finish; }
@@ -1344,7 +1381,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* reverse element order.
*/
[[__nodiscard__]]
- const_reverse_iterator
+ _GLIBCXX26_CONSTEXPR const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(this->_M_impl._M_finish); }
@@ -1354,7 +1391,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* done in reverse element order.
*/
[[__nodiscard__]]
- const_reverse_iterator
+ _GLIBCXX26_CONSTEXPR const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(this->_M_impl._M_start); }
#endif
@@ -1362,7 +1399,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// [23.2.1.2] capacity
/** Returns the number of elements in the %deque. */
_GLIBCXX_NODISCARD
- size_type
+ _GLIBCXX26_CONSTEXPR size_type
size() const _GLIBCXX_NOEXCEPT
{
size_type __sz = this->_M_impl._M_finish - this->_M_impl._M_start;
@@ -1373,7 +1410,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/** Returns the size() of the largest possible %deque. */
_GLIBCXX_NODISCARD
- size_type
+ _GLIBCXX26_CONSTEXPR size_type
max_size() const _GLIBCXX_NOEXCEPT
{ return _S_max_size(_M_get_Tp_allocator()); }
@@ -1387,7 +1424,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* %deque's current size the %deque is truncated, otherwise
* default constructed elements are appended.
*/
- void
+ _GLIBCXX26_CONSTEXPR void
resize(size_type __new_size)
{
const size_type __len = size();
@@ -1409,7 +1446,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* %deque is extended and new elements are populated with given
* data.
*/
- void
+ _GLIBCXX26_CONSTEXPR void
resize(size_type __new_size, const value_type& __x)
#else
/**
@@ -1437,7 +1474,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
/** A non-binding request to reduce memory use. */
- void
+ _GLIBCXX26_CONSTEXPR void
shrink_to_fit() noexcept
{ _M_shrink_to_fit(); }
#endif
@@ -1446,7 +1483,8 @@ _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; }
@@ -1463,7 +1501,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* see at().)
*/
_GLIBCXX_NODISCARD
- reference
+ _GLIBCXX26_CONSTEXPR reference
operator[](size_type __n) _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_subscript(__n);
@@ -1482,7 +1520,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* see at().)
*/
_GLIBCXX_NODISCARD
- const_reference
+ _GLIBCXX26_CONSTEXPR const_reference
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_subscript(__n);
@@ -1491,7 +1529,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
protected:
/// Safety check used only from at().
- void
+ _GLIBCXX26_CONSTEXPR void
_M_range_check(size_type __n) const
{
if (__n >= this->size())
@@ -1513,7 +1551,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.
*/
- reference
+ _GLIBCXX26_CONSTEXPR reference
at(size_type __n)
{
_M_range_check(__n);
@@ -1531,7 +1569,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.
*/
- const_reference
+ _GLIBCXX26_CONSTEXPR const_reference
at(size_type __n) const
{
_M_range_check(__n);
@@ -1543,7 +1581,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* element of the %deque.
*/
_GLIBCXX_NODISCARD
- reference
+ _GLIBCXX26_CONSTEXPR reference
front() _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
@@ -1555,7 +1593,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* element of the %deque.
*/
_GLIBCXX_NODISCARD
- const_reference
+ _GLIBCXX26_CONSTEXPR const_reference
front() const _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
@@ -1567,7 +1605,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* %deque.
*/
_GLIBCXX_NODISCARD
- reference
+ _GLIBCXX26_CONSTEXPR reference
back() _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
@@ -1581,7 +1619,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* element of the %deque.
*/
_GLIBCXX_NODISCARD
- const_reference
+ _GLIBCXX26_CONSTEXPR const_reference
back() const _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
@@ -1600,7 +1638,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* data to it. Due to the nature of a %deque this operation
* can be done in constant time.
*/
- void
+ _GLIBCXX26_CONSTEXPR void
push_front(const value_type& __x)
{
if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first)
@@ -1615,13 +1653,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
#if __cplusplus >= 201103L
- void
+ _GLIBCXX26_CONSTEXPR void
push_front(value_type&& __x)
{ emplace_front(std::move(__x)); }
template<typename... _Args>
#if __cplusplus > 201402L
- reference
+ _GLIBCXX26_CONSTEXPR reference
#else
void
#endif
@@ -1637,7 +1675,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* to it. Due to the nature of a %deque this operation can be
* done in constant time.
*/
- void
+ _GLIBCXX26_CONSTEXPR void
push_back(const value_type& __x)
{
if (this->_M_impl._M_finish._M_cur
@@ -1652,13 +1690,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
#if __cplusplus >= 201103L
- void
+ _GLIBCXX26_CONSTEXPR void
push_back(value_type&& __x)
{ emplace_back(std::move(__x)); }
template<typename... _Args>
#if __cplusplus > 201402L
- reference
+ _GLIBCXX26_CONSTEXPR reference
#else
void
#endif
@@ -1673,7 +1711,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.
*/
- void
+ _GLIBCXX26_CONSTEXPR void
pop_front() _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
@@ -1696,7 +1734,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.
*/
- void
+ _GLIBCXX26_CONSTEXPR void
pop_back() _GLIBCXX_NOEXCEPT
{
__glibcxx_requires_nonempty();
@@ -1722,7 +1760,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* with T(std::forward<Args>(args)...) before the specified location.
*/
template<typename... _Args>
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
emplace(const_iterator __position, _Args&&... __args);
/**
@@ -1734,7 +1772,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* This function will insert a copy of the given value before the
* specified location.
*/
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
insert(const_iterator __position, const value_type& __x);
#else
/**
@@ -1746,7 +1784,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* This function will insert a copy of the given value before the
* specified location.
*/
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
insert(iterator __position, const value_type& __x);
#endif
@@ -1760,7 +1798,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* This function will insert a copy of the given rvalue before the
* specified location.
*/
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
insert(const_iterator __position, value_type&& __x)
{ return emplace(__position, std::move(__x)); }
@@ -1774,7 +1812,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>.
*/
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
insert(const_iterator __p, initializer_list<value_type> __l)
{
auto __offset = __p - cbegin();
@@ -1793,7 +1831,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.
*/
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
insert(const_iterator __position, size_type __n, const value_type& __x)
{
difference_type __offset = __position - cbegin();
@@ -1810,7 +1848,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.
*/
- void
+ _GLIBCXX26_CONSTEXPR void
insert(iterator __position, size_type __n, const value_type& __x)
{ _M_fill_insert(__position, __n, __x); }
#endif
@@ -1829,7 +1867,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/
template<typename _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
insert(const_iterator __position, _InputIterator __first,
_InputIterator __last)
{
@@ -1850,7 +1888,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* by @a __position. This is known as <em>range insert</em>.
*/
template<typename _InputIterator>
- void
+ _GLIBCXX26_CONSTEXPR void
insert(iterator __position, _InputIterator __first,
_InputIterator __last)
{
@@ -1870,7 +1908,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @since C++23
*/
template<__detail::__container_compatible_range<_Tp> _Rg>
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
insert_range(const_iterator __pos, _Rg&& __rg);
/**
@@ -1879,7 +1917,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @since C++23
*/
template<__detail::__container_compatible_range<_Tp> _Rg>
- void
+ _GLIBCXX26_CONSTEXPR void
prepend_range(_Rg&& __rg);
/**
@@ -1888,7 +1926,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* @since C++23
*/
template<__detail::__container_compatible_range<_Tp> _Rg>
- void
+ _GLIBCXX26_CONSTEXPR void
append_range(_Rg&& __rg);
#endif // containers_ranges
@@ -1905,7 +1943,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* itself a pointer, the pointed-to memory is not touched in any way.
* Managing the pointer is the user's responsibility.
*/
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
#if __cplusplus >= 201103L
erase(const_iterator __position)
#else
@@ -1929,7 +1967,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.
*/
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
#if __cplusplus >= 201103L
erase(const_iterator __first, const_iterator __last)
#else
@@ -1948,7 +1986,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*
* Whether the allocators are swapped depends on the allocator traits.
*/
- void
+ _GLIBCXX26_CONSTEXPR void
swap(deque& __x) _GLIBCXX_NOEXCEPT
{
#if __cplusplus >= 201103L
@@ -1966,7 +2004,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* pointed-to memory is not touched in any way. Managing the pointer is
* the user's responsibility.
*/
- void
+ _GLIBCXX26_CONSTEXPR void
clear() _GLIBCXX_NOEXCEPT
{ _M_erase_at_end(begin()); }
@@ -1998,7 +2036,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
#endif
- static size_t
+ static _GLIBCXX26_CONSTEXPR size_t
_S_check_init_len(size_t __n, const allocator_type& __a)
{
if (__n > _S_max_size(__a))
@@ -2007,7 +2045,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return __n;
}
- static size_type
+ static _GLIBCXX26_CONSTEXPR size_type
_S_max_size(const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT
{
const size_t __diffmax = __gnu_cxx::__numeric_traits<ptrdiff_t>::__max;
@@ -2027,13 +2065,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* push_back on each value from the iterator.
*/
template<typename _InputIterator>
- void
+ _GLIBCXX26_CONSTEXPR void
_M_range_initialize(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag);
// called by the second initialize_dispatch above
template<typename _ForwardIterator>
- void
+ _GLIBCXX26_CONSTEXPR void
_M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
std::forward_iterator_tag);
///@}
@@ -2047,12 +2085,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* This function is called only when the user provides an explicit size
* (with or without an explicit exemplar value).
*/
- void
+ _GLIBCXX26_CONSTEXPR void
_M_fill_initialize(const value_type& __value);
#if __cplusplus >= 201103L
// called by deque(n).
- void
+ _GLIBCXX26_CONSTEXPR void
_M_default_initialize();
#endif
@@ -2079,13 +2117,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// called by the second assign_dispatch above
template<typename _InputIterator>
- void
+ _GLIBCXX26_CONSTEXPR void
_M_assign_aux(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag);
// called by the second assign_dispatch above
template<typename _ForwardIterator>
- void
+ _GLIBCXX26_CONSTEXPR void
_M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
std::forward_iterator_tag)
{
@@ -2104,7 +2142,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// Called by assign(n,t), and the range assign when it turns out
// to be the same thing.
- void
+ _GLIBCXX26_CONSTEXPR void
_M_fill_assign(size_type __n, const value_type& __val)
{
if (__n > size())
@@ -2127,15 +2165,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
void _M_push_front_aux(const value_type&);
#else
template<typename... _Args>
- void _M_push_back_aux(_Args&&... __args);
+ _GLIBCXX26_CONSTEXPR void
+ _M_push_back_aux(_Args&&... __args);
template<typename... _Args>
- void _M_push_front_aux(_Args&&... __args);
+ _GLIBCXX26_CONSTEXPR void
+ _M_push_front_aux(_Args&&... __args);
#endif
- void _M_pop_back_aux();
+ _GLIBCXX26_CONSTEXPR void
+ _M_pop_back_aux();
- void _M_pop_front_aux();
+ _GLIBCXX26_CONSTEXPR void
+ _M_pop_front_aux();
///@}
// Internal insert functions follow. The *_aux functions do the actual
@@ -2147,14 +2189,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 438. Ambiguity in the "do the right thing" clause
template<typename _Integer>
- void
+ _GLIBCXX26_CONSTEXPR void
_M_insert_dispatch(iterator __pos,
_Integer __n, _Integer __x, __true_type)
{ _M_fill_insert(__pos, __n, __x); }
// called by the range insert to implement [23.1.1]/9
template<typename _InputIterator>
- void
+ _GLIBCXX26_CONSTEXPR void
_M_insert_dispatch(iterator __pos,
_InputIterator __first, _InputIterator __last,
__false_type)
@@ -2166,30 +2208,32 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// insert [__first, __last) at the front, assumes distance(__first, __last) is n
template<typename _InputIterator, typename _Sentinel>
- void _M_range_prepend(_InputIterator __first, _Sentinel __last,
- size_type __n);
+ _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>
- void _M_range_append(_InputIterator __first, _Sentinel __last,
- size_type __n);
+ _GLIBCXX26_CONSTEXPR void
+ _M_range_append(_InputIterator __first, _Sentinel __last,
+ size_type __n);
// called by the second insert_dispatch above
template<typename _InputIterator>
- void
+ _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>
- void
+ _GLIBCXX26_CONSTEXPR void
_M_range_insert_aux(iterator __pos, _ForwardIterator __first,
_ForwardIterator __last, std::forward_iterator_tag);
// 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).
- void
+ _GLIBCXX26_CONSTEXPR void
_M_fill_insert(iterator __pos, size_type __n, const value_type& __x);
// called by insert(p,x)
@@ -2200,22 +2244,22 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
struct _Temporary_value
{
template<typename... _Args>
- _GLIBCXX20_CONSTEXPR explicit
+ explicit _GLIBCXX26_CONSTEXPR
_Temporary_value(deque* __deque, _Args&&... __args) : _M_this(__deque)
{
_Alloc_traits::construct(_M_this->_M_impl, _M_ptr(),
std::forward<_Args>(__args)...);
}
- _GLIBCXX20_CONSTEXPR
+ _GLIBCXX26_CONSTEXPR
~_Temporary_value()
{ _Alloc_traits::destroy(_M_this->_M_impl, _M_ptr()); }
- _GLIBCXX20_CONSTEXPR value_type&
+ _GLIBCXX26_CONSTEXPR value_type&
_M_val() noexcept { return __tmp_val; }
private:
- _GLIBCXX20_CONSTEXPR _Tp*
+ _GLIBCXX26_CONSTEXPR _Tp*
_M_ptr() noexcept { return std::__addressof(__tmp_val); }
union
@@ -2226,22 +2270,22 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
deque* _M_this;
};
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
_M_insert_aux(iterator __pos, const value_type& __x)
{ return _M_emplace_aux(__pos, __x); }
template<typename... _Args>
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
_M_emplace_aux(iterator __pos, _Args&&... __args);
#endif
// called by insert(p,n,x) via fill_insert
- void
+ _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>
- void
+ _GLIBCXX26_CONSTEXPR void
_M_insert_aux(iterator __pos,
_ForwardIterator __first, _ForwardIterator __last,
size_type __n);
@@ -2249,17 +2293,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// Internal erase functions follow.
- void
+ _GLIBCXX26_CONSTEXPR void
_M_destroy_data_aux(iterator __first, iterator __last);
// Called by ~deque().
// NB: Doesn't deallocate the nodes.
template<typename _Alloc1>
- void
+ _GLIBCXX26_CONSTEXPR void
_M_destroy_data(iterator __first, iterator __last, const _Alloc1&)
{ _M_destroy_data_aux(__first, __last); }
- void
+ _GLIBCXX26_CONSTEXPR void
_M_destroy_data(iterator __first, iterator __last,
const std::allocator<_Tp>&)
{
@@ -2268,7 +2312,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
// Called by erase(q1, q2).
- void
+ _GLIBCXX26_CONSTEXPR void
_M_erase_at_begin(iterator __pos)
{
_M_destroy_data(begin(), __pos, _M_get_Tp_allocator());
@@ -2278,7 +2322,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// Called by erase(q1, q2), resize(), clear(), _M_assign_aux,
// _M_fill_assign, operator=.
- void
+ _GLIBCXX26_CONSTEXPR void
_M_erase_at_end(iterator __pos)
{
_M_destroy_data(__pos, end(), _M_get_Tp_allocator());
@@ -2287,24 +2331,24 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
this->_M_impl._M_finish = __pos;
}
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
_M_erase(iterator __pos);
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
_M_erase(iterator __first, iterator __last);
#if __cplusplus >= 201103L
// Called by resize(sz).
- void
+ _GLIBCXX26_CONSTEXPR void
_M_default_append(size_type __n);
- bool
+ _GLIBCXX26_CONSTEXPR bool
_M_shrink_to_fit();
#endif
///@{
/// Memory-handling helpers for the previous internal insert functions.
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
_M_reserve_elements_at_front(size_type __n)
{
const size_type __vacancies = this->_M_impl._M_start._M_cur
@@ -2314,7 +2358,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return this->_M_impl._M_start - difference_type(__n);
}
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
_M_reserve_elements_at_back(size_type __n)
{
const size_type __vacancies = (this->_M_impl._M_finish._M_last
@@ -2324,10 +2368,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return this->_M_impl._M_finish + difference_type(__n);
}
- void
+ _GLIBCXX26_CONSTEXPR void
_M_new_elements_at_front(size_type __new_elements);
- void
+ _GLIBCXX26_CONSTEXPR void
_M_new_elements_at_back(size_type __new_elements);
///@}
@@ -2340,7 +2384,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
* actually add the nodes. Can invalidate _M_map pointers.
* (And consequently, %deque iterators.)
*/
- void
+ _GLIBCXX26_CONSTEXPR void
_M_reserve_map_at_back(size_type __nodes_to_add = 1)
{
if (__nodes_to_add + 1 > this->_M_impl._M_map_size
@@ -2348,7 +2392,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_M_reallocate_map(__nodes_to_add, false);
}
- void
+ _GLIBCXX26_CONSTEXPR void
_M_reserve_map_at_front(size_type __nodes_to_add = 1)
{
if (__nodes_to_add > size_type(this->_M_impl._M_start._M_node
@@ -2356,14 +2400,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_M_reallocate_map(__nodes_to_add, true);
}
- void
+ _GLIBCXX26_CONSTEXPR void
_M_reallocate_map(size_type __nodes_to_add, bool __add_at_front);
///@}
#if __cplusplus >= 201103L
// Constant-time, nothrow move assignment when source object's memory
// can be moved because the allocators are equal.
- void
+ _GLIBCXX26_CONSTEXPR void
_M_move_assign1(deque&& __x, /* always equal: */ true_type) noexcept
{
this->_M_impl._M_swap_data(__x._M_impl);
@@ -2374,7 +2418,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// When the allocators are not equal the operation could throw, because
// we might need to allocate a new map for __x after moving from it
// or we might need to allocate new elements for *this.
- void
+ _GLIBCXX26_CONSTEXPR void
_M_move_assign1(deque&& __x, /* always equal: */ false_type)
{
if (_M_get_Tp_allocator() == __x._M_get_Tp_allocator())
@@ -2388,7 +2432,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// Destroy all elements and deallocate all memory, then replace
// with elements created from __args.
template<typename... _Args>
- void
+ _GLIBCXX26_CONSTEXPR void
_M_replace_map(_Args&&... __args)
{
// Create new data first, so if allocation fails there are no effects.
@@ -2404,7 +2448,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
// Do move assignment when the allocator propagates.
- void
+ _GLIBCXX26_CONSTEXPR void
_M_move_assign2(deque&& __x, /* propagate: */ true_type)
{
// Make a copy of the original allocator state.
@@ -2418,7 +2462,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
// Do move assignment when it may not be possible to move source
// object's memory, resulting in a linear-time operation.
- void
+ _GLIBCXX26_CONSTEXPR void
_M_move_assign2(deque&& __x, /* propagate: */ false_type)
{
if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator())
@@ -2469,7 +2513,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/
template<typename _Tp, typename _Alloc>
_GLIBCXX_NODISCARD
- inline bool
+ inline _GLIBCXX26_CONSTEXPR bool
operator==(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
{ return __x.size() == __y.size()
&& std::equal(__x.begin(), __x.end(), __y.begin()); }
@@ -2488,7 +2532,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/
template<typename _Tp, typename _Alloc>
[[nodiscard]]
- inline __detail::__synth3way_t<_Tp>
+ inline _GLIBCXX26_CONSTEXPR __detail::__synth3way_t<_Tp>
operator<=>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
{
return std::lexicographical_compare_three_way(__x.begin(), __x.end(),
@@ -2545,7 +2589,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
/// See std::deque::swap().
template<typename _Tp, typename _Alloc>
- inline void
+ inline _GLIBCXX26_CONSTEXPR void
swap(deque<_Tp,_Alloc>& __x, deque<_Tp,_Alloc>& __y)
_GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
diff --git a/libstdc++-v3/include/bits/stl_queue.h b/libstdc++-v3/include/bits/stl_queue.h
index d9edc4c838de..ced5660bc972 100644
--- a/libstdc++-v3/include/bits/stl_queue.h
+++ b/libstdc++-v3/include/bits/stl_queue.h
@@ -115,16 +115,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
template<typename _Tp1, typename _Seq1>
- friend bool
+ friend _GLIBCXX26_CONSTEXPR bool
operator==(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
template<typename _Tp1, typename _Seq1>
- friend bool
+ friend _GLIBCXX26_CONSTEXPR bool
operator<(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
#if __cpp_lib_three_way_comparison
template<typename _Tp1, three_way_comparable _Seq1>
- friend compare_three_way_result_t<_Seq1>
+ friend _GLIBCXX26_CONSTEXPR compare_three_way_result_t<_Seq1>
operator<=>(const queue<_Tp1, _Seq1>&, const queue<_Tp1, _Seq1>&);
#endif
@@ -171,35 +171,40 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#else
template<typename _Seq = _Sequence, typename _Requires = typename
enable_if<is_default_constructible<_Seq>::value>::type>
+ _GLIBCXX26_CONSTEXPR
queue()
: c() { }
- explicit
+ explicit _GLIBCXX26_CONSTEXPR
queue(const _Sequence& __c)
: c(__c) { }
- explicit
+ explicit _GLIBCXX26_CONSTEXPR
queue(_Sequence&& __c)
: c(std::move(__c)) { }
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
- explicit
+ explicit _GLIBCXX26_CONSTEXPR
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 +212,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 +230,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 +241,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,13 +250,14 @@ _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
- size_type
+ _GLIBCXX26_CONSTEXPR size_type
size() const
{ return c.size(); }
@@ -256,7 +266,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* element of the %queue.
*/
_GLIBCXX_NODISCARD
- reference
+ _GLIBCXX26_CONSTEXPR reference
front()
{
__glibcxx_requires_nonempty();
@@ -268,7 +278,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* element of the %queue.
*/
_GLIBCXX_NODISCARD
- const_reference
+ _GLIBCXX26_CONSTEXPR const_reference
front() const
{
__glibcxx_requires_nonempty();
@@ -280,7 +290,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* element of the %queue.
*/
_GLIBCXX_NODISCARD
- reference
+ _GLIBCXX26_CONSTEXPR reference
back()
{
__glibcxx_requires_nonempty();
@@ -292,7 +302,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* element of the %queue.
*/
_GLIBCXX_NODISCARD
- const_reference
+ _GLIBCXX26_CONSTEXPR const_reference
back() const
{
__glibcxx_requires_nonempty();
@@ -308,18 +318,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* to it. The time complexity of the operation depends on the
* underlying sequence.
*/
- void
+ _GLIBCXX26_CONSTEXPR void
push(const value_type& __x)
{ c.push_back(__x); }
#if __cplusplus >= 201103L
- void
+ _GLIBCXX26_CONSTEXPR void
push(value_type&& __x)
{ c.push_back(std::move(__x)); }
#if __cplusplus > 201402L
template<typename... _Args>
- decltype(auto)
+ _GLIBCXX26_CONSTEXPR decltype(auto)
emplace(_Args&&... __args)
{ return c.emplace_back(std::forward<_Args>(__args)...); }
#else
@@ -332,7 +342,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __glibcxx_containers_ranges // C++ >= 23
template<__detail::__container_compatible_range<_Tp> _Rg>
- void
+ _GLIBCXX26_CONSTEXPR void
push_range(_Rg&& __rg)
{
if constexpr (requires { c.append_range(std::forward<_Rg>(__rg)); })
@@ -353,7 +363,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* data is needed, it should be retrieved before pop() is
* called.
*/
- void
+ _GLIBCXX26_CONSTEXPR void
pop()
{
__glibcxx_requires_nonempty();
@@ -361,7 +371,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
#if __cplusplus >= 201103L
- void
+ _GLIBCXX26_CONSTEXPR void
swap(queue& __q)
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
noexcept(__is_nothrow_swappable<_Sequence>::value)
@@ -430,7 +440,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
template<typename _Tp, typename _Seq>
_GLIBCXX_NODISCARD
- inline bool
+ inline _GLIBCXX26_CONSTEXPR bool
operator==(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return __x.c == __y.c; }
@@ -449,49 +459,49 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
template<typename _Tp, typename _Seq>
_GLIBCXX_NODISCARD
- inline bool
+ inline _GLIBCXX26_CONSTEXPR bool
operator<(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return __x.c < __y.c; }
/// Based on operator==
template<typename _Tp, typename _Seq>
_GLIBCXX_NODISCARD
- inline bool
+ inline _GLIBCXX26_CONSTEXPR bool
operator!=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return !(__x == __y); }
/// Based on operator<
template<typename _Tp, typename _Seq>
_GLIBCXX_NODISCARD
- inline bool
+ inline _GLIBCXX26_CONSTEXPR bool
operator>(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return __y < __x; }
/// Based on operator<
template<typename _Tp, typename _Seq>
_GLIBCXX_NODISCARD
- inline bool
+ inline _GLIBCXX26_CONSTEXPR bool
operator<=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return !(__y < __x); }
/// Based on operator<
template<typename _Tp, typename _Seq>
_GLIBCXX_NODISCARD
- inline bool
+ inline _GLIBCXX26_CONSTEXPR bool
operator>=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return !(__x < __y); }
#if __cpp_lib_three_way_comparison
template<typename _Tp, three_way_comparable _Seq>
[[nodiscard]]
- inline compare_three_way_result_t<_Seq>
+ inline _GLIBCXX26_CONSTEXPR compare_three_way_result_t<_Seq>
operator<=>(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
{ return __x.c <=> __y.c; }
#endif
#if __cplusplus >= 201103L
template<typename _Tp, typename _Seq>
- inline
+ inline _GLIBCXX26_CONSTEXPR
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
// Constrained free swap overload, see p0185r1
typename enable_if<__is_swappable<_Seq>::value>::type
@@ -611,14 +621,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
priority_queue()
: c(), comp() { }
- _GLIBCXX26_CONSTEXPR
- explicit
+ explicit _GLIBCXX26_CONSTEXPR
priority_queue(const _Compare& __x, const _Sequence& __s)
: c(__s), comp(__x)
{ std::make_heap(c.begin(), c.end(), comp); }
- _GLIBCXX26_CONSTEXPR
- explicit
+ explicit _GLIBCXX26_CONSTEXPR
priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence())
: c(std::move(__s)), comp(__x)
{ std::make_heap(c.begin(), c.end(), comp); }
@@ -633,8 +641,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: c(std::move(__q.c)), comp(std::move(__q.comp))
{ __q.c.clear(); }
- _GLIBCXX26_CONSTEXPR
- priority_queue&
+ _GLIBCXX26_CONSTEXPR priority_queue&
operator=(priority_queue&& __q)
noexcept(__and_<is_nothrow_move_assignable<_Sequence>,
is_nothrow_move_assignable<_Compare>>::value)
@@ -646,8 +653,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _Alloc, typename _Requires = _Uses<_Alloc>>
- _GLIBCXX26_CONSTEXPR
- explicit
+ explicit _GLIBCXX26_CONSTEXPR
priority_queue(const _Alloc& __a)
: c(__a), comp() { }
@@ -830,14 +836,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* Returns true if the %queue is empty.
*/
- _GLIBCXX_NODISCARD _GLIBCXX26_CONSTEXPR
- 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
+ _GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR size_type
size() const
{ return c.size(); }
@@ -845,8 +851,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* Returns a read-only (constant) reference to the data at the first
* element of the %queue.
*/
- _GLIBCXX_NODISCARD _GLIBCXX26_CONSTEXPR
- const_reference
+ _GLIBCXX_NODISCARD
+ _GLIBCXX26_CONSTEXPR const_reference
top() const
{
__glibcxx_requires_nonempty();
@@ -861,8 +867,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* The time complexity of the operation depends on the underlying
* sequence.
*/
- _GLIBCXX26_CONSTEXPR
- void
+ _GLIBCXX26_CONSTEXPR void
push(const value_type& __x)
{
c.push_back(__x);
@@ -870,8 +875,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
#if __cplusplus >= 201103L
- _GLIBCXX26_CONSTEXPR
- void
+ _GLIBCXX26_CONSTEXPR void
push(value_type&& __x)
{
c.push_back(std::move(__x));
@@ -879,8 +883,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename... _Args>
- _GLIBCXX26_CONSTEXPR
- void
+ _GLIBCXX26_CONSTEXPR void
emplace(_Args&&... __args)
{
c.emplace_back(std::forward<_Args>(__args)...);
@@ -890,8 +893,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __glibcxx_containers_ranges // C++ >= 23
template<__detail::__container_compatible_range<_Tp> _Rg>
- _GLIBCXX26_CONSTEXPR
- void
+ _GLIBCXX26_CONSTEXPR void
push_range(_Rg&& __rg)
{
if constexpr (requires { c.append_range(std::forward<_Rg>(__rg)); })
@@ -913,8 +915,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* data is needed, it should be retrieved before pop() is
* called.
*/
- _GLIBCXX26_CONSTEXPR
- void
+ _GLIBCXX26_CONSTEXPR void
pop()
{
__glibcxx_requires_nonempty();
@@ -923,8 +924,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
#if __cplusplus >= 201103L
- _GLIBCXX26_CONSTEXPR
- void
+ _GLIBCXX26_CONSTEXPR void
swap(priority_queue& __pq)
noexcept(__and_<
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
@@ -992,8 +992,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus >= 201103L
template<typename _Tp, typename _Sequence, typename _Compare>
- _GLIBCXX26_CONSTEXPR
- inline
+ inline _GLIBCXX26_CONSTEXPR
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
// Constrained free swap overload, see p0185r1
typename enable_if<__and_<__is_swappable<_Sequence>,
diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h b/libstdc++-v3/include/bits/stl_uninitialized.h
index a8791a66ae8f..a418c079d2af 100644
--- a/libstdc++-v3/include/bits/stl_uninitialized.h
+++ b/libstdc++-v3/include/bits/stl_uninitialized.h
@@ -666,6 +666,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus >= 201103L
template<typename _ITp, typename _IRef, typename _IPtr, typename _OTp,
typename _Tp>
+ _GLIBCXX26_CONSTEXPR
_GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
__uninitialized_copy_a(
_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
@@ -674,6 +675,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
allocator<_Tp>&);
template<typename _Iter, typename _OTp, typename _Tp>
+ _GLIBCXX26_CONSTEXPR
__enable_if_t<__is_random_access_iter<_Iter>::value,
_GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>>
__uninitialized_copy_a(_Iter __first, _Iter __last,
@@ -682,6 +684,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _ITp, typename _IRef, typename _IPtr, typename _OTp,
typename _Tp>
+ _GLIBCXX26_CONSTEXPR
_GLIBCXX_STD_C::_Deque_iterator<_OTp, _OTp&, _OTp*>
__uninitialized_move_a(
_GLIBCXX_STD_C::_Deque_iterator<_ITp, _IRef, _IPtr> __first,
@@ -1003,7 +1006,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>
- void
+ _GLIBCXX20_CONSTEXPR void
__uninitialized_default_a(_ForwardIterator __first,
_ForwardIterator __last,
_Allocator& __alloc)
@@ -1018,7 +1021,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if _GLIBCXX_HOSTED
template<typename _ForwardIterator, typename _Tp>
- inline void
+ inline _GLIBCXX20_CONSTEXPR void
__uninitialized_default_a(_ForwardIterator __first,
_ForwardIterator __last,
allocator<_Tp>&)
diff --git a/libstdc++-v3/include/bits/version.def b/libstdc++-v3/include/bits/version.def
index d14d4f4ef25f..b7349fdef639 100644
--- a/libstdc++-v3/include/bits/version.def
+++ b/libstdc++-v3/include/bits/version.def
@@ -1463,6 +1463,24 @@ ftms = {
};
};
+ftms = {
+ name = constexpr_deque;
+ values = {
+ v = 202502;
+ cxxmin = 26;
+ hosted = yes;
+ };
+};
+
+ftms = {
+ name = constexpr_queue;
+ values = {
+ v = 202502;
+ cxxmin = 26;
+ hosted = yes;
+ };
+};
+
ftms = {
name = constrained_equality;
values = {
diff --git a/libstdc++-v3/include/bits/version.h b/libstdc++-v3/include/bits/version.h
index 9a73f771e72e..142d550279f2 100644
--- a/libstdc++-v3/include/bits/version.h
+++ b/libstdc++-v3/include/bits/version.h
@@ -1596,6 +1596,26 @@
#endif /* !defined(__cpp_lib_constexpr_vector) */
#undef __glibcxx_want_constexpr_vector
+#if !defined(__cpp_lib_constexpr_deque)
+# if (__cplusplus > 202302L) && _GLIBCXX_HOSTED
+# 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) */
+#undef __glibcxx_want_constexpr_deque
+
+#if !defined(__cpp_lib_constexpr_queue)
+# if (__cplusplus > 202302L) && _GLIBCXX_HOSTED
+# 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) */
+#undef __glibcxx_want_constexpr_queue
+
#if !defined(__cpp_lib_constrained_equality)
# if (__cplusplus > 202002L) && (__glibcxx_three_way_comparison)
# define __glibcxx_constrained_equality 202411L
diff --git a/libstdc++-v3/include/debug/deque b/libstdc++-v3/include/debug/deque
index 00b4220051e7..9a1f493e494d 100644
--- a/libstdc++-v3/include/debug/deque
+++ b/libstdc++-v3/include/debug/deque
@@ -110,12 +110,15 @@ namespace __debug
deque(const deque&) = default;
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) { }
@@ -123,15 +126,16 @@ namespace __debug
~deque() = default;
#endif
- explicit
+ explicit _GLIBCXX26_CONSTEXPR
deque(const _Allocator& __a)
: _Base(__a) { }
#if __cplusplus >= 201103L
- explicit
+ explicit _GLIBCXX26_CONSTEXPR
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,23 +149,26 @@ namespace __debug
#if __cplusplus >= 201103L
template<class _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
+ _GLIBCXX26_CONSTEXPR
#else
template<class _InputIterator>
#endif
deque(_InputIterator __first, _InputIterator __last,
const _Allocator& __a = _Allocator())
- : _Base(__gnu_debug::__base(
- __glibcxx_check_valid_constructor_range(__first, __last)),
+ : _Base(__gnu_debug::__base(std::__is_constant_evaluated() ? __first
+ : __glibcxx_check_valid_constructor_range(__first, __last)),
__gnu_debug::__base(__last), __a)
{ }
#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) { }
@@ -172,11 +179,12 @@ namespace __debug
deque&
operator=(deque&&) = default;
- deque&
+ _GLIBCXX26_CONSTEXPR deque&
operator=(initializer_list<value_type> __l)
{
_Base::operator=(__l);
- this->_M_invalidate_all();
+ if (!std::__is_constant_evaluated())
+ this->_M_invalidate_all();
return *this;
}
#endif
@@ -187,9 +195,13 @@ namespace __debug
#else
template<class _InputIterator>
#endif
- void
+ _GLIBCXX26_CONSTEXPR void
assign(_InputIterator __first, _InputIterator __last)
{
+ if (std::__is_constant_evaluated())
+ return _Base::assign(__gnu_debug::__unsafe(__first),
+ __gnu_debug::__unsafe(__last));
+
typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
__glibcxx_check_valid_range2(__first, __last, __dist);
if (__dist.second >= __gnu_debug::__dp_sign)
@@ -201,29 +213,32 @@ namespace __debug
this->_M_invalidate_all();
}
- void
+ _GLIBCXX26_CONSTEXPR void
assign(size_type __n, const _Tp& __t)
{
_Base::assign(__n, __t);
- this->_M_invalidate_all();
+ if (!std::__is_constant_evaluated())
+ this->_M_invalidate_all();
}
#if __cplusplus >= 201103L
- void
+ _GLIBCXX26_CONSTEXPR void
assign(initializer_list<value_type> __l)
{
_Base::assign(__l);
- this->_M_invalidate_all();
+ if (!std::__is_constant_evaluated())
+ this->_M_invalidate_all();
}
#endif
#if __glibcxx_containers_ranges // C++ >= 23
template<std::__detail::__container_compatible_range<_Tp> _Rg>
- void
+ _GLIBCXX26_CONSTEXPR void
assign_range(_Rg&& __rg)
{
_Base::assign_range(std::forward<_Rg>(__rg));
- this->_M_invalidate_all();
+ if (!std::__is_constant_evaluated())
+ this->_M_invalidate_all();
}
#endif
@@ -231,69 +246,69 @@ namespace __debug
// iterators:
_GLIBCXX_NODISCARD
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
begin() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::begin(), this); }
_GLIBCXX_NODISCARD
- const_iterator
+ _GLIBCXX26_CONSTEXPR const_iterator
begin() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::begin(), this); }
_GLIBCXX_NODISCARD
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
end() _GLIBCXX_NOEXCEPT
{ return iterator(_Base::end(), this); }
_GLIBCXX_NODISCARD
- const_iterator
+ _GLIBCXX26_CONSTEXPR const_iterator
end() const _GLIBCXX_NOEXCEPT
{ return const_iterator(_Base::end(), this); }
_GLIBCXX_NODISCARD
- reverse_iterator
+ _GLIBCXX26_CONSTEXPR reverse_iterator
rbegin() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(end()); }
_GLIBCXX_NODISCARD
- const_reverse_iterator
+ _GLIBCXX26_CONSTEXPR const_reverse_iterator
rbegin() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(end()); }
_GLIBCXX_NODISCARD
- reverse_iterator
+ _GLIBCXX26_CONSTEXPR reverse_iterator
rend() _GLIBCXX_NOEXCEPT
{ return reverse_iterator(begin()); }
_GLIBCXX_NODISCARD
- const_reverse_iterator
+ _GLIBCXX26_CONSTEXPR const_reverse_iterator
rend() const _GLIBCXX_NOEXCEPT
{ return const_reverse_iterator(begin()); }
#if __cplusplus >= 201103L
[[__nodiscard__]]
- const_iterator
+ _GLIBCXX26_CONSTEXPR const_iterator
cbegin() const noexcept
{ return const_iterator(_Base::begin(), this); }
[[__nodiscard__]]
- const_iterator
+ _GLIBCXX26_CONSTEXPR const_iterator
cend() const noexcept
{ return const_iterator(_Base::end(), this); }
[[__nodiscard__]]
- const_reverse_iterator
+ _GLIBCXX26_CONSTEXPR const_reverse_iterator
crbegin() const noexcept
{ return const_reverse_iterator(end()); }
[[__nodiscard__]]
- const_reverse_iterator
+ _GLIBCXX26_CONSTEXPR const_reverse_iterator
crend() const noexcept
{ return const_reverse_iterator(begin()); }
#endif
private:
- void
+ _GLIBCXX26_CONSTEXPR void
_M_invalidate_after_nth(difference_type __n)
{
typedef __gnu_debug::_After_nth_from<_Base_const_iterator> _After_nth;
@@ -306,9 +321,12 @@ namespace __debug
using _Base::max_size;
#if __cplusplus >= 201103L
- void
+ _GLIBCXX26_CONSTEXPR void
resize(size_type __sz)
{
+ if (std::__is_constant_evaluated())
+ return _Base::resize(__sz);
+
bool __invalidate_all = __sz > this->size();
if (__sz < this->size())
this->_M_invalidate_after_nth(__sz);
@@ -319,9 +337,12 @@ namespace __debug
this->_M_invalidate_all();
}
- void
+ _GLIBCXX26_CONSTEXPR void
resize(size_type __sz, const _Tp& __c)
{
+ if (std::__is_constant_evaluated())
+ return _Base::resize(__sz, __c);
+
bool __invalidate_all = __sz > this->size();
if (__sz < this->size())
this->_M_invalidate_after_nth(__sz);
@@ -347,11 +368,12 @@ namespace __debug
#endif
#if __cplusplus >= 201103L
- void
+ _GLIBCXX26_CONSTEXPR void
shrink_to_fit() noexcept
{
if (_Base::_M_shrink_to_fit())
- this->_M_invalidate_all();
+ if (!std::__is_constant_evaluated())
+ this->_M_invalidate_all();
}
#endif
@@ -359,7 +381,7 @@ namespace __debug
// element access:
_GLIBCXX_NODISCARD
- reference
+ _GLIBCXX26_CONSTEXPR reference
operator[](size_type __n) _GLIBCXX_NOEXCEPT
{
__glibcxx_check_subscript(__n);
@@ -367,7 +389,7 @@ namespace __debug
}
_GLIBCXX_NODISCARD
- const_reference
+ _GLIBCXX26_CONSTEXPR const_reference
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
{
__glibcxx_check_subscript(__n);
@@ -377,7 +399,7 @@ namespace __debug
using _Base::at;
_GLIBCXX_NODISCARD
- reference
+ _GLIBCXX26_CONSTEXPR reference
front() _GLIBCXX_NOEXCEPT
{
__glibcxx_check_nonempty();
@@ -385,7 +407,7 @@ namespace __debug
}
_GLIBCXX_NODISCARD
- const_reference
+ _GLIBCXX26_CONSTEXPR const_reference
front() const _GLIBCXX_NOEXCEPT
{
__glibcxx_check_nonempty();
@@ -393,7 +415,7 @@ namespace __debug
}
_GLIBCXX_NODISCARD
- reference
+ _GLIBCXX26_CONSTEXPR reference
back() _GLIBCXX_NOEXCEPT
{
__glibcxx_check_nonempty();
@@ -401,7 +423,7 @@ namespace __debug
}
_GLIBCXX_NODISCARD
- const_reference
+ _GLIBCXX26_CONSTEXPR const_reference
back() const _GLIBCXX_NOEXCEPT
{
__glibcxx_check_nonempty();
@@ -409,14 +431,14 @@ namespace __debug
}
// 23.2.1.3 modifiers:
- void
+ _GLIBCXX26_CONSTEXPR void
push_front(const _Tp& __x)
{
_Base::push_front(__x);
this->_M_invalidate_all();
}
- void
+ _GLIBCXX26_CONSTEXPR void
push_back(const _Tp& __x)
{
_Base::push_back(__x);
@@ -424,24 +446,25 @@ namespace __debug
}
#if __cplusplus >= 201103L
- void
+ _GLIBCXX26_CONSTEXPR void
push_front(_Tp&& __x)
{ emplace_front(std::move(__x)); }
- void
+ _GLIBCXX26_CONSTEXPR void
push_back(_Tp&& __x)
{ emplace_back(std::move(__x)); }
template<typename... _Args>
#if __cplusplus > 201402L
- reference
+ _GLIBCXX26_CONSTEXPR reference
#else
void
#endif
emplace_front(_Args&&... __args)
{
_Base::emplace_front(std::forward<_Args>(__args)...);
- this->_M_invalidate_all();
+ if (!std::__is_constant_evaluated())
+ this->_M_invalidate_all();
#if __cplusplus > 201402L
return front();
#endif
@@ -449,23 +472,29 @@ namespace __debug
template<typename... _Args>
#if __cplusplus > 201402L
- reference
+ _GLIBCXX26_CONSTEXPR reference
#else
void
#endif
emplace_back(_Args&&... __args)
{
_Base::emplace_back(std::forward<_Args>(__args)...);
- this->_M_invalidate_all();
+ if (!std::__is_constant_evaluated())
+ this->_M_invalidate_all();
#if __cplusplus > 201402L
return back();
#endif
}
template<typename... _Args>
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
emplace(const_iterator __position, _Args&&... __args)
{
+ if (std::__is_constant_evaluated())
+ return iterator(_Base::emplace(__position.base(),
+ std::forward<_Args>(__args)...),
+ this);
+
__glibcxx_check_insert(__position);
_Base_iterator __res = _Base::emplace(__position.base(),
std::forward<_Args>(__args)...);
@@ -474,13 +503,16 @@ namespace __debug
}
#endif
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
#if __cplusplus >= 201103L
insert(const_iterator __position, const _Tp& __x)
#else
insert(iterator __position, const _Tp& __x)
#endif
{
+ if (std::__is_constant_evaluated())
+ return iterator(_Base::insert(__position.base(), __x), this);
+
__glibcxx_check_insert(__position);
_Base_iterator __res = _Base::insert(__position.base(), __x);
this->_M_invalidate_all();
@@ -488,13 +520,16 @@ namespace __debug
}
#if __cplusplus >= 201103L
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
insert(const_iterator __position, _Tp&& __x)
{ return emplace(__position, std::move(__x)); }
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
insert(const_iterator __position, initializer_list<value_type> __l)
{
+ if (std::__is_constant_evaluated())
+ return iterator(_Base::insert(__position.base(), __l), this);
+
__glibcxx_check_insert(__position);
_Base_iterator __res = _Base::insert(__position.base(), __l);
this->_M_invalidate_all();
@@ -503,9 +538,12 @@ namespace __debug
#endif
#if __cplusplus >= 201103L
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
insert(const_iterator __position, size_type __n, const _Tp& __x)
{
+ if (std::__is_constant_evaluated())
+ return iterator(_Base::insert(__position.base(), __n, __x), this);
+
__glibcxx_check_insert(__position);
_Base_iterator __res = _Base::insert(__position.base(), __n, __x);
this->_M_invalidate_all();
@@ -524,10 +562,15 @@ namespace __debug
#if __cplusplus >= 201103L
template<class _InputIterator,
typename = std::_RequireInputIter<_InputIterator>>
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
insert(const_iterator __position,
_InputIterator __first, _InputIterator __last)
{
+ if (std::__is_constant_evaluated())
+ return iterator(_Base::insert(__position.base(),
+ __gnu_debug::__unsafe(__first),
+ __gnu_debug::__unsafe(__last)), this);
+
typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
__glibcxx_check_insert_range(__position, __first, __last, __dist);
_Base_iterator __res;
@@ -563,54 +606,66 @@ namespace __debug
#if __glibcxx_containers_ranges // C++ >= 23
template<__detail::__container_compatible_range<_Tp> _Rg>
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
insert_range(const_iterator __pos, _Rg&& __rg)
{
auto __res = _Base::insert_range(__pos.base(), std::forward<_Rg>(__rg));
- this->_M_invalidate_all();
+ if (!std::__is_constant_evaluated())
+ this->_M_invalidate_all();
return iterator(__res, this);
}
template<std::__detail::__container_compatible_range<_Tp> _Rg>
- void
+ _GLIBCXX26_CONSTEXPR void
prepend_range(_Rg&& __rg)
{
_Base::prepend_range(std::forward<_Rg>(__rg));
- this->_M_invalidate_all();
+ if (!std::__is_constant_evaluated())
+ this->_M_invalidate_all();
}
template<std::__detail::__container_compatible_range<_Tp> _Rg>
- void
+ _GLIBCXX26_CONSTEXPR void
append_range(_Rg&& __rg)
{
_Base::append_range(std::forward<_Rg>(__rg));
- this->_M_invalidate_all();
+ if (!std::__is_constant_evaluated())
+ this->_M_invalidate_all();
}
#endif
- void
+ _GLIBCXX26_CONSTEXPR void
pop_front() _GLIBCXX_NOEXCEPT
{
- __glibcxx_check_nonempty();
- this->_M_invalidate_if(_Equal(_Base::begin()));
+ if (!std::__is_constant_evaluated())
+ {
+ __glibcxx_check_nonempty();
+ this->_M_invalidate_if(_Equal(_Base::begin()));
+ }
_Base::pop_front();
}
- void
+ _GLIBCXX26_CONSTEXPR void
pop_back() _GLIBCXX_NOEXCEPT
{
- __glibcxx_check_nonempty();
- this->_M_invalidate_if(_Equal(--_Base::end()));
+ if (!std::__is_constant_evaluated())
+ {
+ __glibcxx_check_nonempty();
+ this->_M_invalidate_if(_Equal(_Base::begin()));
+ }
_Base::pop_back();
}
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
#if __cplusplus >= 201103L
erase(const_iterator __position)
#else
- erase(iterator __position)
+ erase(iterator __position)
#endif
{
+ if (std::__is_constant_evaluated())
+ return iterator(_Base::erase(__position.base()), this);
+
__glibcxx_check_erase(__position);
#if __cplusplus >= 201103L
_Base_const_iterator __victim = __position.base();
@@ -630,13 +685,16 @@ namespace __debug
}
}
- iterator
+ _GLIBCXX26_CONSTEXPR iterator
#if __cplusplus >= 201103L
erase(const_iterator __first, const_iterator __last)
#else
erase(iterator __first, iterator __last)
#endif
{
+ if (std::__is_constant_evaluated())
+ return iterator(_Base::erase(__first.base(), __last.base()), this);
+
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container
__glibcxx_check_erase_range(__first, __last);
@@ -677,25 +735,27 @@ namespace __debug
}
}
- void
+ _GLIBCXX26_CONSTEXPR void
swap(deque& __x)
_GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
{
- _Safe::_M_swap(__x);
+ if (!std::__is_constant_evaluated())
+ _Safe::_M_swap(__x);
_Base::swap(__x);
}
- void
+ _GLIBCXX26_CONSTEXPR void
clear() _GLIBCXX_NOEXCEPT
{
_Base::clear();
- this->_M_invalidate_all();
+ if (!std::__is_constant_evaluated())
+ this->_M_invalidate_all();
}
- _Base&
+ _GLIBCXX26_CONSTEXPR _Base&
_M_base() _GLIBCXX_NOEXCEPT { return *this; }
- const _Base&
+ _GLIBCXX26_CONSTEXPR const _Base&
_M_base() const _GLIBCXX_NOEXCEPT { return *this; }
};
@@ -722,7 +782,7 @@ namespace __debug
#endif
template<typename _Tp, typename _Alloc>
- inline bool
+ inline _GLIBCXX26_CONSTEXPR bool
operator==(const deque<_Tp, _Alloc>& __lhs,
const deque<_Tp, _Alloc>& __rhs)
{ return __lhs._M_base() == __rhs._M_base(); }
@@ -765,7 +825,7 @@ namespace __debug
#endif // three-way comparison
template<typename _Tp, typename _Alloc>
- inline void
+ inline _GLIBCXX26_CONSTEXPR void
swap(deque<_Tp, _Alloc>& __lhs, deque<_Tp, _Alloc>& __rhs)
_GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
{ __lhs.swap(__rhs); }
@@ -775,14 +835,14 @@ namespace __debug
#ifdef __glibcxx_erase_if // C++ >= 20 && HOSTED
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp, typename _Alloc, typename _Predicate>
- inline typename __debug::deque<_Tp, _Alloc>::size_type
+ inline _GLIBCXX26_CONSTEXPR typename __debug::deque<_Tp, _Alloc>::size_type
erase_if(__debug::deque<_Tp, _Alloc>& __cont, _Predicate __pred)
{
return __detail::__erase_if(__cont, __cont._M_base(), std::move(__pred));
}
template<typename _Tp, typename _Alloc, typename _Up = _Tp>
- inline typename __debug::deque<_Tp, _Alloc>::size_type
+ inline _GLIBCXX26_CONSTEXPR typename __debug::deque<_Tp, _Alloc>::size_type
erase(__debug::deque<_Tp, _Alloc>& __cont, const _Up& __value)
{ return std::erase_if(__cont, __gnu_cxx::__ops::__equal_to(__value)); }
_GLIBCXX_END_NAMESPACE_VERSION
diff --git a/libstdc++-v3/include/std/deque b/libstdc++-v3/include/std/deque
index 3b2f34fc7075..f889c2cf4c7f 100644
--- a/libstdc++-v3/include/std/deque
+++ b/libstdc++-v3/include/std/deque
@@ -73,6 +73,7 @@
#define __glibcxx_want_algorithm_default_value_type
#define __glibcxx_want_allocator_traits_is_always_equal
+#define __glibcxx_want_constexpr_deque
#define __glibcxx_want_containers_ranges
#define __glibcxx_want_erase_if
#define __glibcxx_want_hardened_deque
@@ -103,13 +104,15 @@ namespace std _GLIBCXX_VISIBILITY(default)
_GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp, typename _Alloc, typename _Predicate>
- inline typename _GLIBCXX_STD_C::deque<_Tp, _Alloc>::size_type
+ inline _GLIBCXX26_CONSTEXPR
+ 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)>
- inline typename _GLIBCXX_STD_C::deque<_Tp, _Alloc>::size_type
+ inline _GLIBCXX26_CONSTEXPR
+ 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 13e254821254..061e7cae5d35 100644
--- a/libstdc++-v3/include/std/queue
+++ b/libstdc++-v3/include/std/queue
@@ -63,6 +63,7 @@
#define __glibcxx_want_adaptor_iterator_pair_constructor
#define __glibcxx_want_containers_ranges
+#define __glibcxx_want_constexpr_queue
#include <bits/version.h>
#include <deque>
@@ -74,6 +75,12 @@
#ifdef __glibcxx_format_ranges // C++ >= 23 && HOSTED
#include <bits/formatfwd.h>
+#ifdef __glibcxx_constexpr_format // C++ >= 26 && HOSTED && CXX11 strings
+# define _GLIBCXX_CONSTEXPR_FORMAT constexpr
+#else
+# define _GLIBCXX_CONSTEXPR_FORMAT
+#endif
+
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -99,6 +106,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Standard declares this as template accepting unconstrained
// FormatContext type.
template<typename _Out>
+ _GLIBCXX_CONSTEXPR_FORMAT
typename basic_format_context<_Out, _CharT>::iterator
format(__maybe_const_adaptor& __a,
basic_format_context<_Out, _CharT>& __fc) const
@@ -141,6 +149,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Standard declares this as template accepting unconstrained
// FormatContext type.
template<typename _Out>
+ _GLIBCXX_CONSTEXPR_FORMAT
typename basic_format_context<_Out, _CharT>::iterator
format(__maybe_const_adaptor& __a,
basic_format_context<_Out, _CharT>& __fc) const
@@ -163,6 +172,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
priority_queue<_Tp, _Container, _Comparator>> = false;
#endif
+#undef _GLIBCXX_CONSTEXPR_FORMAT
+
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // __glibcxx_format_ranges
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 000000000000..50e45a639abd
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/deque/constexpr.cc
@@ -0,0 +1,334 @@
+// { dg-do compile { target c++26 } }
+
+#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>
+
+using namespace __gnu_test;
+
+template<typename Alloc>
+constexpr bool
+ctor_tests()
+{
+ Alloc alloc;
+
+ 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};
+ std::deque<int> dq5(rg.begin(), rg.end());
+ VERIFY( dq5.front() == 2 );
+ VERIFY( dq5.back() == 7 );
+ VERIFY( dq5.size() == 4 );
+
+ std::deque<int> dq6(std::from_range, rg);
+ VERIFY( dq6 == dq5 );
+
+ std::deque<int> dq1{1, 2, 3};
+ 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;
+}
+static_assert( ctor_tests<std::allocator<int>>() );
+static_assert( ctor_tests<SimpleAllocator<int>>() );
+
+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<typename Range>
+constexpr bool
+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 );
+
+ return true;
+}
+
+static_assert( ranges_test<test_forward_range<int>>() );
+static_assert( ranges_test<test_forward_sized_range<int>>() );
+static_assert( ranges_test<test_sized_range_sized_sent<int, forward_iterator_wrapper>>() );
+
+static_assert( ranges_test<test_input_range<int>>() );
+static_assert( ranges_test<test_input_sized_range<int>>() );
+static_assert( ranges_test<test_sized_range_sized_sent<int, input_iterator_wrapper>>() );
+
+static_assert( ranges_test<test_range<int, input_iterator_wrapper_nocopy>>() );
+static_assert( ranges_test<test_sized_range<int, input_iterator_wrapper_nocopy>>() );
+static_assert( ranges_test<test_sized_range_sized_sent<int, input_iterator_wrapper_nocopy>>() );
+
+static_assert( ranges_test<test_forward_range<short>>() );
+static_assert( ranges_test<test_input_range<short>>() );
+
+// Not lvalue-convertible to int
+struct C {
+ constexpr C(int v) : val(v) { }
+ constexpr operator int() && { return val; }
+
+ friend bool operator==(C c, C b) = default;
+ friend constexpr bool operator==(C c, int b)
+ { return b == c.val; }
+
+ int val;
+};
+using rvalue_input_range = test_range<C, input_iterator_wrapper_rval>;
+static_assert( ranges_test<rvalue_input_range>() );
diff --git a/libstdc++-v3/testsuite/23_containers/headers/deque/synopsis.cc b/libstdc++-v3/testsuite/23_containers/headers/deque/synopsis.cc
index 48e895920590..447eefd63197 100644
--- a/libstdc++-v3/testsuite/23_containers/headers/deque/synopsis.cc
+++ b/libstdc++-v3/testsuite/23_containers/headers/deque/synopsis.cc
@@ -21,6 +21,12 @@
#include <deque>
+#if __cplusplus > 202302L
+# define CONSTEXPR constexpr
+#else
+# define CONSTEXPR
+#endif
+
#if __cplusplus >= 201103L
# define NOTHROW(X) noexcept(X)
#else
@@ -31,24 +37,30 @@ namespace std {
template <class T, class Allocator> class deque;
template <class T, class Allocator>
- bool operator== (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+ CONSTEXPR bool
+ operator== (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
template <class T, class Allocator>
- bool operator< (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+ CONSTEXPR bool
+ operator< (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
template <class T, class Allocator>
- bool operator!= (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+ CONSTEXPR bool
+ operator!= (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
template <class T, class Allocator>
- bool operator> (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+ CONSTEXPR bool
+ operator> (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
template <class T, class Allocator>
- bool operator>= (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+ CONSTEXPR bool
+ operator>= (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
template <class T, class Allocator>
- bool operator<= (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
+ CONSTEXPR bool
+ operator<= (const deque<T,Allocator>& x, const deque<T,Allocator>& y);
template <class T, class Allocator>
- void swap(deque<T,Allocator>& x, deque<T,Allocator>& y)
+ CONSTEXPR void swap(deque<T,Allocator>& x, deque<T,Allocator>& y)
NOTHROW(noexcept(x.swap(y)));
}
diff --git a/libstdc++-v3/testsuite/23_containers/headers/queue/synopsis.cc b/libstdc++-v3/testsuite/23_containers/headers/queue/synopsis.cc
index b30af563359a..9ebf4b7074a7 100644
--- a/libstdc++-v3/testsuite/23_containers/headers/queue/synopsis.cc
+++ b/libstdc++-v3/testsuite/23_containers/headers/queue/synopsis.cc
@@ -20,6 +20,12 @@
#include <queue>
+#if __cplusplus > 202302L
+# define CONSTEXPR constexpr
+#else
+# define CONSTEXPR
+#endif
+
#if __cplusplus >= 201103L
# define NOTHROW noexcept
#else
@@ -29,28 +35,28 @@
namespace std {
template <class T, class Container> class queue;
template <class T, class Container>
- bool operator==(const queue<T, Container>& x,
- const queue<T, Container>& y);
-
+ CONSTEXPR bool
+ operator==(const queue<T, Container>& x, const queue<T, Container>& y);
+
template <class T, class Container>
- bool operator< (const queue<T, Container>& x,
- const queue<T, Container>& y);
+ CONSTEXPR bool
+ operator< (const queue<T, Container>& x, const queue<T, Container>& y);
template <class T, class Container>
- bool operator!=(const queue<T, Container>& x,
- const queue<T, Container>& y);
+ CONSTEXPR bool
+ operator!=(const queue<T, Container>& x, const queue<T, Container>& y);
template <class T, class Container>
- bool operator> (const queue<T, Container>& x,
- const queue<T, Container>& y);
+ CONSTEXPR bool
+ operator> (const queue<T, Container>& x, const queue<T, Container>& y);
template <class T, class Container>
- bool operator>=(const queue<T, Container>& x,
- const queue<T, Container>& y);
+ CONSTEXPR bool
+ operator>=(const queue<T, Container>& x, const queue<T, Container>& y);
template <class T, class Container>
- bool operator<=(const queue<T, Container>& x,
- const queue<T, Container>& y);
+ CONSTEXPR bool
+ operator<=(const queue<T, Container>& x, const queue<T, Container>& y);
template <class T, class Container, class Compare>
class priority_queue;
diff --git a/libstdc++-v3/testsuite/23_containers/priority_queue/constexpr.cc b/libstdc++-v3/testsuite/23_containers/priority_queue/constexpr.cc
index fe85617416d0..9cc6f932adb8 100644
--- a/libstdc++-v3/testsuite/23_containers/priority_queue/constexpr.cc
+++ b/libstdc++-v3/testsuite/23_containers/priority_queue/constexpr.cc
@@ -1,43 +1,238 @@
// { dg-do compile { target c++26 } }
+
#include <queue>
-constexpr bool test_constexpr_priority_queue() {
- std::priority_queue<int> pq;
- if (!pq.empty()) return false;
- if (pq.size() != 0) return false;
+#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>
+
+using namespace __gnu_test;
+
+template<typename Cont, typename Cmp = std::less<int>>
+constexpr bool
+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 );
- pq.push(10);
- if (pq.empty()) return false;
- if (pq.size() != 1) return false;
- if (pq.top() != 10) return false;
+ std::priority_queue<V, Cont, Cmp> pq5(pq3);
+ VERIFY( pq5.top() == pq3.top() );
+ VERIFY( pq5.size() == pq3.size() );
- pq.emplace(30);
- pq.emplace(20);
- if (pq.size() != 3) return false;
- if (pq.top() != 30) return false;
+ 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() );
+ return true;
+}
+static_assert( ctor_tests<std::vector<int>>() );
+static_assert( ctor_tests<std::vector<int>, std::greater<int>>() );
+static_assert( ctor_tests<std::vector<int, SimpleAllocator<int>>>() );
+static_assert( ctor_tests<std::deque<int>>() );
+static_assert( ctor_tests<std::deque<int>, std::greater<int>>() );
+static_assert( ctor_tests<std::deque<int, SimpleAllocator<int>>>() );
+
+constexpr bool
+push_and_pop_test()
+{
+ std::priority_queue<int> a;
+ a.push(2);
+ a.push(4);
+ VERIFY( a.top() == 4 );
+ a.pop();
+ VERIFY( a.top() == 2 );
+ a.pop();
+ VERIFY( a.empty() );
+ return true;
+}
+static_assert( push_and_pop_test() );
+
+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());
+
+constexpr bool
+emplace_test()
+{
+ struct S
+ {
+ int foo;
+ constexpr S(int i, int j) : foo{i + j} {}
+ std::strong_ordering operator<=>(const S&) const = default;
+ };
+
+ std::priority_queue<S> pq;
+ pq.emplace(0, 0);
+ pq.emplace(1, 0);
+ VERIFY( pq.size() == 2 );
+ VERIFY( pq.top().foo == 1 );
pq.pop();
- if (pq.size() != 2) return false;
- if (pq.top() != 20) return false;
+ VERIFY ( pq.top().foo == 0 );
+ return true;
+}
+static_assert( emplace_test() );
+
+template<typename Range, typename Cont, typename Cmp>
+constexpr void
+do_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>;
- std::priority_queue<int> pq2;
- pq2 = pq;
- if (pq2.size() != 2) return false;
- if (pq2.top() != 20) return false;
+ 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}) );
+
+ std::priority_queue<V, Cont, Cmp>
+ pq2(std::from_range, Range(rg, rg+5), alloc);
+ VERIFY( eq(pq2, {rg, 5}) );
+
+ std::priority_queue<V, Cont, Cmp>
+ pq3(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}) );
+}
+
+template<typename Range, typename Cont>
+constexpr void
+do_ranges_tests_b()
+{
+ do_range_tests<Range, Cont, std::less<>>();
+ do_range_tests<Range, Cont, std::greater<>>();
+}
- std::priority_queue<int> pq3;
- pq3.push(100);
- pq.swap(pq3);
- if (pq.size() != 1 || pq.top() != 100) return false;
- if (pq3.size() != 2 || pq3.top() != 20) return false;
+template<typename Cont>
+constexpr bool
+ranges_tests() {
+ using T = typename Cont::value_type;
+ 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>();
- int arr[] = {50, 200, 10};
- pq.push_range(arr);
- if (pq.size() != 4) return false;
- if (pq.top() != 200) return false;
+ 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>();
return true;
}
-static_assert(test_constexpr_priority_queue(),
- "constexpr priority_queue test failed!");
+static_assert( ranges_tests<std::vector<int>>() );
+static_assert( ranges_tests<std::vector<int, SimpleAllocator<int>>>() );
+static_assert( ranges_tests<std::deque<int, SimpleAllocator<int>>>() );
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 000000000000..01dbc53b4ff5
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/queue/constexpr.cc
@@ -0,0 +1,242 @@
+// { dg-do compile { target c++26 } }
+
+#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>
+
+using namespace __gnu_test;
+
+template<typename Cont>
+constexpr bool
+ctor_tests()
+{
+ using Tp = typename Cont::value_type;
+ using Alloc = typename Cont::allocator_type;
+
+ auto eq = [] (std::queue<Tp, Cont> 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;
+ };
+
+ Cont c0;
+ Alloc alloc0;
+
+ std::queue<Tp, Cont> q1(c0);
+ VERIFY( q1.size() == 0 && q1.empty() );
+ q1.push(1);
+ q1.push(2);
+ VERIFY( q1.size() == 2) ;
+
+ Cont c1{1, 2};
+ std::queue<Tp, Cont> q2(c1);
+ VERIFY ( q2 == q1 );
+ std::queue<Tp, Cont> q3(std::move(c1));
+ VERIFY ( q3 == q1 );
+
+ std::queue<Tp, Cont> q4(q1);
+ std::queue<Tp, Cont> q5(std::move(q1));
+ VERIFY ( q4 == q5 );
+
+ Tp rg[4] = {2, 3, 5, 7};
+ std::queue<Tp, Cont> q6(std::begin(rg), std::end(rg));
+ 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();
+
+ std::queue<Tp, Cont> q7(alloc0);
+ q7.push(1);
+ q7.push(2);
+ VERIFY( q7.size() == 2 );
+
+ Cont c2{1, 2};
+ std::queue<Tp, Cont> q8(c2, alloc0);
+ VERIFY( q8 == q7 );
+ std::queue<Tp, Cont> q9(std::move(c2), alloc0);
+ VERIFY( q9 == q7 );
+ VERIFY( c2.empty() );
+
+ std::queue<Tp, Cont> q10(q7, alloc0);
+ VERIFY( q10 == q7 );
+ VERIFY( q10.size() == q7.size() );
+ VERIFY( q10.front() == q7.front() );
+ VERIFY( q10.back() == q7.back() );
+
+ std::queue<Tp, Cont> q11(std::move(q7), alloc0);
+ VERIFY( q11 == q10 );
+ VERIFY( q11.size() == q10.size() );
+ VERIFY( q7.empty() );
+
+ std::queue<Tp, Cont> 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();
+
+ std::queue<Tp, Cont> q13(std::from_range, rg);
+ VERIFY( eq(q13, rg) );
+ std::queue<Tp, Cont> q14(std::from_range, rg, alloc0);
+ VERIFY( eq(q14, rg) );
+
+ return true;
+}
+// TODO check list when avaialble
+static_assert( ctor_tests<std::deque<int>>() );
+static_assert( ctor_tests<std::deque<int, SimpleAllocator<int>>>() );
+
+template<typename Range, typename Cont>
+constexpr void
+do_ranges_tests_a()
+{
+ using Tp = typename Cont::value_type;
+ typename Cont::allocator_type 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;
+ };
+
+ std::queue<Tp, Cont> q1(std::from_range, Range(a, a+4));
+ std::queue<Tp> q2;
+ q2.push_range(Range(a, a+4));
+ VERIFY( eq(q1, q2) );
+
+ std::queue<Tp, Cont> q3(std::from_range, Range(a, a+4), alloc);
+ std::queue<Tp, Cont> q4(std::from_range, Range(a, a+4));
+ VERIFY( eq(q3, q4) );
+}
+
+template<typename Cont>
+constexpr bool
+ranges_tests()
+{
+ using Tp = typename Cont::value_type;
+
+ do_ranges_tests_a<test_forward_range<Tp>, Cont>();
+ do_ranges_tests_a<test_forward_sized_range<Tp>, Cont>();
+ do_ranges_tests_a<
+ test_sized_range_sized_sent<Tp, forward_iterator_wrapper>, Cont>();
+
+ do_ranges_tests_a<test_input_range<Tp>, Cont>();
+ do_ranges_tests_a<test_input_sized_range<Tp>, Cont>();
+ do_ranges_tests_a<
+ test_sized_range_sized_sent<Tp, forward_iterator_wrapper>, Cont>();
+
+ do_ranges_tests_a<
+ test_range<Tp, input_iterator_wrapper_nocopy>, Cont>();
+ do_ranges_tests_a<
+ test_sized_range<Tp, input_iterator_wrapper_nocopy>, Cont>();
+ do_ranges_tests_a<
+ test_sized_range_sized_sent<Tp, input_iterator_wrapper_nocopy>, Cont>();
+ return true;
+}
+// TODO check list when avaialble
+static_assert( ranges_tests<std::deque<int>>() );
+static_assert( ranges_tests<std::deque<int, SimpleAllocator<int>>>() );
+
+constexpr bool
+push_and_pop_test()
+{
+ std::queue<int> a;
+ a.push(2);
+ a.push(4);
+ VERIFY( a.front() == 2 && a.back() == 4);
+ a.pop();
+ VERIFY( a.front() == 4 && a.back() == 4);
+ a.pop();
+ VERIFY( a.empty() );
+ return true;
+}
+static_assert( push_and_pop_test() );
+
+constexpr bool
+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 );
+ return true;
+}
+static_assert( swap_test() );
+
+constexpr bool
+emplace_test()
+{
+ struct S
+ {
+ int foo;
+ constexpr S(int i, int j) : foo{i + j} {}
+ };
+
+ std::queue<S> a;
+ const S& s = a.emplace(196883, 1);
+ VERIFY( a.size() == 1 );
+ VERIFY( a.front().foo == 196884 );
+ return true;
+}
+static_assert( emplace_test() );
+
+constexpr bool
+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 );
+ return true;
+}
+static_assert( operator_test() );
diff --git a/libstdc++-v3/testsuite/std/format/ranges/adaptors.cc b/libstdc++-v3/testsuite/std/format/ranges/adaptors.cc
index 649eea47f168..968ac00b63e1 100644
--- a/libstdc++-v3/testsuite/std/format/ranges/adaptors.cc
+++ b/libstdc++-v3/testsuite/std/format/ranges/adaptors.cc
@@ -6,8 +6,14 @@
#include <stack>
#include <testsuite_hooks.h>
+#ifdef __glibcxx_constexpr_format
+# define CONSTEXPR constexpr
+#else
+# define CONSTEXPR
+#endif
+
template<typename... Args>
-bool
+CONSTEXPR bool
is_format_string_for(const char* str, Args&&... args)
{
try {
@@ -22,7 +28,7 @@ is_format_string_for(const char* str, Args&&... args)
#define WIDEN(S) WIDEN_(CharT, S)
template<template<typename Tp> class Adaptor>
-void
+CONSTEXPR void
test_format_string()
{
Adaptor<int> q;
@@ -41,7 +47,7 @@ struct NoFormat
struct MutFormat
{
MutFormat() = default;
- MutFormat(int p) : x(p) {}
+ CONSTEXPR MutFormat(int p) : x(p) {}
int x;
friend auto operator<=>(MutFormat, MutFormat) = default;
@@ -52,7 +58,8 @@ struct std::formatter<MutFormat, CharT>
: std::formatter<int, CharT>
{
template<typename Out>
- Out format(MutFormat& mf, basic_format_context<Out, CharT>& ctx) const
+ CONSTEXPR Out
+ format(MutFormat& mf, basic_format_context<Out, CharT>& ctx) const
{ return std::formatter<int, CharT>::format(mf.x, ctx); }
};
@@ -68,7 +75,7 @@ constexpr auto std::format_kind<NotFormattableCont<T>>
template<typename CharT,
template<typename Tp, typename Cont = std::vector<Tp>> class Adaptor>
-void
+CONSTEXPR void
test_output()
{
const std::vector<int> v{3, 2, 1};
@@ -133,7 +140,7 @@ test_output()
}
template<template<typename Tp, typename Cont = std::vector<Tp>> class Adaptor>
-void
+CONSTEXPR void
test_adaptor()
{
test_format_string<Adaptor>();
@@ -145,7 +152,7 @@ test_adaptor()
}
template<typename CharT>
-void
+CONSTEXPR void
test_compare()
{
const std::vector<int> v{3, 2, 1};
@@ -157,9 +164,20 @@ test_compare()
VERIFY( res == WIDEN("[1, 2, 3]") );
}
-int main()
+CONSTEXPR bool
+test_all()
{
test_adaptor<std::queue>();
test_adaptor<std::priority_queue>();
test_compare<char>();
+ return true;
+}
+
+#ifdef __glibcxx_constexpr_format
+ static_assert(test_all());
+#endif
+
+int main()
+{
+ test_all();
}
More information about the Libstdc++-cvs
mailing list