Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion libcxx/docs/FeatureTestMacroTable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_algorithms`` ``201806L``
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_complex`` ``201711L``
``__cpp_lib_constexpr_deque`` ``202502L``
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_dynamic_alloc`` ``201907L``
---------------------------------------------------------- -----------------
Expand Down Expand Up @@ -416,6 +416,8 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_bitset`` ``202306L``
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_complex`` ``201711L``
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_new`` ``202406L``
---------------------------------------------------------- -----------------
``__cpp_lib_constrained_equality`` *unimplemented*
Expand Down
11 changes: 6 additions & 5 deletions libcxx/include/deque
Original file line number Diff line number Diff line change
Expand Up @@ -2543,7 +2543,8 @@ inline void deque<_Tp, _Allocator>::clear() _NOEXCEPT {
}

template <class _Tp, class _Allocator>
inline _LIBCPP_HIDE_FROM_ABI bool operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) {
inline _LIBCPP_CONSTEXPR_SINCE_CXX26 constexpr bool
operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) {
const typename deque<_Tp, _Allocator>::size_type __sz = __x.size();
return __sz == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
}
Expand Down Expand Up @@ -2578,30 +2579,30 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const deque<_Tp, _Allocator>& __x,
# else // _LIBCPP_STD_VER <= 17

template <class _Tp, class _Allocator>
_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
_LIBCPP_CONSTEXPR_SINCE_CXX26 __synth_three_way_result<_Tp> constexpr
operator<=>(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) {
return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
}

# endif // _LIBCPP_STD_VER <= 17

template <class _Tp, class _Allocator>
inline _LIBCPP_HIDE_FROM_ABI void swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y)
inline _LIBCPP_CONSTEXPR_SINCE_CXX26 constexpr void swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
__x.swap(__y);
}

# if _LIBCPP_STD_VER >= 20
template <class _Tp, class _Allocator, class _Up>
inline _LIBCPP_HIDE_FROM_ABI typename deque<_Tp, _Allocator>::size_type
inline _LIBCPP_CONSTEXPR_SINCE_CXX26 constexpr typename deque<_Tp, _Allocator>::size_type
erase(deque<_Tp, _Allocator>& __c, const _Up& __v) {
auto __old_size = __c.size();
__c.erase(std::remove(__c.begin(), __c.end(), __v), __c.end());
return __old_size - __c.size();
}

template <class _Tp, class _Allocator, class _Predicate>
inline _LIBCPP_HIDE_FROM_ABI typename deque<_Tp, _Allocator>::size_type
inline _LIBCPP_CONSTEXPR_SINCE_CXX26 constexpr typename deque<_Tp, _Allocator>::size_type
erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred) {
auto __old_size = __c.size();
__c.erase(std::remove_if(__c.begin(), __c.end(), __pred), __c.end());
Expand Down
6 changes: 4 additions & 2 deletions libcxx/include/version
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ __cpp_lib_constexpr_algorithms 201806L <algorithm> <uti
__cpp_lib_constexpr_bitset 202207L <bitset>
__cpp_lib_constexpr_charconv 202207L <charconv>
__cpp_lib_constexpr_cmath 202202L <cmath> <cstdlib>
__cpp_lib_constexpr_complex 201711L <complex>
__cpp_lib_constexpr_complex 201711L <deque>
__cpp_lib_constexpr_deque 202502L <complex>
__cpp_lib_constexpr_dynamic_alloc 201907L <memory>
__cpp_lib_constexpr_functional 201907L <functional>
__cpp_lib_constexpr_iterator 201811L <iterator>
Expand Down Expand Up @@ -398,7 +399,7 @@ __cpp_lib_void_t 201411L <type_traits>
# endif
# define __cpp_lib_concepts 202002L
# define __cpp_lib_constexpr_algorithms 201806L
# define __cpp_lib_constexpr_complex 201711L
# define __cpp_lib_constexpr_deque 202502L
# define __cpp_lib_constexpr_dynamic_alloc 201907L
# define __cpp_lib_constexpr_functional 201907L
# define __cpp_lib_constexpr_iterator 201811L
Expand Down Expand Up @@ -536,6 +537,7 @@ __cpp_lib_void_t 201411L <type_traits>
# undef __cpp_lib_bind_front
# define __cpp_lib_bind_front 202306L
# define __cpp_lib_bitset 202306L
# define __cpp_lib_constexpr_complex 201711L
# if !defined(_LIBCPP_ABI_VCRUNTIME)
# define __cpp_lib_constexpr_new 202406L
# endif
Expand Down
10 changes: 9 additions & 1 deletion libcxx/test/std/containers/sequences/deque/compare.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#include "test_comparisons.h"

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
const std::deque<int> d1, d2;
assert(testComparisons(d1, d2, true, false));
Expand Down Expand Up @@ -113,6 +113,14 @@ int main(int, char**) {
const std::deque<LessAndEqComp> d2(items2, items2 + 2);
assert(testComparisons(d1, d2, false, false));
}
return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@

#include "test_container_comparisons.h"

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
assert(test_sequence_container_spaceship<std::deque>());
// `std::deque` is not constexpr, so no `static_assert` test here.
return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ C make(int size, int start = 0) {
return c;
}

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::deque<int> C;
C c = make<std::deque<int> >(10);
Expand Down Expand Up @@ -118,6 +118,14 @@ int main(int, char**) {
LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
}
#endif
return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "test_macros.h"
#include "min_allocator.h"

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::deque<int> C;
C c;
Expand All @@ -46,6 +46,13 @@ int main(int, char**) {
LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
}
#endif
return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "test_allocator.h"
#include "test_macros.h"

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
typedef limited_allocator<int, 10> A;
typedef std::deque<int, A> C;
Expand All @@ -45,6 +45,14 @@ int main(int, char**) {
assert(c.max_size() <= alloc_max_size(c.get_allocator()));
LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
}
return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void testN(int start, int N, int M) {
test(c1, M);
}

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng) / sizeof(rng[0]);
Expand All @@ -90,6 +90,14 @@ int main(int, char**) {
testN<std::deque<int, safe_allocator<int>>>(rng[i], rng[j], rng[k]);
}
#endif
return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void testN(int start, int N, int M) {
test(c1, M, -10);
}

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng) / sizeof(rng[0]);
Expand Down Expand Up @@ -91,5 +91,13 @@ int main(int, char**) {
}
#endif

return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void testN(int start, int N) {
test(c1);
}

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng) / sizeof(rng[0]);
Expand All @@ -74,6 +74,14 @@ int main(int, char**) {
testN<std::deque<int, safe_allocator<int>> >(rng[i], rng[j]);
}
#endif
return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "test_macros.h"
#include "min_allocator.h"

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::deque<int> C;
C c;
Expand Down Expand Up @@ -72,6 +72,14 @@ int main(int, char**) {
LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(c));
}
#endif
return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,31 @@
#include "min_allocator.h"

template <class T, class Allocator>
void test(const Allocator& a) {
void test_util(const Allocator& a) {
std::deque<T, Allocator> d(a);
assert(d.size() == 0);
assert(d.get_allocator() == a);
LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(d));
}

int main(int, char**) {
test<int>(std::allocator<int>());
test<NotConstructible>(test_allocator<NotConstructible>(3));
TEST_CONSTEXPR_CXX26 bool test() {
test_util<int>(std::allocator<int>());
test_util<NotConstructible>(test_allocator<NotConstructible>(3));
#if TEST_STD_VER >= 11
test<int>(min_allocator<int>());
test<int>(safe_allocator<int>());
test<NotConstructible>(min_allocator<NotConstructible>{});
test<NotConstructible>(safe_allocator<NotConstructible>{});
test<int>(explicit_allocator<int>());
test<NotConstructible>(explicit_allocator<NotConstructible>{});
test_util<int>(min_allocator<int>());
test_util<int>(safe_allocator<int>());
test_util<NotConstructible>(min_allocator<NotConstructible>{});
test_util<NotConstructible>(safe_allocator<NotConstructible>{});
test_util<int>(explicit_allocator<int>());
test_util<NotConstructible>(explicit_allocator<NotConstructible>{});
#endif
return false;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "test_macros.h"
#include "min_allocator.h"

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
std::deque<int> d;
d.assign({3, 4, 5, 6});
Expand All @@ -40,6 +40,13 @@ int main(int, char**) {
assert(d[3] == 6);
LIBCPP_ASSERT(is_double_ended_contiguous_container_asan_correct(d));
}
return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ void test_iterators() {

int main(int, char**) {
basic_test();

#if TEST_STD_VER >= 26
static_assert(basic_test());
#endif
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void testN(int start, int N, int M) {
test(c1, M, -10);
}

int main(int, char**) {
TEST_CONSTEXPR_CXX26 bool test() {
{
int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
const int N = sizeof(rng) / sizeof(rng[0]);
Expand All @@ -74,6 +74,14 @@ int main(int, char**) {
testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
}
#endif
return true;
}

int main(int, char**) {
test();
#if TEST_STD_VER >= 26
static_assert(test());
#endif

return 0;
}
Loading
Loading