[libcxx-commits] [libcxx] [libc++] constexpr `flat_set` (PR #140360)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun May 18 05:58:41 PDT 2025
https://github.com/huixie90 updated https://github.com/llvm/llvm-project/pull/140360
>From 69e095de29211b243a7d9ba066498a7db5d79275 Mon Sep 17 00:00:00 2001
From: Hui Xie <hui.xie1990 at gmail.com>
Date: Sun, 4 May 2025 13:33:59 +0100
Subject: [PATCH 1/3] constexpr flat_set
---
libcxx/include/__flat_set/flat_set.h | 278 +++++++++++-------
libcxx/include/__flat_set/utils.h | 8 +-
libcxx/include/module.modulemap.in | 3 +
libcxx/test/std/containers/Emplaceable.h | 16 +-
.../flat.set/flat.set.capacity/empty.pass.cpp | 14 +-
.../flat.set.capacity/max_size.pass.cpp | 7 +-
.../flat.set/flat.set.capacity/size.pass.cpp | 17 +-
.../flat.set/flat.set.cons/alloc.pass.cpp | 26 +-
.../assign_initializer_list.pass.cpp | 14 +-
.../flat.set/flat.set.cons/compare.pass.cpp | 80 +++--
.../flat.set.cons/containers.pass.cpp | 106 ++++---
.../flat.set/flat.set.cons/copy.pass.cpp | 21 +-
.../flat.set.cons/copy_alloc.pass.cpp | 47 +--
.../flat.set.cons/copy_assign.pass.cpp | 27 +-
.../flat.set/flat.set.cons/default.pass.cpp | 42 ++-
.../flat.set.cons/dtor_noexcept.pass.cpp | 28 +-
.../flat.set.cons/initializer_list.pass.cpp | 121 ++++----
.../flat.set/flat.set.cons/iter_iter.pass.cpp | 98 +++---
.../flat.set/flat.set.cons/move.pass.cpp | 64 ++--
.../flat.set.cons/move_alloc.pass.cpp | 51 ++--
.../flat.set.cons/move_assign.pass.cpp | 51 +++-
.../flat.set/flat.set.cons/range.pass.cpp | 93 ++++--
.../flat.set.cons/sorted_container.pass.cpp | 91 +++---
.../sorted_initializer_list.pass.cpp | 122 ++++----
.../flat.set.cons/sorted_iter_iter.pass.cpp | 93 +++---
.../flat.set.erasure/erase_if.pass.cpp | 26 +-
.../flat.set.iterators/iterator.pass.cpp | 14 +-
.../iterator_comparison.pass.cpp | 14 +-
.../reverse_iterator.pass.cpp | 52 ++--
.../flat.set.modifiers/clear.pass.cpp | 15 +-
.../flat.set.modifiers/emplace.pass.cpp | 21 +-
.../flat.set.modifiers/emplace_hint.pass.cpp | 21 +-
.../flat.set.modifiers/erase_iter.pass.cpp | 14 +-
.../erase_iter_iter.pass.cpp | 14 +-
.../flat.set.modifiers/erase_key.pass.cpp | 14 +-
.../erase_key_transparent.pass.cpp | 29 +-
.../flat.set.modifiers/extract.pass.cpp | 14 +-
.../flat.set.modifiers/insert_cv.pass.cpp | 14 +-
.../insert_initializer_list.pass.cpp | 14 +-
.../insert_iter_cv.pass.cpp | 14 +-
.../insert_iter_iter.pass.cpp | 14 +-
.../insert_iter_rv.pass.cpp | 18 +-
.../flat.set.modifiers/insert_range.pass.cpp | 16 +-
.../flat.set.modifiers/insert_rv.pass.cpp | 18 +-
.../insert_sorted_initializer_list.pass.cpp | 14 +-
.../insert_sorted_iter_iter.pass.cpp | 14 +-
.../insert_transparent.pass.cpp | 14 +-
.../flat.set.modifiers/replace.pass.cpp | 14 +-
.../flat.set.modifiers/swap_free.pass.cpp | 15 +-
.../flat.set.modifiers/swap_member.pass.cpp | 14 +-
.../flat.set/flat.set.observers/comp.pass.cpp | 9 +-
.../flat.set.operations/contains.pass.cpp | 14 +-
.../contains_transparent.pass.cpp | 14 +-
.../flat.set.operations/count.pass.cpp | 14 +-
.../count_transparent.pass.cpp | 14 +-
.../flat.set.operations/equal_range.pass.cpp | 14 +-
.../equal_range_transparent.pass.cpp | 14 +-
.../flat.set.operations/find.pass.cpp | 14 +-
.../find_transparent.pass.cpp | 12 +-
.../flat.set.operations/lower_bound.pass.cpp | 14 +-
.../lower_bound_transparent.pass.cpp | 14 +-
.../flat.set.operations/upper_bound.pass.cpp | 14 +-
.../upper_bound_transparent.pass.cpp | 14 +-
.../container.adaptors/flat.set/helpers.h | 2 +-
.../flat.set/incomplete_type.pass.cpp | 11 +-
.../flat.set/op_compare.pass.cpp | 16 +-
.../container.adaptors/flat_helpers.h | 22 +-
libcxx/test/std/containers/test_compare.h | 9 +-
libcxx/test/support/MinSequenceContainer.h | 43 +--
69 files changed, 1487 insertions(+), 750 deletions(-)
diff --git a/libcxx/include/__flat_set/flat_set.h b/libcxx/include/__flat_set/flat_set.h
index a87496bb9916e..3c44c796a3c59 100644
--- a/libcxx/include/__flat_set/flat_set.h
+++ b/libcxx/include/__flat_set/flat_set.h
@@ -108,13 +108,13 @@ class flat_set {
public:
// [flat.set.cons], construct/copy/destroy
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
flat_set() noexcept(is_nothrow_default_constructible_v<_KeyContainer> && is_nothrow_default_constructible_v<_Compare>)
: __keys_(), __compare_() {}
- _LIBCPP_HIDE_FROM_ABI flat_set(const flat_set&) = default;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(const flat_set&) = default;
- _LIBCPP_HIDE_FROM_ABI flat_set(flat_set&& __other) noexcept(
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(flat_set&& __other) noexcept(
is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_Compare>)
# if _LIBCPP_HAS_EXCEPTIONS
try
@@ -131,14 +131,17 @@ class flat_set {
# endif // _LIBCPP_HAS_EXCEPTIONS
}
- _LIBCPP_HIDE_FROM_ABI explicit flat_set(const key_compare& __comp) : __keys_(), __compare_(__comp) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_set(const key_compare& __comp)
+ : __keys_(), __compare_(__comp) {}
- _LIBCPP_HIDE_FROM_ABI explicit flat_set(container_type __keys, const key_compare& __comp = key_compare())
+ _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_set(container_type __keys, const key_compare& __comp = key_compare())
: __keys_(std::move(__keys)), __compare_(__comp) {
__sort_and_unique();
}
- _LIBCPP_HIDE_FROM_ABI flat_set(sorted_unique_t, container_type __keys, const key_compare& __comp = key_compare())
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
+ flat_set(sorted_unique_t, container_type __keys, const key_compare& __comp = key_compare())
: __keys_(std::move(__keys)), __compare_(__comp) {
_LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
__is_sorted_and_unique(__keys_), "Either the key container is not sorted or it contains duplicates");
@@ -146,7 +149,7 @@ class flat_set {
template <class _InputIterator>
requires __has_input_iterator_category<_InputIterator>::value
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
flat_set(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare())
: __keys_(), __compare_(__comp) {
insert(__first, __last);
@@ -154,7 +157,7 @@ class flat_set {
template <class _InputIterator>
requires __has_input_iterator_category<_InputIterator>::value
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
flat_set(sorted_unique_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare())
: __keys_(__first, __last), __compare_(__comp) {
_LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
@@ -162,48 +165,52 @@ class flat_set {
}
template <_ContainerCompatibleRange<value_type> _Range>
- _LIBCPP_HIDE_FROM_ABI flat_set(from_range_t, _Range&& __rg)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(from_range_t, _Range&& __rg)
: flat_set(from_range, std::forward<_Range>(__rg), key_compare()) {}
template <_ContainerCompatibleRange<value_type> _Range>
- _LIBCPP_HIDE_FROM_ABI flat_set(from_range_t, _Range&& __rg, const key_compare& __comp) : flat_set(__comp) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(from_range_t, _Range&& __rg, const key_compare& __comp)
+ : flat_set(__comp) {
insert_range(std::forward<_Range>(__rg));
}
- _LIBCPP_HIDE_FROM_ABI flat_set(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
+ flat_set(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
: flat_set(__il.begin(), __il.end(), __comp) {}
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
flat_set(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare())
: flat_set(sorted_unique, __il.begin(), __il.end(), __comp) {}
template <class _Allocator>
requires uses_allocator<container_type, _Allocator>::value
- _LIBCPP_HIDE_FROM_ABI explicit flat_set(const _Allocator& __alloc)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_set(const _Allocator& __alloc)
: __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() {}
template <class _Allocator>
requires uses_allocator<container_type, _Allocator>::value
- _LIBCPP_HIDE_FROM_ABI flat_set(const key_compare& __comp, const _Allocator& __alloc)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(const key_compare& __comp, const _Allocator& __alloc)
: __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) {}
template <class _Allocator>
requires uses_allocator<container_type, _Allocator>::value
- _LIBCPP_HIDE_FROM_ABI flat_set(const container_type& __keys, const _Allocator& __alloc)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(const container_type& __keys, const _Allocator& __alloc)
: __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_() {
__sort_and_unique();
}
template <class _Allocator>
requires uses_allocator<container_type, _Allocator>::value
- _LIBCPP_HIDE_FROM_ABI flat_set(const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
+ flat_set(const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc)
: __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_(__comp) {
__sort_and_unique();
}
template <class _Allocator>
requires uses_allocator<container_type, _Allocator>::value
- _LIBCPP_HIDE_FROM_ABI flat_set(sorted_unique_t, const container_type& __keys, const _Allocator& __alloc)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
+ flat_set(sorted_unique_t, const container_type& __keys, const _Allocator& __alloc)
: __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_() {
_LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
__is_sorted_and_unique(__keys_), "Either the key container is not sorted or it contains duplicates");
@@ -211,7 +218,7 @@ class flat_set {
template <class _Allocator>
requires uses_allocator<container_type, _Allocator>::value
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
flat_set(sorted_unique_t, const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc)
: __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_(__comp) {
_LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
@@ -220,13 +227,13 @@ class flat_set {
template <class _Allocator>
requires uses_allocator<container_type, _Allocator>::value
- _LIBCPP_HIDE_FROM_ABI flat_set(const flat_set& __other, const _Allocator& __alloc)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(const flat_set& __other, const _Allocator& __alloc)
: __keys_(std::make_obj_using_allocator<container_type>(__alloc, __other.__keys_)),
__compare_(__other.__compare_) {}
template <class _Allocator>
requires uses_allocator<container_type, _Allocator>::value
- _LIBCPP_HIDE_FROM_ABI flat_set(flat_set&& __other, const _Allocator& __alloc)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(flat_set&& __other, const _Allocator& __alloc)
# if _LIBCPP_HAS_EXCEPTIONS
try
# endif // _LIBCPP_HAS_EXCEPTIONS
@@ -242,14 +249,15 @@ class flat_set {
template <class _InputIterator, class _Allocator>
requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value)
- _LIBCPP_HIDE_FROM_ABI flat_set(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
+ flat_set(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc)
: __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() {
insert(__first, __last);
}
template <class _InputIterator, class _Allocator>
requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value)
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
flat_set(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc)
: __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) {
insert(__first, __last);
@@ -257,7 +265,7 @@ class flat_set {
template <class _InputIterator, class _Allocator>
requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value)
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
flat_set(sorted_unique_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc)
: __keys_(std::make_obj_using_allocator<container_type>(__alloc, __first, __last)), __compare_() {
_LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
@@ -266,12 +274,12 @@ class flat_set {
template <class _InputIterator, class _Allocator>
requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value)
- _LIBCPP_HIDE_FROM_ABI
- flat_set(sorted_unique_t,
- _InputIterator __first,
- _InputIterator __last,
- const key_compare& __comp,
- const _Allocator& __alloc)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(
+ sorted_unique_t,
+ _InputIterator __first,
+ _InputIterator __last,
+ const key_compare& __comp,
+ const _Allocator& __alloc)
: __keys_(std::make_obj_using_allocator<container_type>(__alloc, __first, __last)), __compare_(__comp) {
_LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
__is_sorted_and_unique(__keys_), "Either the key container is not sorted or it contains duplicates");
@@ -279,49 +287,52 @@ class flat_set {
template <_ContainerCompatibleRange<value_type> _Range, class _Allocator>
requires uses_allocator<container_type, _Allocator>::value
- _LIBCPP_HIDE_FROM_ABI flat_set(from_range_t, _Range&& __rg, const _Allocator& __alloc)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(from_range_t, _Range&& __rg, const _Allocator& __alloc)
: __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() {
insert_range(std::forward<_Range>(__rg));
}
template <_ContainerCompatibleRange<value_type> _Range, class _Allocator>
requires uses_allocator<container_type, _Allocator>::value
- _LIBCPP_HIDE_FROM_ABI flat_set(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
+ flat_set(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc)
: __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) {
insert_range(std::forward<_Range>(__rg));
}
template <class _Allocator>
requires uses_allocator<container_type, _Allocator>::value
- _LIBCPP_HIDE_FROM_ABI flat_set(initializer_list<value_type> __il, const _Allocator& __alloc)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
+ flat_set(initializer_list<value_type> __il, const _Allocator& __alloc)
: flat_set(__il.begin(), __il.end(), __alloc) {}
template <class _Allocator>
requires uses_allocator<container_type, _Allocator>::value
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
flat_set(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc)
: flat_set(__il.begin(), __il.end(), __comp, __alloc) {}
template <class _Allocator>
requires uses_allocator<container_type, _Allocator>::value
- _LIBCPP_HIDE_FROM_ABI flat_set(sorted_unique_t, initializer_list<value_type> __il, const _Allocator& __alloc)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
+ flat_set(sorted_unique_t, initializer_list<value_type> __il, const _Allocator& __alloc)
: flat_set(sorted_unique, __il.begin(), __il.end(), __alloc) {}
template <class _Allocator>
requires uses_allocator<container_type, _Allocator>::value
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
flat_set(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc)
: flat_set(sorted_unique, __il.begin(), __il.end(), __comp, __alloc) {}
- _LIBCPP_HIDE_FROM_ABI flat_set& operator=(initializer_list<value_type> __il) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set& operator=(initializer_list<value_type> __il) {
clear();
insert(__il);
return *this;
}
- _LIBCPP_HIDE_FROM_ABI flat_set& operator=(const flat_set&) = default;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set& operator=(const flat_set&) = default;
- _LIBCPP_HIDE_FROM_ABI flat_set& operator=(flat_set&& __other) noexcept(
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set& operator=(flat_set&& __other) noexcept(
is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_Compare>) {
// No matter what happens, we always want to clear the other container before returning
// since we moved from it
@@ -337,31 +348,53 @@ class flat_set {
}
// iterators
- _LIBCPP_HIDE_FROM_ABI iterator begin() noexcept { return iterator(std::as_const(__keys_).begin()); }
- _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept { return const_iterator(__keys_.begin()); }
- _LIBCPP_HIDE_FROM_ABI iterator end() noexcept { return iterator(std::as_const(__keys_).end()); }
- _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept { return const_iterator(__keys_.end()); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() noexcept {
+ return iterator(std::as_const(__keys_).begin());
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const noexcept {
+ return const_iterator(__keys_.begin());
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() noexcept {
+ return iterator(std::as_const(__keys_).end());
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const noexcept {
+ return const_iterator(__keys_.end());
+ }
- _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() noexcept { return reverse_iterator(end()); }
- _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); }
- _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() noexcept { return reverse_iterator(begin()); }
- _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rbegin() noexcept {
+ return reverse_iterator(end());
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rbegin() const noexcept {
+ return const_reverse_iterator(end());
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rend() noexcept {
+ return reverse_iterator(begin());
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rend() const noexcept {
+ return const_reverse_iterator(begin());
+ }
- _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept { return begin(); }
- _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept { return end(); }
- _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); }
- _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cbegin() const noexcept { return begin(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cend() const noexcept { return end(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crbegin() const noexcept {
+ return const_reverse_iterator(end());
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crend() const noexcept {
+ return const_reverse_iterator(begin());
+ }
// [flat.set.capacity], capacity
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __keys_.empty(); }
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool empty() const noexcept {
+ return __keys_.empty();
+ }
- _LIBCPP_HIDE_FROM_ABI size_type size() const noexcept { return __keys_.size(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const noexcept { return __keys_.size(); }
- _LIBCPP_HIDE_FROM_ABI size_type max_size() const noexcept { return __keys_.max_size(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const noexcept { return __keys_.max_size(); }
// [flat.set.modifiers], modifiers
template <class... _Args>
- _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> emplace(_Args&&... __args) {
if constexpr (sizeof...(__args) == 1 && (is_same_v<remove_cvref_t<_Args>, _Key> && ...)) {
return __emplace(std::forward<_Args>(__args)...);
} else {
@@ -370,7 +403,7 @@ class flat_set {
}
template <class... _Args>
- _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __hint, _Args&&... __args) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace_hint(const_iterator __hint, _Args&&... __args) {
if constexpr (sizeof...(__args) == 1 && (is_same_v<remove_cvref_t<_Args>, _Key> && ...)) {
return __emplace_hint(std::move(__hint), std::forward<_Args>(__args)...);
} else {
@@ -378,32 +411,36 @@ class flat_set {
}
}
- _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return emplace(__x); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(const value_type& __x) {
+ return emplace(__x);
+ }
- _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) { return emplace(std::move(__x)); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(value_type&& __x) {
+ return emplace(std::move(__x));
+ }
template <class _Kp>
requires(__is_transparent_v<_Compare> && is_constructible_v<value_type, _Kp>)
- _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Kp&& __x) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(_Kp&& __x) {
return __emplace(std::forward<_Kp>(__x));
}
- _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, const value_type& __x) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, const value_type& __x) {
return emplace_hint(__hint, __x);
}
- _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, value_type&& __x) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, value_type&& __x) {
return emplace_hint(__hint, std::move(__x));
}
template <class _Kp>
requires(__is_transparent_v<_Compare> && is_constructible_v<value_type, _Kp>)
- _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, _Kp&& __x) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, _Kp&& __x) {
return __emplace_hint(__hint, std::forward<_Kp>(__x));
}
template <class _InputIterator>
requires __has_input_iterator_category<_InputIterator>::value
- _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(_InputIterator __first, _InputIterator __last) {
if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {
__reserve(__last - __first);
}
@@ -412,7 +449,8 @@ class flat_set {
template <class _InputIterator>
requires __has_input_iterator_category<_InputIterator>::value
- _LIBCPP_HIDE_FROM_ABI void insert(sorted_unique_t, _InputIterator __first, _InputIterator __last) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
+ insert(sorted_unique_t, _InputIterator __first, _InputIterator __last) {
if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {
__reserve(__last - __first);
}
@@ -421,7 +459,7 @@ class flat_set {
}
template <_ContainerCompatibleRange<value_type> _Range>
- _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(_Range&& __range) {
if constexpr (ranges::sized_range<_Range>) {
__reserve(ranges::size(__range));
}
@@ -429,19 +467,21 @@ class flat_set {
__append_sort_merge_unique</*WasSorted = */ false>(std::forward<_Range>(__range));
}
- _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list<value_type> __il) {
+ insert(__il.begin(), __il.end());
+ }
- _LIBCPP_HIDE_FROM_ABI void insert(sorted_unique_t, initializer_list<value_type> __il) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(sorted_unique_t, initializer_list<value_type> __il) {
insert(sorted_unique, __il.begin(), __il.end());
}
- _LIBCPP_HIDE_FROM_ABI container_type extract() && {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 container_type extract() && {
auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; });
auto __ret = std::move(__keys_);
return __ret;
}
- _LIBCPP_HIDE_FROM_ABI void replace(container_type&& __keys) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void replace(container_type&& __keys) {
_LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
__is_sorted_and_unique(__keys), "Either the key container is not sorted or it contains duplicates");
auto __guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
@@ -449,7 +489,7 @@ class flat_set {
__guard.__complete();
}
- _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __position) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(iterator __position) {
auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
auto __key_iter = __keys_.erase(__position.__base());
__on_failure.__complete();
@@ -459,7 +499,7 @@ class flat_set {
// The following overload is the same as the iterator overload
// iterator erase(const_iterator __position);
- _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __x) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(const key_type& __x) {
auto __iter = find(__x);
if (__iter != end()) {
erase(__iter);
@@ -471,21 +511,21 @@ class flat_set {
template <class _Kp>
requires(__is_transparent_v<_Compare> && !is_convertible_v<_Kp &&, iterator> &&
!is_convertible_v<_Kp &&, const_iterator>)
- _LIBCPP_HIDE_FROM_ABI size_type erase(_Kp&& __x) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(_Kp&& __x) {
auto [__first, __last] = equal_range(__x);
auto __res = __last - __first;
erase(__first, __last);
return __res;
}
- _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __first, const_iterator __last) {
auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
auto __key_it = __keys_.erase(__first.__base(), __last.__base());
__on_failure.__complete();
return iterator(std::move(__key_it));
}
- _LIBCPP_HIDE_FROM_ABI void swap(flat_set& __y) noexcept {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(flat_set& __y) noexcept {
// warning: The spec has unconditional noexcept, which means that
// if any of the following functions throw an exception,
// std::terminate will be called.
@@ -494,121 +534,134 @@ class flat_set {
ranges::swap(__keys_, __y.__keys_);
}
- _LIBCPP_HIDE_FROM_ABI void clear() noexcept { __keys_.clear(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() noexcept { __keys_.clear(); }
// observers
- _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __compare_; }
- _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return __compare_; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const { return __compare_; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const { return __compare_; }
// set operations
- _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __x) { return __find_impl(*this, __x); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const key_type& __x) {
+ return __find_impl(*this, __x);
+ }
- _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __x) const { return __find_impl(*this, __x); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const key_type& __x) const {
+ return __find_impl(*this, __x);
+ }
template <class _Kp>
requires __is_transparent_v<_Compare>
- _LIBCPP_HIDE_FROM_ABI iterator find(const _Kp& __x) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _Kp& __x) {
return __find_impl(*this, __x);
}
template <class _Kp>
requires __is_transparent_v<_Compare>
- _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Kp& __x) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _Kp& __x) const {
return __find_impl(*this, __x);
}
- _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __x) const { return contains(__x) ? 1 : 0; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __x) const {
+ return contains(__x) ? 1 : 0;
+ }
template <class _Kp>
requires __is_transparent_v<_Compare>
- _LIBCPP_HIDE_FROM_ABI size_type count(const _Kp& __x) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const _Kp& __x) const {
return contains(__x) ? 1 : 0;
}
- _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __x) const { return find(__x) != end(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const key_type& __x) const {
+ return find(__x) != end();
+ }
template <class _Kp>
requires __is_transparent_v<_Compare>
- _LIBCPP_HIDE_FROM_ABI bool contains(const _Kp& __x) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const _Kp& __x) const {
return find(__x) != end();
}
- _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __x) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __x) {
const auto& __keys = __keys_;
return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_));
}
- _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __x) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const key_type& __x) const {
return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_));
}
template <class _Kp>
requires __is_transparent_v<_Compare>
- _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _Kp& __x) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const _Kp& __x) {
const auto& __keys = __keys_;
return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_));
}
template <class _Kp>
requires __is_transparent_v<_Compare>
- _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Kp& __x) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const _Kp& __x) const {
return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_));
}
- _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __x) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __x) {
const auto& __keys = __keys_;
return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_));
}
- _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __x) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const key_type& __x) const {
return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_));
}
template <class _Kp>
requires __is_transparent_v<_Compare>
- _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Kp& __x) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const _Kp& __x) {
const auto& __keys = __keys_;
return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_));
}
template <class _Kp>
requires __is_transparent_v<_Compare>
- _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Kp& __x) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const _Kp& __x) const {
return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_));
}
- _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __x) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const key_type& __x) {
return __equal_range_impl(*this, __x);
}
- _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __x) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
+ equal_range(const key_type& __x) const {
return __equal_range_impl(*this, __x);
}
template <class _Kp>
requires __is_transparent_v<_Compare>
- _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _Kp& __x) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const _Kp& __x) {
return __equal_range_impl(*this, __x);
}
template <class _Kp>
requires __is_transparent_v<_Compare>
- _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _Kp& __x) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
+ equal_range(const _Kp& __x) const {
return __equal_range_impl(*this, __x);
}
- friend _LIBCPP_HIDE_FROM_ABI bool operator==(const flat_set& __x, const flat_set& __y) {
+ friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator==(const flat_set& __x, const flat_set& __y) {
return ranges::equal(__x, __y);
}
- friend _LIBCPP_HIDE_FROM_ABI auto operator<=>(const flat_set& __x, const flat_set& __y) {
+ friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 auto
+ operator<=>(const flat_set& __x, const flat_set& __y) {
return std::lexicographical_compare_three_way(
__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
}
- friend _LIBCPP_HIDE_FROM_ABI void swap(flat_set& __x, flat_set& __y) noexcept { __x.swap(__y); }
+ friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(flat_set& __x, flat_set& __y) noexcept {
+ __x.swap(__y);
+ }
private:
- _LIBCPP_HIDE_FROM_ABI bool __is_sorted_and_unique(auto&& __key_container) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __is_sorted_and_unique(auto&& __key_container) const {
auto __greater_or_equal_to = [this](const auto& __x, const auto& __y) { return !__compare_(__x, __y); };
return ranges::adjacent_find(__key_container, __greater_or_equal_to) == ranges::end(__key_container);
}
@@ -616,14 +669,14 @@ class flat_set {
// This function is only used in constructors. So there is not exception handling in this function.
// If the function exits via an exception, there will be no flat_set object constructed, thus, there
// is no invariant state to preserve
- _LIBCPP_HIDE_FROM_ABI void __sort_and_unique() {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __sort_and_unique() {
ranges::sort(__keys_, __compare_);
auto __dup_start = ranges::unique(__keys_, __key_equiv(__compare_)).begin();
__keys_.erase(__dup_start, __keys_.end());
}
template <bool _WasSorted, class... _Args>
- _LIBCPP_HIDE_FROM_ABI void __append_sort_merge_unique(_Args&&... __args) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __append_sort_merge_unique(_Args&&... __args) {
auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
size_type __old_size = size();
__flat_set_utils::__append(*this, std::forward<_Args>(__args)...);
@@ -643,7 +696,7 @@ class flat_set {
}
template <class _Self, class _Kp>
- _LIBCPP_HIDE_FROM_ABI static auto __find_impl(_Self&& __self, const _Kp& __key) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto __find_impl(_Self&& __self, const _Kp& __key) {
auto __it = __self.lower_bound(__key);
auto __last = __self.end();
if (__it == __last || __self.__compare_(__key, *__it)) {
@@ -653,7 +706,7 @@ class flat_set {
}
template <class _Self, class _Kp>
- _LIBCPP_HIDE_FROM_ABI static auto __equal_range_impl(_Self&& __self, const _Kp& __key) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto __equal_range_impl(_Self&& __self, const _Kp& __key) {
using __iter = _If<is_const_v<__libcpp_remove_reference_t<_Self>>, const_iterator, iterator>;
auto __it = std::lower_bound(__self.__keys_.begin(), __self.__keys_.end(), __key, __self.__compare_);
auto __last = __self.__keys_.end();
@@ -664,7 +717,7 @@ class flat_set {
}
template <class _Kp>
- _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace(_Kp&& __key) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> __emplace(_Kp&& __key) {
auto __it = lower_bound(__key);
if (__it == end() || __compare_(__key, *__it)) {
return pair<iterator, bool>(__flat_set_utils::__emplace_exact_pos(*this, __it, std::forward<_Kp>(__key)), true);
@@ -674,7 +727,7 @@ class flat_set {
}
template <class _Kp>
- _LIBCPP_HIDE_FROM_ABI bool __is_hint_correct(const_iterator __hint, _Kp&& __key) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __is_hint_correct(const_iterator __hint, _Kp&& __key) {
if (__hint != cbegin() && !__compare_(*std::prev(__hint), __key)) {
return false;
}
@@ -685,7 +738,7 @@ class flat_set {
}
template <class _Kp>
- _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint(const_iterator __hint, _Kp&& __key) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __emplace_hint(const_iterator __hint, _Kp&& __key) {
if (__is_hint_correct(__hint, __key)) {
if (__hint == cend() || __compare_(__key, *__hint)) {
return __flat_set_utils::__emplace_exact_pos(*this, __hint, std::forward<_Kp>(__key));
@@ -698,7 +751,7 @@ class flat_set {
}
}
- _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __size) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __reserve(size_t __size) {
if constexpr (requires { __keys_.reserve(__size); }) {
__keys_.reserve(__size);
}
@@ -706,14 +759,15 @@ class flat_set {
template <class _Key2, class _Compare2, class _KeyContainer2, class _Predicate>
friend typename flat_set<_Key2, _Compare2, _KeyContainer2>::size_type
- erase_if(flat_set<_Key2, _Compare2, _KeyContainer2>&, _Predicate);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 erase_if(flat_set<_Key2, _Compare2, _KeyContainer2>&, _Predicate);
_KeyContainer __keys_;
_LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_;
struct __key_equiv {
- _LIBCPP_HIDE_FROM_ABI __key_equiv(key_compare __c) : __comp_(__c) {}
- _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_equiv(key_compare __c) : __comp_(__c) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
+ operator()(const_reference __x, const_reference __y) const {
return !__comp_(__x, __y) && !__comp_(__y, __x);
}
key_compare __comp_;
@@ -800,7 +854,7 @@ struct uses_allocator<flat_set<_Key, _Compare, _KeyContainer>, _Allocator>
: bool_constant<uses_allocator_v<_KeyContainer, _Allocator>> {};
template <class _Key, class _Compare, class _KeyContainer, class _Predicate>
-_LIBCPP_HIDE_FROM_ABI typename flat_set<_Key, _Compare, _KeyContainer>::size_type
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename flat_set<_Key, _Compare, _KeyContainer>::size_type
erase_if(flat_set<_Key, _Compare, _KeyContainer>& __flat_set, _Predicate __pred) {
auto __guard = std::__make_exception_guard([&] { __flat_set.clear(); });
auto __it = std::remove_if(__flat_set.__keys_.begin(), __flat_set.__keys_.end(), [&](const auto& __e) -> bool {
diff --git a/libcxx/include/__flat_set/utils.h b/libcxx/include/__flat_set/utils.h
index ed3b4c48580fb..3d28d51256c52 100644
--- a/libcxx/include/__flat_set/utils.h
+++ b/libcxx/include/__flat_set/utils.h
@@ -37,7 +37,8 @@ struct __flat_set_utils {
// When an exception is thrown during the emplacement, the function will clear the set if the container does not
// have strong exception safety guarantee on emplacement.
template <class _Set, class _Iter, class _KeyArg>
- _LIBCPP_HIDE_FROM_ABI static auto __emplace_exact_pos(_Set& __set, _Iter&& __iter, _KeyArg&& __key) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto
+ __emplace_exact_pos(_Set& __set, _Iter&& __iter, _KeyArg&& __key) {
using _KeyContainer = typename decay_t<_Set>::container_type;
auto __on_failure = std::__make_exception_guard([&]() noexcept {
if constexpr (!__container_traits<_KeyContainer>::__emplacement_has_strong_exception_safety_guarantee) {
@@ -50,12 +51,13 @@ struct __flat_set_utils {
}
template <class _Set, class _InputIterator>
- _LIBCPP_HIDE_FROM_ABI static void __append(_Set& __set, _InputIterator __first, _InputIterator __last) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static void
+ __append(_Set& __set, _InputIterator __first, _InputIterator __last) {
__set.__keys_.insert(__set.__keys_.end(), std::move(__first), std::move(__last));
}
template <class _Set, class _Range>
- _LIBCPP_HIDE_FROM_ABI static void __append(_Set& __set, _Range&& __rng) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static void __append(_Set& __set, _Range&& __rng) {
if constexpr (requires { __set.__keys_.insert_range(__set.__keys_.end(), std::forward<_Range>(__rng)); }) {
// C++23 Sequence Container should have insert_range member function
// Note that not all Sequence Containers provide append_range.
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 7260c3a5d51f3..dd4064bcdd78b 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -1316,6 +1316,9 @@ module std [system] {
export std.flat_map.sorted_unique
export std.flat_map.sorted_equivalent
export *
+ export std.algorithm.ranges_sort
+ export std.ranges.zip_view
+ export std.tuple
}
module format {
diff --git a/libcxx/test/std/containers/Emplaceable.h b/libcxx/test/std/containers/Emplaceable.h
index afc4e2e38b0eb..48d8eab0a9a09 100644
--- a/libcxx/test/std/containers/Emplaceable.h
+++ b/libcxx/test/std/containers/Emplaceable.h
@@ -22,13 +22,13 @@ class Emplaceable {
double double_;
public:
- Emplaceable() : int_(0), double_(0) {}
- Emplaceable(int i, double d) : int_(i), double_(d) {}
- Emplaceable(Emplaceable&& x) : int_(x.int_), double_(x.double_) {
+ TEST_CONSTEXPR Emplaceable() : int_(0), double_(0) {}
+ TEST_CONSTEXPR Emplaceable(int i, double d) : int_(i), double_(d) {}
+ TEST_CONSTEXPR Emplaceable(Emplaceable&& x) : int_(x.int_), double_(x.double_) {
x.int_ = 0;
x.double_ = 0;
}
- Emplaceable& operator=(Emplaceable&& x) {
+ TEST_CONSTEXPR Emplaceable& operator=(Emplaceable&& x) {
int_ = x.int_;
x.int_ = 0;
double_ = x.double_;
@@ -36,10 +36,12 @@ class Emplaceable {
return *this;
}
- bool operator==(const Emplaceable& x) const { return int_ == x.int_ && double_ == x.double_; }
- bool operator<(const Emplaceable& x) const { return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_); }
+ TEST_CONSTEXPR bool operator==(const Emplaceable& x) const { return int_ == x.int_ && double_ == x.double_; }
+ TEST_CONSTEXPR bool operator<(const Emplaceable& x) const {
+ return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);
+ }
- int get() const { return int_; }
+ TEST_CONSTEXPR int get() const { return int_; }
};
template <>
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.capacity/empty.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.capacity/empty.pass.cpp
index 223b92fc3e8e8..076102c616d44 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.capacity/empty.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.capacity/empty.pass.cpp
@@ -24,7 +24,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<int>, KeyContainer>;
M m;
@@ -38,15 +38,23 @@ void test_one() {
assert(m.empty());
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.capacity/max_size.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.capacity/max_size.pass.cpp
index dde1f7092e5b1..e2f52ab458c4c 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.capacity/max_size.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.capacity/max_size.pass.cpp
@@ -24,7 +24,7 @@
#include "test_allocator.h"
#include "test_macros.h"
-void test() {
+constexpr bool test() {
{
using A1 = limited_allocator<int, 10>;
using C = std::flat_set<int, std::less<int>, std::vector<int, A1>>;
@@ -59,10 +59,15 @@ void test() {
assert(c.max_size() <= max_dist);
assert(c.max_size() <= alloc_max_size(std::allocator<char>()));
}
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.capacity/size.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.capacity/size.pass.cpp
index 9f5ffdd066351..278d5ea2cdefd 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.capacity/size.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.capacity/size.pass.cpp
@@ -16,6 +16,7 @@
#include <deque>
#include <flat_set>
#include <functional>
+#include <type_traits>
#include <vector>
#include "MinSequenceContainer.h"
@@ -23,7 +24,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using M = std::flat_set<int, std::less<int>, KeyContainer>;
using S = typename M::size_type;
{
@@ -46,7 +47,7 @@ void test_one() {
}
{
M m;
- S s = 1000000;
+ S s = std::is_constant_evaluated() ? 100 : 1000000;
for (auto i = 0u; i < s; ++i) {
m.emplace(i);
}
@@ -56,15 +57,23 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/alloc.pass.cpp
index d14e883dd5e93..00a0d4849c2ed 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/alloc.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/alloc.pass.cpp
@@ -14,15 +14,18 @@
// explicit flat_set(const Allocator& a);
#include <cassert>
+#include <deque>
#include <flat_set>
#include <functional>
#include <vector>
+#include "MinSequenceContainer.h"
#include "test_macros.h"
#include "test_allocator.h"
#include "../../../test_compare.h"
-void test() {
+template <template <class...> class KeyContainer>
+constexpr void test() {
{
// The constructors in this subclause shall not participate in overload
// resolution unless uses_allocator_v<container_type, Alloc> is true.
@@ -30,8 +33,8 @@ void test() {
using C = test_less<int>;
using A1 = test_allocator<int>;
using A2 = other_allocator<int>;
- using V1 = std::vector<int, A1>;
- using V2 = std::vector<int, A2>;
+ using V1 = KeyContainer<int, A1>;
+ using V2 = KeyContainer<int, A2>;
using M1 = std::flat_set<int, C, V1>;
using M2 = std::flat_set<int, C, V2>;
static_assert(std::is_constructible_v<M1, const A1&>);
@@ -41,14 +44,14 @@ void test() {
}
{
// explicit
- using M = std::flat_set<int, std::less<int>, std::vector<int, test_allocator<int>>>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int, test_allocator<int>>>;
static_assert(std::is_constructible_v<M, test_allocator<int>>);
static_assert(!std::is_convertible_v<test_allocator<int>, M>);
}
{
using A = test_allocator<short>;
- using M = std::flat_set<int, std::less<int>, std::vector<int, test_allocator<int>>>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int, test_allocator<int>>>;
M m(A(0, 5));
assert(m.empty());
assert(m.begin() == m.end());
@@ -57,8 +60,21 @@ void test() {
}
}
+constexpr bool test() {
+ test<std::vector>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test<std::deque>();
+
+ return true;
+}
+
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/assign_initializer_list.pass.cpp
index ad49b62149036..44ac9d1a9040d 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/assign_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/assign_initializer_list.pass.cpp
@@ -24,7 +24,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
{
@@ -45,17 +45,25 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/compare.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/compare.pass.cpp
index 110757a1bb9ab..814445f91c17f 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/compare.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/compare.pass.cpp
@@ -23,27 +23,14 @@
#include "test_macros.h"
#include "../../../test_compare.h"
#include "test_allocator.h"
+#include "MinSequenceContainer.h"
+#include "min_allocator.h"
-void test() {
- {
- // The constructors in this subclause shall not participate in overload
- // resolution unless uses_allocator_v<container_type, Alloc> is true.
-
- using C = test_less<int>;
- using A1 = test_allocator<int>;
- using A2 = other_allocator<int>;
- using V1 = std::vector<int, A1>;
- using V2 = std::vector<int, A2>;
- using M1 = std::flat_set<int, C, V1>;
- using M2 = std::flat_set<int, C, V2>;
- static_assert(std::is_constructible_v<M1, const C&, const A1&>);
- static_assert(std::is_constructible_v<M2, const C&, const A2&>);
- static_assert(!std::is_constructible_v<M1, const C&, const A2&>);
- static_assert(!std::is_constructible_v<M2, const C&, const A1&>);
- }
+template <class KeyContainer>
+constexpr void test_compare() {
{
using C = test_less<int>;
- auto m = std::flat_set<int, C>(C(3));
+ auto m = std::flat_set<int, C, KeyContainer>(C(3));
assert(m.empty());
assert(m.begin() == m.end());
assert(m.key_comp() == C(3));
@@ -51,16 +38,20 @@ void test() {
{
// The one-argument ctor is explicit.
using C = test_less<int>;
- static_assert(std::is_constructible_v<std::flat_set<int, C>, C>);
- static_assert(!std::is_convertible_v<C, std::flat_set<int, C>>);
+ static_assert(std::is_constructible_v<std::flat_set<int, C, KeyContainer>, C>);
+ static_assert(!std::is_convertible_v<C, std::flat_set<int, C, KeyContainer>>);
- static_assert(std::is_constructible_v<std::flat_set<int>, std::less<int>>);
- static_assert(!std::is_convertible_v<std::less<int>, std::flat_set<int>>);
+ static_assert(std::is_constructible_v<std::flat_set<int, std::less<int>, KeyContainer>, std::less<int>>);
+ static_assert(!std::is_convertible_v<std::less<int>, std::flat_set<int, std::less<int>, KeyContainer>>);
}
+}
+
+template <template <class...> class KeyContainer>
+constexpr void test_compare_alloc() {
{
using C = test_less<int>;
using A1 = test_allocator<int>;
- auto m = std::flat_set<int, C, std::vector<int, A1>>(C(4), A1(5));
+ auto m = std::flat_set<int, C, KeyContainer<int, A1>>(C(4), A1(5));
assert(m.empty());
assert(m.begin() == m.end());
assert(m.key_comp() == C(4));
@@ -69,9 +60,9 @@ void test() {
}
{
// explicit(false)
- using C = test_less<int>;
- using A1 = test_allocator<int>;
- std::flat_set<int, C, std::deque<int, A1>> m = {C(4), A1(5)};
+ using C = test_less<int>;
+ using A1 = test_allocator<int>;
+ std::flat_set<int, C, KeyContainer<int, A1>> m = {C(4), A1(5)};
assert(m.empty());
assert(m.begin() == m.end());
assert(m.key_comp() == C(4));
@@ -80,8 +71,45 @@ void test() {
}
}
+constexpr bool test() {
+ {
+ // The constructors in this subclause shall not participate in overload
+ // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+ using C = test_less<int>;
+ using A1 = test_allocator<int>;
+ using A2 = other_allocator<int>;
+ using V1 = std::vector<int, A1>;
+ using V2 = std::vector<int, A2>;
+ using M1 = std::flat_set<int, C, V1>;
+ using M2 = std::flat_set<int, C, V2>;
+ static_assert(std::is_constructible_v<M1, const C&, const A1&>);
+ static_assert(std::is_constructible_v<M2, const C&, const A2&>);
+ static_assert(!std::is_constructible_v<M1, const C&, const A2&>);
+ static_assert(!std::is_constructible_v<M2, const C&, const A1&>);
+ }
+ test_compare<std::vector<int>>();
+ test_compare<MinSequenceContainer<int>>();
+ test_compare<std::vector<int, min_allocator<int>>>();
+
+ test_compare_alloc<std::vector>();
+
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ {
+ test_compare<std::deque<int>>();
+ test_compare_alloc<std::deque>();
+ }
+
+ return true;
+}
+
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/containers.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/containers.pass.cpp
index 6b1246885bf52..aaaa19a8a6d33 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/containers.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/containers.pass.cpp
@@ -36,44 +36,24 @@ void conversion_test(T);
template <class T, class... Args>
concept ImplicitlyConstructible = requires(Args&&... args) { conversion_test<T>({std::forward<Args>(args)...}); };
-void test() {
- {
- // The constructors in this subclause shall not participate in overload
- // resolution unless uses_allocator_v<container_type, Alloc> is true.
-
- using C = test_less<int>;
- using A1 = test_allocator<int>;
- using A2 = other_allocator<int>;
- using V1 = std::vector<int, A1>;
- using V2 = std::vector<int, A2>;
- using M1 = std::flat_set<int, C, V1>;
- using M2 = std::flat_set<int, C, V2>;
- static_assert(std::is_constructible_v<M1, const V1&, const A1&>);
- static_assert(std::is_constructible_v<M2, const V2&, const A2&>);
- static_assert(!std::is_constructible_v<M1, const V1&, const A2&>);
- static_assert(!std::is_constructible_v<M2, const V2&, const A1&>);
-
- static_assert(std::is_constructible_v<M1, const V1&, const C&, const A1&>);
- static_assert(std::is_constructible_v<M2, const V2&, const C&, const A2&>);
- static_assert(!std::is_constructible_v<M1, const V1&, const C&, const A2&>);
- static_assert(!std::is_constructible_v<M2, const V2&, const C&, const A1&>);
- }
+template <template <class...> class KeyContainer>
+constexpr void test() {
{
// flat_set(container_type)
- using M = std::flat_set<int>;
- std::vector<int> ks = {1, 1, 1, 2, 2, 3, 2, 3, 3};
- auto m = M(ks);
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int>>;
+ KeyContainer<int> ks = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+ auto m = M(ks);
assert(std::ranges::equal(m, std::vector<int>{1, 2, 3}));
// explicit
- static_assert(std::is_constructible_v<M, const std::vector<int>&>);
- static_assert(!ImplicitlyConstructible<M, const std::vector<int>&>);
+ static_assert(std::is_constructible_v<M, const KeyContainer<int>&>);
+ static_assert(!ImplicitlyConstructible<M, const KeyContainer<int>&>);
}
{
// flat_set(container_type)
// move-only
MoveOnly expected[] = {3, 2, 1};
- using Ks = std::deque<MoveOnly, min_allocator<MoveOnly>>;
+ using Ks = KeyContainer<MoveOnly, min_allocator<MoveOnly>>;
using M = std::flat_set<MoveOnly, std::greater<MoveOnly>, Ks>;
Ks ks;
ks.push_back(1);
@@ -87,8 +67,8 @@ void test() {
// flat_set(container_type)
// container's allocator is used
using A = test_allocator<int>;
- using M = std::flat_set<int, std::less<int>, std::deque<int, A>>;
- auto ks = std::deque<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(5));
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int, A>>;
+ auto ks = KeyContainer<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(5));
auto m = M(std::move(ks));
assert(ks.empty()); // it was moved-from
assert((m == M{1, 2, 3}));
@@ -97,22 +77,22 @@ void test() {
}
{
// flat_set(container_type , key_compare)
- using C = test_less<int>;
- using M = std::flat_set<int, C>;
- std::vector<int> ks = {1, 1, 1, 2, 2, 3, 2, 3, 3};
- auto m = M(ks, C(4));
+ using C = test_less<int>;
+ using M = std::flat_set<int, C, KeyContainer<int>>;
+ KeyContainer<int> ks = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+ auto m = M(ks, C(4));
assert(std::ranges::equal(m, std::vector<int>{1, 2, 3}));
assert(m.key_comp() == C(4));
// explicit
- static_assert(std::is_constructible_v<M, const std::vector<int>&, const C&>);
- static_assert(!ImplicitlyConstructible<M, const std::vector<int>&, const C&>);
+ static_assert(std::is_constructible_v<M, const KeyContainer<int>&, const C&>);
+ static_assert(!ImplicitlyConstructible<M, const KeyContainer<int>&, const C&>);
}
{
// flat_set(container_type , const Allocator&)
using A = test_allocator<int>;
- using M = std::flat_set<int, std::less<int>, std::deque<int, A>>;
- auto ks = std::deque<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(5));
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int, A>>;
+ auto ks = KeyContainer<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(5));
auto m = M(ks, A(4)); // replaces the allocators
assert(!ks.empty()); // it was an lvalue above
assert((m == M{1, 2, 3}));
@@ -120,7 +100,7 @@ void test() {
assert(keys.get_allocator() == A(4));
// explicit(false)
- static_assert(ImplicitlyConstructible<M, const std::deque<int, A>&, const A&>);
+ static_assert(ImplicitlyConstructible<M, const KeyContainer<int, A>&, const A&>);
M m2 = {ks, A(4)}; // implicit ctor
assert(!ks.empty()); // it was an lvalue above
assert(m2 == m);
@@ -129,11 +109,11 @@ void test() {
}
{
// flat_set(container_type , key_compare, const Allocator&)
- using C = test_less<int>;
- using A = test_allocator<int>;
- using M = std::flat_set<int, C, std::vector<int, A>>;
- std::vector<int, A> ks = {1, 1, 1, 2, 2, 3, 2, 3, 3};
- auto m = M(ks, C(4), A(5));
+ using C = test_less<int>;
+ using A = test_allocator<int>;
+ using M = std::flat_set<int, C, KeyContainer<int, A>>;
+ KeyContainer<int, A> ks = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+ auto m = M(ks, C(4), A(5));
assert(std::ranges::equal(m, std::vector<int, A>{1, 2, 3}));
assert(m.key_comp() == C(4));
auto m_copy = m;
@@ -141,7 +121,7 @@ void test() {
assert(keys.get_allocator() == A(5));
// explicit(false)
- static_assert(ImplicitlyConstructible<M, const std::vector<int, A>&, const A&>);
+ static_assert(ImplicitlyConstructible<M, const KeyContainer<int, A>&, const A&>);
M m2 = {ks, C(4), A(5)};
assert(m2 == m);
assert(m2.key_comp() == C(4));
@@ -150,8 +130,44 @@ void test() {
}
}
+constexpr bool test() {
+ {
+ // The constructors in this subclause shall not participate in overload
+ // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+ using C = test_less<int>;
+ using A1 = test_allocator<int>;
+ using A2 = other_allocator<int>;
+ using V1 = std::vector<int, A1>;
+ using V2 = std::vector<int, A2>;
+ using M1 = std::flat_set<int, C, V1>;
+ using M2 = std::flat_set<int, C, V2>;
+ static_assert(std::is_constructible_v<M1, const V1&, const A1&>);
+ static_assert(std::is_constructible_v<M2, const V2&, const A2&>);
+ static_assert(!std::is_constructible_v<M1, const V1&, const A2&>);
+ static_assert(!std::is_constructible_v<M2, const V2&, const A1&>);
+
+ static_assert(std::is_constructible_v<M1, const V1&, const C&, const A1&>);
+ static_assert(std::is_constructible_v<M2, const V2&, const C&, const A2&>);
+ static_assert(!std::is_constructible_v<M1, const V1&, const C&, const A2&>);
+ static_assert(!std::is_constructible_v<M2, const V2&, const C&, const A1&>);
+ }
+
+ test<std::vector>();
+
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test<std::deque>();
+
+ return true;
+}
+
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/copy.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/copy.pass.cpp
index 1ba550d98f01f..343725c294971 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/copy.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/copy.pass.cpp
@@ -14,6 +14,7 @@
#include <algorithm>
#include <cassert>
+#include <deque>
#include <flat_set>
#include <vector>
@@ -21,10 +22,11 @@
#include "../../../test_compare.h"
#include "test_allocator.h"
-void test() {
+template <template <class...> class KeyContainer>
+constexpr void test() {
{
using C = test_less<int>;
- std::vector<int, test_allocator<int>> ks({1, 3, 5}, test_allocator<int>(6));
+ KeyContainer<int, test_allocator<int>> ks({1, 3, 5}, test_allocator<int>(6));
using M = std::flat_set<int, C, decltype(ks)>;
auto mo = M(ks, C(5));
auto m = mo;
@@ -42,7 +44,7 @@ void test() {
}
{
using C = test_less<int>;
- using Ks = std::vector<int, other_allocator<int>>;
+ using Ks = KeyContainer<int, other_allocator<int>>;
auto ks = Ks({1, 3, 5}, other_allocator<int>(6));
using M = std::flat_set<int, C, Ks>;
auto mo = M(Ks(ks, other_allocator<int>(6)), C(5));
@@ -61,8 +63,21 @@ void test() {
}
}
+constexpr bool test() {
+ test<std::vector>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test<std::deque>();
+
+ return true;
+}
+
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/copy_alloc.pass.cpp
index 5011bd2003064..779d0f8132708 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/copy_alloc.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/copy_alloc.pass.cpp
@@ -23,7 +23,27 @@
#include "../../../test_compare.h"
#include "test_allocator.h"
-void test() {
+template <template <class...> class KeyContainer>
+constexpr void test() {
+ using C = test_less<int>;
+ KeyContainer<int, test_allocator<int>> ks({1, 3, 5}, test_allocator<int>(6));
+ using M = std::flat_set<int, C, decltype(ks)>;
+ auto mo = M(ks, C(5));
+ auto m = M(mo, test_allocator<int>(3));
+
+ assert(m.key_comp() == C(5));
+ assert(std::ranges::equal(m, ks));
+ auto keys = std::move(m).extract();
+ assert(keys.get_allocator() == test_allocator<int>(3));
+
+ // mo is unchanged
+ assert(mo.key_comp() == C(5));
+ assert(std::ranges::equal(mo, ks));
+ auto keys2 = std::move(mo).extract();
+ assert(keys2.get_allocator() == test_allocator<int>(6));
+}
+
+constexpr bool test() {
{
// The constructors in this subclause shall not participate in overload
// resolution unless uses_allocator_v<container_type, Alloc> is true.
@@ -40,28 +60,21 @@ void test() {
static_assert(!std::is_constructible_v<M1, const M1&, const A2&>);
static_assert(!std::is_constructible_v<M2, const M2&, const A1&>);
}
- {
- using C = test_less<int>;
- std::vector<int, test_allocator<int>> ks({1, 3, 5}, test_allocator<int>(6));
- using M = std::flat_set<int, C, decltype(ks)>;
- auto mo = M(ks, C(5));
- auto m = M(mo, test_allocator<int>(3));
- assert(m.key_comp() == C(5));
- assert(std::ranges::equal(m, ks));
- auto keys = std::move(m).extract();
- assert(keys.get_allocator() == test_allocator<int>(3));
+ test<std::vector>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test<std::deque>();
- // mo is unchanged
- assert(mo.key_comp() == C(5));
- assert(std::ranges::equal(mo, ks));
- auto keys2 = std::move(mo).extract();
- assert(keys2.get_allocator() == test_allocator<int>(6));
- }
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/copy_assign.pass.cpp
index 695363e3aeaba..0a43c3c03aa39 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/copy_assign.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/copy_assign.pass.cpp
@@ -13,6 +13,7 @@
// flat_set& operator=(const flat_set& m);
#include <algorithm>
+#include <deque>
#include <flat_set>
#include <functional>
#include <vector>
@@ -22,11 +23,12 @@
#include "../../../test_compare.h"
#include "test_allocator.h"
-void test() {
+template <template <class...> class KeyContainer>
+constexpr void test() {
{
// test_allocator is not propagated
using C = test_less<int>;
- std::vector<int, test_allocator<int>> ks({1, 3, 5}, test_allocator<int>(6));
+ KeyContainer<int, test_allocator<int>> ks({1, 3, 5}, test_allocator<int>(6));
using M = std::flat_set<int, C, decltype(ks)>;
auto mo = M(ks, C(5));
auto m = M({{3, 4, 5}}, C(3), test_allocator<int>(2));
@@ -46,7 +48,7 @@ void test() {
{
// other_allocator is propagated
using C = test_less<int>;
- using Ks = std::vector<int, other_allocator<int>>;
+ using Ks = KeyContainer<int, other_allocator<int>>;
auto ks = Ks({1, 3, 5}, other_allocator<int>(6));
using M = std::flat_set<int, C, Ks>;
auto mo = M(Ks(ks, other_allocator<int>(6)), C(5));
@@ -64,9 +66,9 @@ void test() {
auto keys2 = std::move(mo).extract();
assert(keys2.get_allocator() == other_allocator<int>(6));
}
- {
+ if (!std::is_constant_evaluated()) {
// comparator is copied and invariant is preserved
- using M = std::flat_set<int, std::function<bool(int, int)>>;
+ using M = std::flat_set<int, std::function<bool(int, int)>, KeyContainer<int>>;
M mo = M({1, 2}, std::less<int>());
M m = M({1, 2}, std::greater<int>());
assert(m.key_comp()(2, 1) == true);
@@ -77,7 +79,7 @@ void test() {
}
{
// self-assignment
- using M = std::flat_set<int>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int>>;
M m = {{1, 2}};
m = static_cast<const M&>(m);
assert((m == M{{1, 2}}));
@@ -93,8 +95,21 @@ void test() {
}
}
+constexpr bool test() {
+ test<std::vector>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test<std::deque>();
+
+ return true;
+}
+
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/default.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/default.pass.cpp
index 5cbd557eb8562..c7ab9d20f999b 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/default.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/default.pass.cpp
@@ -25,28 +25,29 @@
#include "test_macros.h"
struct DefaultCtableComp {
- explicit DefaultCtableComp() { default_constructed_ = true; }
- bool operator()(int, int) const { return false; }
+ constexpr explicit DefaultCtableComp() { default_constructed_ = true; }
+ constexpr bool operator()(int, int) const { return false; }
bool default_constructed_ = false;
};
struct ThrowingCtorComp {
- ThrowingCtorComp() noexcept(false) {}
- bool operator()(const auto&, const auto&) const { return false; }
+ constexpr ThrowingCtorComp() noexcept(false) {}
+ constexpr bool operator()(const auto&, const auto&) const { return false; }
};
-void test() {
+template <template <class...> class KeyContainer>
+constexpr void test() {
{
- std::flat_set<int> m;
+ std::flat_set<int, std::less<int>, KeyContainer<int>> m;
assert(m.empty());
}
{
// explicit(false)
- std::flat_set<int> m = {};
+ std::flat_set<int, std::less<int>, KeyContainer<int>> m = {};
assert(m.empty());
}
{
- std::flat_set<int, DefaultCtableComp, std::deque<int, min_allocator<int>>> m;
+ std::flat_set<int, DefaultCtableComp, KeyContainer<int, min_allocator<int>>> m;
assert(m.empty());
assert(m.begin() == m.end());
assert(m.key_comp().default_constructed_);
@@ -54,43 +55,56 @@ void test() {
{
using A1 = explicit_allocator<int>;
{
- std::flat_set<int, DefaultCtableComp, std::vector<int, A1>> m;
+ std::flat_set<int, DefaultCtableComp, KeyContainer<int, A1>> m;
assert(m.empty());
assert(m.key_comp().default_constructed_);
}
{
A1 a1;
- std::flat_set<int, DefaultCtableComp, std::vector<int, A1>> m(a1);
+ std::flat_set<int, DefaultCtableComp, KeyContainer<int, A1>> m(a1);
assert(m.empty());
assert(m.key_comp().default_constructed_);
}
}
#if defined(_LIBCPP_VERSION)
{
- using C = std::flat_set<MoveOnly>;
+ using C = std::flat_set<MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly>>;
static_assert(std::is_nothrow_default_constructible_v<C>);
C c;
}
{
- using C = std::flat_set<MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, test_allocator<MoveOnly>>>;
+ using C = std::flat_set<MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly, test_allocator<MoveOnly>>>;
static_assert(std::is_nothrow_default_constructible_v<C>);
C c;
}
#endif // _LIBCPP_VERSION
{
- using C = std::flat_set<MoveOnly, std::less<MoveOnly>, std::vector<MoveOnly, other_allocator<MoveOnly>>>;
+ using C = std::flat_set<MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly, other_allocator<MoveOnly>>>;
static_assert(!std::is_nothrow_default_constructible_v<C>);
C c;
}
{
- using C = std::flat_set<MoveOnly, ThrowingCtorComp>;
+ using C = std::flat_set<MoveOnly, ThrowingCtorComp, KeyContainer<MoveOnly>>;
static_assert(!std::is_nothrow_default_constructible_v<C>);
C c;
}
}
+constexpr bool test() {
+ test<std::vector>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test<std::deque>();
+
+ return true;
+}
+
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/dtor_noexcept.pass.cpp
index fa1e2478af459..f7a8f8719c22f 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/dtor_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/dtor_noexcept.pass.cpp
@@ -23,39 +23,53 @@
#include "test_allocator.h"
struct ThrowingDtorComp {
- bool operator()(const auto&, const auto&) const;
- ~ThrowingDtorComp() noexcept(false) {}
+ constexpr bool operator()(const auto&, const auto&) const;
+ constexpr ~ThrowingDtorComp() noexcept(false) {}
};
-void test() {
+template <template <class...> class KeyContainer>
+constexpr void test() {
{
- using C = std::flat_set<MoveOnly, MoveOnly>;
+ using C = std::flat_set<MoveOnly, std::less<MoveOnly>, KeyContainer<MoveOnly>>;
static_assert(std::is_nothrow_destructible_v<C>);
C c;
}
{
- using V = std::vector<MoveOnly, test_allocator<MoveOnly>>;
+ using V = KeyContainer<MoveOnly, test_allocator<MoveOnly>>;
using C = std::flat_set<MoveOnly, std::less<MoveOnly>, V>;
static_assert(std::is_nothrow_destructible_v<C>);
C c;
}
{
- using V = std::deque<MoveOnly, other_allocator<MoveOnly>>;
+ using V = KeyContainer<MoveOnly, other_allocator<MoveOnly>>;
using C = std::flat_set<MoveOnly, std::greater<MoveOnly>, V>;
static_assert(std::is_nothrow_destructible_v<C>);
C c;
}
#if defined(_LIBCPP_VERSION)
{
- using C = std::flat_set<MoveOnly, ThrowingDtorComp>;
+ using C = std::flat_set<MoveOnly, ThrowingDtorComp, KeyContainer<MoveOnly>>;
static_assert(!std::is_nothrow_destructible_v<C>);
C c;
}
#endif // _LIBCPP_VERSION
}
+constexpr bool test() {
+ test<std::vector>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test<std::deque>();
+
+ return true;
+}
+
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/initializer_list.pass.cpp
index 9aed5c88ee726..55eabcee578c3 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/initializer_list.pass.cpp
@@ -30,57 +30,17 @@
#include "../../../test_compare.h"
struct DefaultCtableComp {
- explicit DefaultCtableComp() { default_constructed_ = true; }
- bool operator()(int, int) const { return false; }
+ constexpr explicit DefaultCtableComp() { default_constructed_ = true; }
+ constexpr bool operator()(int, int) const { return false; }
bool default_constructed_ = false;
};
-void test() {
- {
- // The constructors in this subclause shall not participate in overload
- // resolution unless uses_allocator_v<container_type, Alloc> is true.
-
- using C = test_less<int>;
- using A1 = test_allocator<int>;
- using A2 = other_allocator<int>;
- using V1 = std::vector<int, A1>;
- using V2 = std::vector<int, A2>;
- using M1 = std::flat_set<int, C, V1>;
- using M2 = std::flat_set<int, C, V2>;
- using IL = std::initializer_list<int>;
- static_assert(std::is_constructible_v<M1, IL, const A1&>);
- static_assert(std::is_constructible_v<M2, IL, const A2&>);
- static_assert(!std::is_constructible_v<M1, IL, const A2&>);
- static_assert(!std::is_constructible_v<M2, IL, const A1&>);
-
- static_assert(std::is_constructible_v<M1, IL, const C&, const A1&>);
- static_assert(std::is_constructible_v<M2, IL, const C&, const A2&>);
- static_assert(!std::is_constructible_v<M1, IL, const C&, const A2&>);
- static_assert(!std::is_constructible_v<M2, IL, const C&, const A1&>);
- }
-
- {
- // initializer_list<value_type> needs to match exactly
- using M = std::flat_set<int>;
- using C = typename M::key_compare;
- static_assert(std::is_constructible_v<M, std::initializer_list<int>>);
- static_assert(std::is_constructible_v<M, std::initializer_list<int>, C>);
- static_assert(std::is_constructible_v<M, std::initializer_list<int>, C, std::allocator<int>>);
- static_assert(std::is_constructible_v<M, std::initializer_list<int>, std::allocator<int>>);
- static_assert(!std::is_constructible_v<M, std::initializer_list<const int>>);
- static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C>);
- static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C, std::allocator<int>>);
- static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, std::allocator<int>>);
- static_assert(!std::is_constructible_v<M, std::initializer_list<const int>>);
- static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C>);
- static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C, std::allocator<int>>);
- static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, std::allocator<int>>);
- }
-
+template <template <class...> class KeyContainer>
+constexpr void test() {
int expected[] = {1, 2, 3, 5};
{
// flat_set(initializer_list<value_type>);
- using M = std::flat_set<int>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int>>;
std::initializer_list<int> il = {5, 2, 2, 3, 1, 3};
M m(il);
assert(std::equal(m.begin(), m.end(), expected, expected + 4));
@@ -88,13 +48,13 @@ void test() {
{
// flat_set(initializer_list<value_type>);
// explicit(false)
- using M = std::flat_set<int>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int>>;
M m = {5, 2, 2, 3, 1, 3};
assert(std::equal(m.begin(), m.end(), expected, expected + 4));
}
{
// flat_set(initializer_list<value_type>);
- using M = std::flat_set<int, std::greater<int>, std::deque<int, min_allocator<int>>>;
+ using M = std::flat_set<int, std::greater<int>, KeyContainer<int, min_allocator<int>>>;
M m = {5, 2, 2, 3, 1, 3};
assert(std::equal(m.rbegin(), m.rend(), expected, expected + 4));
}
@@ -103,15 +63,14 @@ void test() {
{
// flat_set(initializer_list<value_type>);
// different comparator
- using M = std::flat_set<int, DefaultCtableComp, std::vector<int, A>>;
+ using M = std::flat_set<int, DefaultCtableComp, KeyContainer<int, A>>;
M m = {1, 2, 3};
assert(m.size() == 1);
- LIBCPP_ASSERT(*m.begin() == 1);
assert(m.key_comp().default_constructed_);
}
{
// flat_set(initializer_list<value_type>, const Allocator&);
- using M = std::flat_set<int, std::greater<int>, std::deque<int, A>>;
+ using M = std::flat_set<int, std::greater<int>, KeyContainer<int, A>>;
A a;
M m({5, 2, 2, 3, 1, 3}, a);
assert(std::equal(m.rbegin(), m.rend(), expected, expected + 4));
@@ -120,7 +79,7 @@ void test() {
{
// flat_set(initializer_list<value_type>, const key_compare&);
using C = test_less<int>;
- using M = std::flat_set<int, C>;
+ using M = std::flat_set<int, C, KeyContainer<int>>;
auto m = M({5, 2, 2, 3, 1, 3}, C(10));
assert(std::equal(m.begin(), m.end(), expected, expected + 4));
assert(m.key_comp() == C(10));
@@ -130,10 +89,10 @@ void test() {
assert(m2 == m);
assert(m2.key_comp() == C(10));
}
- {
+ if (!std::is_constant_evaluated()) {
// flat_set(initializer_list<value_type>, const key_compare&);
// Sorting uses the comparator that was passed in
- using M = std::flat_set<int, std::function<bool(int, int)>, std::deque<int, min_allocator<int>>>;
+ using M = std::flat_set<int, std::function<bool(int, int)>, KeyContainer<int, min_allocator<int>>>;
auto m = M({5, 2, 2, 1, 3, 1}, std::greater<int>());
assert(std::equal(m.rbegin(), m.rend(), expected, expected + 4));
assert(m.key_comp()(2, 1) == true);
@@ -141,15 +100,69 @@ void test() {
{
// flat_set(initializer_list<value_type> il, const key_compare& comp, const Alloc& a);
using A = explicit_allocator<int>;
- using M = std::flat_set<int, std::greater<int>, std::deque<int, A>>;
+ using M = std::flat_set<int, std::greater<int>, KeyContainer<int, A>>;
A a;
M m({5, 2, 2, 3, 1, 3}, {}, a);
assert(std::equal(m.rbegin(), m.rend(), expected, expected + 4));
}
}
+constexpr bool test() {
+ {
+ // The constructors in this subclause shall not participate in overload
+ // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+ using C = test_less<int>;
+ using A1 = test_allocator<int>;
+ using A2 = other_allocator<int>;
+ using V1 = std::vector<int, A1>;
+ using V2 = std::vector<int, A2>;
+ using M1 = std::flat_set<int, C, V1>;
+ using M2 = std::flat_set<int, C, V2>;
+ using IL = std::initializer_list<int>;
+ static_assert(std::is_constructible_v<M1, IL, const A1&>);
+ static_assert(std::is_constructible_v<M2, IL, const A2&>);
+ static_assert(!std::is_constructible_v<M1, IL, const A2&>);
+ static_assert(!std::is_constructible_v<M2, IL, const A1&>);
+
+ static_assert(std::is_constructible_v<M1, IL, const C&, const A1&>);
+ static_assert(std::is_constructible_v<M2, IL, const C&, const A2&>);
+ static_assert(!std::is_constructible_v<M1, IL, const C&, const A2&>);
+ static_assert(!std::is_constructible_v<M2, IL, const C&, const A1&>);
+ }
+
+ {
+ // initializer_list<value_type> needs to match exactly
+ using M = std::flat_set<int>;
+ using C = typename M::key_compare;
+ static_assert(std::is_constructible_v<M, std::initializer_list<int>>);
+ static_assert(std::is_constructible_v<M, std::initializer_list<int>, C>);
+ static_assert(std::is_constructible_v<M, std::initializer_list<int>, C, std::allocator<int>>);
+ static_assert(std::is_constructible_v<M, std::initializer_list<int>, std::allocator<int>>);
+ static_assert(!std::is_constructible_v<M, std::initializer_list<const int>>);
+ static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C>);
+ static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C, std::allocator<int>>);
+ static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, std::allocator<int>>);
+ static_assert(!std::is_constructible_v<M, std::initializer_list<const int>>);
+ static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C>);
+ static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, C, std::allocator<int>>);
+ static_assert(!std::is_constructible_v<M, std::initializer_list<const int>, std::allocator<int>>);
+ }
+
+ test<std::vector>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test<std::deque>();
+
+ return true;
+}
+
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/iter_iter.pass.cpp
index 2d0b07c9155fd..4d64e560ce231 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/iter_iter.pass.cpp
@@ -23,43 +23,21 @@
#include <functional>
#include <vector>
+#include "MinSequenceContainer.h"
#include "min_allocator.h"
#include "test_allocator.h"
#include "test_iterators.h"
#include "test_macros.h"
#include "../../../test_compare.h"
-void test() {
- {
- // The constructors in this subclause shall not participate in overload
- // resolution unless uses_allocator_v<container_type, Alloc> is true.
-
- using C = test_less<int>;
- using A1 = test_allocator<int>;
- using A2 = other_allocator<int>;
- using V1 = std::vector<int, A1>;
- using V2 = std::vector<int, A2>;
- using M1 = std::flat_set<int, C, V1>;
- using M2 = std::flat_set<int, C, V2>;
- using Iter1 = typename M1::iterator;
- using Iter2 = typename M2::iterator;
- static_assert(std::is_constructible_v<M1, Iter1, Iter1, const A1&>);
- static_assert(std::is_constructible_v<M2, Iter2, Iter2, const A2&>);
- static_assert(!std::is_constructible_v<M1, Iter1, Iter1, const A2&>);
- static_assert(!std::is_constructible_v<M2, Iter2, Iter2, const A1&>);
-
- static_assert(std::is_constructible_v<M1, Iter1, Iter1, const C&, const A1&>);
- static_assert(std::is_constructible_v<M2, Iter2, Iter2, const C&, const A2&>);
- static_assert(!std::is_constructible_v<M1, Iter1, Iter1, const C&, const A2&>);
- static_assert(!std::is_constructible_v<M2, Iter2, Iter2, const C&, const A1&>);
- }
-
+template <class KeyContainer>
+constexpr void test() {
int ar[] = {1, 1, 1, 2, 2, 3, 2, 3, 3};
int expected[] = {1, 2, 3};
{
// flat_set(InputIterator , InputIterator)
// cpp17_input_iterator
- using M = std::flat_set<int>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer>;
auto m = M(cpp17_input_iterator<const int*>(ar), cpp17_input_iterator<const int*>(ar + 9));
assert(std::ranges::equal(m, expected));
@@ -70,21 +48,21 @@ void test() {
{
// flat_set(InputIterator , InputIterator)
// greater
- using M = std::flat_set<int, std::greater<int>, std::deque<int, min_allocator<int>>>;
+ using M = std::flat_set<int, std::greater<int>, KeyContainer>;
auto m = M(cpp17_input_iterator<const int*>(ar), cpp17_input_iterator<const int*>(ar + 9));
- assert(std::ranges::equal(m, std::deque<int, min_allocator<int>>{3, 2, 1}));
+ assert(std::ranges::equal(m, KeyContainer{3, 2, 1}));
}
{
// flat_set(InputIterator , InputIterator)
// Test when the operands are of array type (also contiguous iterator type)
- using M = std::flat_set<int, std::greater<int>, std::vector<int, min_allocator<int>>>;
+ using M = std::flat_set<int, std::greater<int>, KeyContainer>;
auto m = M(ar, ar);
assert(m.empty());
}
{
// flat_set(InputIterator , InputIterator, const key_compare&)
using C = test_less<int>;
- using M = std::flat_set<int, C, std::vector<int>>;
+ using M = std::flat_set<int, C, KeyContainer>;
auto m = M(ar, ar + 9, C(3));
assert(std::ranges::equal(m, expected));
assert(m.key_comp() == C(3));
@@ -94,10 +72,17 @@ void test() {
assert(m2 == m);
assert(m2.key_comp() == C(3));
}
+}
+
+template <template <class...> class KeyContainer>
+constexpr void test_alloc() {
+ int ar[] = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+ int expected[] = {1, 2, 3};
+
{
// flat_set(InputIterator , InputIterator, const Allocator&)
using A1 = test_allocator<int>;
- using M = std::flat_set<int, std::less<int>, std::vector<int, A1>>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int, A1>>;
auto m = M(ar, ar + 9, A1(5));
assert(std::ranges::equal(m, expected));
assert(std::move(m).extract().get_allocator() == A1(5));
@@ -106,7 +91,7 @@ void test() {
// flat_set(InputIterator , InputIterator, const Allocator&)
// explicit(false)
using A1 = test_allocator<int>;
- using M = std::flat_set<int, std::less<int>, std::vector<int, A1>>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int, A1>>;
M m = {ar, ar + 9, A1(5)}; // implicit ctor
assert(std::ranges::equal(m, expected));
assert(std::move(m).extract().get_allocator() == A1(5));
@@ -115,7 +100,7 @@ void test() {
// flat_set(InputIterator , InputIterator, const key_compare&, const Allocator&)
using C = test_less<int>;
using A1 = test_allocator<int>;
- using M = std::flat_set<int, C, std::vector<int, A1>>;
+ using M = std::flat_set<int, C, KeyContainer<int, A1>>;
auto m = M(ar, ar + 9, C(3), A1(5));
assert(std::ranges::equal(m, expected));
assert(m.key_comp() == C(3));
@@ -125,7 +110,7 @@ void test() {
// flat_set(InputIterator , InputIterator, const key_compare&, const Allocator&)
// explicit(false)
using A1 = test_allocator<int>;
- using M = std::flat_set<int, std::less<int>, std::deque<int, A1>>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int, A1>>;
M m = {ar, ar + 9, {}, A1(5)}; // implicit ctor
assert(std::ranges::equal(m, expected));
LIBCPP_ASSERT(std::ranges::equal(m, expected));
@@ -133,8 +118,53 @@ void test() {
}
}
+constexpr bool test() {
+ {
+ // The constructors in this subclause shall not participate in overload
+ // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+ using C = test_less<int>;
+ using A1 = test_allocator<int>;
+ using A2 = other_allocator<int>;
+ using V1 = std::vector<int, A1>;
+ using V2 = std::vector<int, A2>;
+ using M1 = std::flat_set<int, C, V1>;
+ using M2 = std::flat_set<int, C, V2>;
+ using Iter1 = typename M1::iterator;
+ using Iter2 = typename M2::iterator;
+ static_assert(std::is_constructible_v<M1, Iter1, Iter1, const A1&>);
+ static_assert(std::is_constructible_v<M2, Iter2, Iter2, const A2&>);
+ static_assert(!std::is_constructible_v<M1, Iter1, Iter1, const A2&>);
+ static_assert(!std::is_constructible_v<M2, Iter2, Iter2, const A1&>);
+
+ static_assert(std::is_constructible_v<M1, Iter1, Iter1, const C&, const A1&>);
+ static_assert(std::is_constructible_v<M2, Iter2, Iter2, const C&, const A2&>);
+ static_assert(!std::is_constructible_v<M1, Iter1, Iter1, const C&, const A2&>);
+ static_assert(!std::is_constructible_v<M2, Iter2, Iter2, const C&, const A1&>);
+ }
+
+ test<std::vector<int>>();
+ test<MinSequenceContainer<int>>();
+ test<std::vector<int, min_allocator<int>>>();
+
+ test_alloc<std::vector>();
+
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ {
+ test<std::deque<int>>();
+ test_alloc<std::deque>();
+ }
+
+ return true;
+}
+
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move.pass.cpp
index e26f8c8f25ce1..17c4b3550a784 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move.pass.cpp
@@ -25,11 +25,12 @@
#include "test_allocator.h"
#include "min_allocator.h"
-void test() {
+template <template <class...> class KeyContainer>
+constexpr void test() {
{
using C = test_less<int>;
using A = test_allocator<int>;
- using M = std::flat_set<int, C, std::deque<int, A>>;
+ using M = std::flat_set<int, C, KeyContainer<int, A>>;
M mo = M({1, 2, 3}, C(5), A(7));
M m = std::move(mo);
assert((m == M{1, 2, 3}));
@@ -43,7 +44,7 @@ void test() {
{
using C = test_less<int>;
using A = min_allocator<int>;
- using M = std::flat_set<int, C, std::vector<int, A>>;
+ using M = std::flat_set<int, C, KeyContainer<int, A>>;
M mo = M({1, 2, 3}, C(5), A());
M m = std::move(mo);
assert((m == M{1, 2, 3}));
@@ -54,9 +55,9 @@ void test() {
assert(mo.key_comp() == C(5));
assert(std::move(mo).extract().get_allocator() == A());
}
- {
+ if (!std::is_constant_evaluated()) {
// A moved-from flat_set maintains its class invariant in the presence of moved-from comparators.
- using M = std::flat_set<int, std::function<bool(int, int)>>;
+ using M = std::flat_set<int, std::function<bool(int, int)>, KeyContainer<int>>;
M mo = M({1, 2, 3}, std::less<int>());
M m = std::move(mo);
assert(m.size() == 3);
@@ -86,47 +87,35 @@ struct ThrowingMoveAllocator {
using value_type = T;
explicit ThrowingMoveAllocator() = default;
ThrowingMoveAllocator(const ThrowingMoveAllocator&) = default;
- ThrowingMoveAllocator(ThrowingMoveAllocator&&) noexcept(false) {}
- T* allocate(std::ptrdiff_t n) { return std::allocator<T>().allocate(n); }
- void deallocate(T* p, std::ptrdiff_t n) { return std::allocator<T>().deallocate(p, n); }
+ constexpr ThrowingMoveAllocator(ThrowingMoveAllocator&&) noexcept(false) {}
+ constexpr T* allocate(std::ptrdiff_t n) { return std::allocator<T>().allocate(n); }
+ constexpr void deallocate(T* p, std::ptrdiff_t n) { return std::allocator<T>().deallocate(p, n); }
friend bool operator==(ThrowingMoveAllocator, ThrowingMoveAllocator) = default;
};
struct ThrowingMoveComp {
ThrowingMoveComp() = default;
- ThrowingMoveComp(const ThrowingMoveComp&) noexcept(true) {}
- ThrowingMoveComp(ThrowingMoveComp&&) noexcept(false) {}
- bool operator()(const auto&, const auto&) const { return false; }
-};
-
-struct MoveSensitiveComp {
- MoveSensitiveComp() noexcept(false) = default;
- MoveSensitiveComp(const MoveSensitiveComp&) noexcept = default;
- MoveSensitiveComp(MoveSensitiveComp&& rhs) { rhs.is_moved_from_ = true; }
- MoveSensitiveComp& operator=(const MoveSensitiveComp&) noexcept(false) = default;
- MoveSensitiveComp& operator=(MoveSensitiveComp&& rhs) {
- rhs.is_moved_from_ = true;
- return *this;
- }
- bool operator()(const auto&, const auto&) const { return false; }
- bool is_moved_from_ = false;
+ constexpr ThrowingMoveComp(const ThrowingMoveComp&) noexcept(true) {}
+ constexpr ThrowingMoveComp(ThrowingMoveComp&&) noexcept(false) {}
+ constexpr bool operator()(const auto&, const auto&) const { return false; }
};
-void test_move_noexcept() {
+template <template <class...> class KeyContainer>
+constexpr void test_move_noexcept() {
{
- using C = std::flat_set<int>;
+ using C = std::flat_set<int, std::less<int>, KeyContainer<int>>;
LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<C>);
C c;
C d = std::move(c);
}
{
- using C = std::flat_set<int, std::less<int>, std::deque<int, test_allocator<int>>>;
+ using C = std::flat_set<int, std::less<int>, KeyContainer<int, test_allocator<int>>>;
LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<C>);
C c;
C d = std::move(c);
}
#if _LIBCPP_VERSION
- {
+ if (!std::is_constant_evaluated()) {
// Container fails to be nothrow-move-constructible; this relies on libc++'s support for non-nothrow-copyable allocators
using C = std::flat_set<int, std::less<int>, std::deque<int, ThrowingMoveAllocator<int>>>;
static_assert(!std::is_nothrow_move_constructible_v<std::deque<int, ThrowingMoveAllocator<int>>>);
@@ -137,13 +126,26 @@ void test_move_noexcept() {
#endif // _LIBCPP_VERSION
{
// Comparator fails to be nothrow-move-constructible
- using C = std::flat_set<int, ThrowingMoveComp>;
+ using C = std::flat_set<int, ThrowingMoveComp, KeyContainer<int>>;
static_assert(!std::is_nothrow_move_constructible_v<C>);
C c;
C d = std::move(c);
}
}
+constexpr bool test() {
+ test<std::vector>();
+ test_move_noexcept<std::vector>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ {
+ test<std::deque>();
+ test_move_noexcept<std::deque>();
+ }
+ return true;
+}
+
#if !defined(TEST_HAS_NO_EXCEPTIONS)
static int countdown = 0;
@@ -179,10 +181,12 @@ void test_move_exception() {
int main(int, char**) {
test();
- test_move_noexcept();
#if !defined(TEST_HAS_NO_EXCEPTIONS)
test_move_exception();
#endif
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move_alloc.pass.cpp
index 489b6ff36324b..a2253208422d5 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move_alloc.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move_alloc.pass.cpp
@@ -24,28 +24,13 @@
#include "../../../test_compare.h"
#include "test_allocator.h"
-void test() {
- {
- // The constructors in this subclause shall not participate in overload
- // resolution unless uses_allocator_v<container_type, Alloc> is true.
-
- using C = test_less<int>;
- using A1 = test_allocator<int>;
- using A2 = other_allocator<int>;
- using V1 = std::vector<int, A1>;
- using V2 = std::vector<int, A2>;
- using M1 = std::flat_set<int, C, V1>;
- using M2 = std::flat_set<int, C, V2>;
- static_assert(std::is_constructible_v<M1, M1&&, const A1&>);
- static_assert(std::is_constructible_v<M2, M2&&, const A2&>);
- static_assert(!std::is_constructible_v<M1, M1&&, const A2&>);
- static_assert(!std::is_constructible_v<M2, M2&&, const A1&>);
- }
+template <template <class...> class KeyContainer>
+constexpr void test() {
{
int expected[] = {1, 2, 3};
using C = test_less<int>;
using A = test_allocator<int>;
- using M = std::flat_set<int, C, std::deque<int, A>>;
+ using M = std::flat_set<int, C, KeyContainer<int, A>>;
auto mo = M(expected, expected + 3, C(5), A(7));
auto m = M(std::move(mo), A(3));
@@ -72,8 +57,38 @@ void test() {
}
}
+constexpr bool test() {
+ {
+ // The constructors in this subclause shall not participate in overload
+ // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+ using C = test_less<int>;
+ using A1 = test_allocator<int>;
+ using A2 = other_allocator<int>;
+ using V1 = std::vector<int, A1>;
+ using V2 = std::vector<int, A2>;
+ using M1 = std::flat_set<int, C, V1>;
+ using M2 = std::flat_set<int, C, V2>;
+ static_assert(std::is_constructible_v<M1, M1&&, const A1&>);
+ static_assert(std::is_constructible_v<M2, M2&&, const A2&>);
+ static_assert(!std::is_constructible_v<M1, M1&&, const A2&>);
+ static_assert(!std::is_constructible_v<M2, M2&&, const A1&>);
+ }
+
+ test<std::vector>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test<std::deque>();
+
+ return true;
+}
+
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move_assign.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move_assign.pass.cpp
index 0e0ab0aa135f9..f54acea41e3c7 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move_assign.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/move_assign.pass.cpp
@@ -30,9 +30,9 @@
struct MoveNegates {
int value_ = 0;
MoveNegates() = default;
- MoveNegates(int v) : value_(v) {}
- MoveNegates(MoveNegates&& rhs) : value_(rhs.value_) { rhs.value_ = -rhs.value_; }
- MoveNegates& operator=(MoveNegates&& rhs) {
+ constexpr MoveNegates(int v) : value_(v) {}
+ constexpr MoveNegates(MoveNegates&& rhs) : value_(rhs.value_) { rhs.value_ = -rhs.value_; }
+ constexpr MoveNegates& operator=(MoveNegates&& rhs) {
value_ = rhs.value_;
rhs.value_ = -rhs.value_;
return *this;
@@ -44,9 +44,9 @@ struct MoveNegates {
struct MoveClears {
int value_ = 0;
MoveClears() = default;
- MoveClears(int v) : value_(v) {}
- MoveClears(MoveClears&& rhs) : value_(rhs.value_) { rhs.value_ = 0; }
- MoveClears& operator=(MoveClears&& rhs) {
+ constexpr MoveClears(int v) : value_(v) {}
+ constexpr MoveClears(MoveClears&& rhs) : value_(rhs.value_) { rhs.value_ = 0; }
+ constexpr MoveClears& operator=(MoveClears&& rhs) {
value_ = rhs.value_;
rhs.value_ = 0;
return *this;
@@ -68,11 +68,12 @@ struct MoveAssignThrows : std::vector<int> {
};
#endif // TEST_HAS_NO_EXCEPTIONS
-void test_move_assign_clears() {
+template <template <class...> class KeyContainer>
+constexpr void test_move_assign_clears() {
// Preserves the class invariant for the moved-from flat_set.
{
const int expected[] = {1, 2, 3, 4, 5, 6, 7, 8};
- using M = std::flat_set<MoveNegates, std::less<MoveNegates>>;
+ using M = std::flat_set<MoveNegates, std::less<MoveNegates>, KeyContainer<MoveNegates>>;
M m = M(expected, expected + 8);
M m2 = M(expected, expected + 3);
@@ -89,7 +90,7 @@ void test_move_assign_clears() {
}
{
const int expected[] = {1, 2, 3, 4, 5, 6, 7, 8};
- using M = std::flat_set<MoveClears, std::less<MoveClears>>;
+ using M = std::flat_set<MoveClears, std::less<MoveClears>, KeyContainer<MoveClears>>;
M m = M(expected, expected + 8);
M m2 = M(expected, expected + 3);
@@ -106,7 +107,7 @@ void test_move_assign_clears() {
}
{
// moved-from object maintains invariant if one of underlying container does not clear after move
- using M = std::flat_set<int, std::less<>, std::vector<int>>;
+ using M = std::flat_set<int, std::less<>, CopyOnlyVector<int>>;
M m1 = M({1, 2, 3});
M m2 = M({1, 2});
m2 = std::move(m1);
@@ -115,7 +116,7 @@ void test_move_assign_clears() {
LIBCPP_ASSERT(m1.empty());
}
#if !defined(TEST_HAS_NO_EXCEPTIONS)
- {
+ if (!std::is_constant_evaluated()) {
using M = std::flat_set<int, std::less<>, MoveAssignThrows>;
M m1 = {1, 2, 3};
M m2 = {1, 2};
@@ -189,11 +190,12 @@ void test_move_assign_no_except() {
}
}
-void test() {
+template <template <class...> class KeyContainer>
+constexpr void test() {
{
using C = test_less<int>;
using A1 = test_allocator<int>;
- using M = std::flat_set<int, C, std::vector<int, A1>>;
+ using M = std::flat_set<int, C, KeyContainer<int, A1>>;
M mo = M({1, 2, 3}, C(5), A1(7));
M m = M({}, C(3), A1(7));
std::same_as<M&> decltype(auto) r = m = std::move(mo);
@@ -207,7 +209,7 @@ void test() {
{
using C = test_less<int>;
using A1 = other_allocator<int>;
- using M = std::flat_set<int, C, std::deque<int, A1>>;
+ using M = std::flat_set<int, C, KeyContainer<int, A1>>;
M mo = M({4, 5}, C(5), A1(7));
M m = M({1, 2, 3, 4}, C(3), A1(7));
std::same_as<M&> decltype(auto) r = m = std::move(mo);
@@ -220,7 +222,7 @@ void test() {
}
{
using A = min_allocator<int>;
- using M = std::flat_set<int, std::greater<int>, std::vector<int, A>>;
+ using M = std::flat_set<int, std::greater<int>, KeyContainer<int, A>>;
M mo = M({5, 4, 3}, A());
M m = M({4, 3, 2, 1}, A());
std::same_as<M&> decltype(auto) r = m = std::move(mo);
@@ -232,10 +234,27 @@ void test() {
}
}
+constexpr bool test() {
+ test<std::vector>();
+ test_move_assign_clears<std::vector>();
+
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ {
+ test<std::deque>();
+ test_move_assign_clears<std::deque>();
+ }
+
+ return true;
+}
+
int main(int, char**) {
test();
- test_move_assign_clears();
test_move_assign_no_except();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/range.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/range.pass.cpp
index bd7b5c12432e9..75b7a7d66ad48 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/range.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/range.pass.cpp
@@ -26,6 +26,7 @@
#include <string>
#include <vector>
+#include "MinSequenceContainer.h"
#include "min_allocator.h"
#include "test_allocator.h"
#include "test_iterators.h"
@@ -56,35 +57,14 @@ static_assert(
!std::
is_constructible_v<Set, std::from_range_t, RangeOf<std::pair<int, int>>, std::less<int>, std::allocator<int>>);
-void test() {
- {
- // The constructors in this subclause shall not participate in overload
- // resolution unless uses_allocator_v<container_type, Alloc> is true.
-
- using C = test_less<int>;
- using A1 = test_allocator<int>;
- using A2 = other_allocator<int>;
- using V1 = std::vector<int, A1>;
- using V2 = std::vector<int, A2>;
- using M1 = std::flat_set<int, C, V1>;
- using M2 = std::flat_set<int, C, V2>;
- static_assert(std::is_constructible_v<M1, std::from_range_t, M1, const A1&>);
- static_assert(std::is_constructible_v<M2, std::from_range_t, M2, const A2&>);
- static_assert(!std::is_constructible_v<M1, std::from_range_t, M1, const A2&>);
- static_assert(!std::is_constructible_v<M2, std::from_range_t, M2, const A1&>);
-
- static_assert(std::is_constructible_v<M1, std::from_range_t, M1, const C&, const A1&>);
- static_assert(std::is_constructible_v<M2, std::from_range_t, M2, const C&, const A2&>);
- static_assert(!std::is_constructible_v<M1, std::from_range_t, M1, const C&, const A2&>);
- static_assert(!std::is_constructible_v<M2, std::from_range_t, M2, const C&, const A1&>);
- }
-
+template <class KeyContainer>
+constexpr void test() {
int ar[] = {1, 1, 1, 2, 2, 3, 2, 3, 3};
int expected[] = {1, 2, 3};
{
// flat_set(from_range_t, R&&)
// input_range && !common
- using M = std::flat_set<int>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer>;
using Iter = cpp20_input_iterator<const int*>;
using Sent = sentinel_wrapper<Iter>;
using R = std::ranges::subrange<Iter, Sent>;
@@ -99,17 +79,17 @@ void test() {
{
// flat_set(from_range_t, R&&)
// greater
- using M = std::flat_set<int, std::greater<int>, std::deque<int, min_allocator<int>>>;
+ using M = std::flat_set<int, std::greater<int>, KeyContainer>;
using Iter = cpp20_input_iterator<const int*>;
using Sent = sentinel_wrapper<Iter>;
using R = std::ranges::subrange<Iter, Sent>;
auto m = M(std::from_range, R(Iter(ar), Sent(Iter(ar + 9))));
- assert(std::ranges::equal(m, std::deque<int, min_allocator<int>>{3, 2, 1}));
+ assert(std::ranges::equal(m, KeyContainer{3, 2, 1}));
}
{
// flat_set(from_range_t, R&&)
// contiguous range
- using M = std::flat_set<int>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer>;
using R = std::ranges::subrange<const int*>;
auto m = M(std::from_range, R(ar, ar + 9));
assert(std::ranges::equal(m, expected));
@@ -117,7 +97,7 @@ void test() {
{
// flat_set(from_range_t, R&&, const key_compare&)
using C = test_less<int>;
- using M = std::flat_set<int, C, std::vector<int>>;
+ using M = std::flat_set<int, C, KeyContainer>;
using R = std::ranges::subrange<const int*>;
auto m = M(std::from_range, R(ar, ar + 9), C(3));
assert(std::ranges::equal(m, expected));
@@ -128,10 +108,16 @@ void test() {
assert(m2 == m);
assert(m2.key_comp() == C(3));
}
+}
+
+template <template <class...> class KeyContainer>
+constexpr void test_alloc() {
+ int ar[] = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+ int expected[] = {1, 2, 3};
{
// flat_set(from_range_t, R&&, const Allocator&)
using A1 = test_allocator<int>;
- using M = std::flat_set<int, std::less<int>, std::vector<int, A1>>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int, A1>>;
using R = std::ranges::subrange<const int*>;
auto m = M(std::from_range, R(ar, ar + 9), A1(5));
assert(std::ranges::equal(m, expected));
@@ -141,7 +127,7 @@ void test() {
// flat_set(from_range_t, R&&, const Allocator&)
// explicit(false)
using A1 = test_allocator<int>;
- using M = std::flat_set<int, std::less<int>, std::deque<int, A1>>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int, A1>>;
using R = std::ranges::subrange<const int*>;
M m = {std::from_range, R(ar, ar + 9), A1(5)}; // implicit ctor
assert(std::ranges::equal(m, expected));
@@ -151,7 +137,7 @@ void test() {
// flat_set(from_range_t, R&&, const key_compare&, const Allocator&)
using C = test_less<int>;
using A1 = test_allocator<int>;
- using M = std::flat_set<int, C, std::vector<int, A1>>;
+ using M = std::flat_set<int, C, KeyContainer<int, A1>>;
using R = std::ranges::subrange<const int*>;
auto m = M(std::from_range, R(ar, ar + 9), C(3), A1(5));
assert(std::ranges::equal(m, expected));
@@ -162,7 +148,7 @@ void test() {
// flat_set(from_range_t, R&&, const key_compare&, const Allocator&)
// explicit(false)
using A1 = test_allocator<int>;
- using M = std::flat_set<int, std::less<int>, std::deque<int, A1>>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int, A1>>;
using R = std::ranges::subrange<const int*>;
M m = {std::from_range, R(ar, ar + 9), {}, A1(5)}; // implicit ctor
assert(std::ranges::equal(m, expected));
@@ -170,8 +156,51 @@ void test() {
}
}
+constexpr bool test() {
+ {
+ // The constructors in this subclause shall not participate in overload
+ // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+ using C = test_less<int>;
+ using A1 = test_allocator<int>;
+ using A2 = other_allocator<int>;
+ using V1 = std::vector<int, A1>;
+ using V2 = std::vector<int, A2>;
+ using M1 = std::flat_set<int, C, V1>;
+ using M2 = std::flat_set<int, C, V2>;
+ static_assert(std::is_constructible_v<M1, std::from_range_t, M1, const A1&>);
+ static_assert(std::is_constructible_v<M2, std::from_range_t, M2, const A2&>);
+ static_assert(!std::is_constructible_v<M1, std::from_range_t, M1, const A2&>);
+ static_assert(!std::is_constructible_v<M2, std::from_range_t, M2, const A1&>);
+
+ static_assert(std::is_constructible_v<M1, std::from_range_t, M1, const C&, const A1&>);
+ static_assert(std::is_constructible_v<M2, std::from_range_t, M2, const C&, const A2&>);
+ static_assert(!std::is_constructible_v<M1, std::from_range_t, M1, const C&, const A2&>);
+ static_assert(!std::is_constructible_v<M2, std::from_range_t, M2, const C&, const A1&>);
+ }
+
+ test<std::vector<int>>();
+ test<std::vector<int, min_allocator<int>>>();
+ test<MinSequenceContainer<int>>();
+
+ test_alloc<std::vector>();
+
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ {
+ test<std::deque<int>>();
+ test_alloc<std::deque>();
+ }
+
+ return true;
+}
+
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_container.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_container.pass.cpp
index 873ff32b62936..32dd0b6586675 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_container.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_container.pass.cpp
@@ -30,33 +30,13 @@
#include "test_macros.h"
#include "../../../test_compare.h"
-void test() {
- {
- // The constructors in this subclause shall not participate in overload
- // resolution unless uses_allocator_v<container_type, Alloc> is true.
-
- using C = test_less<int>;
- using A1 = test_allocator<int>;
- using A2 = other_allocator<int>;
- using V1 = std::vector<int, A1>;
- using V2 = std::vector<int, A2>;
- using M1 = std::flat_set<int, C, V1>;
- using M2 = std::flat_set<int, C, V2>;
- static_assert(std::is_constructible_v<M1, std::sorted_unique_t, const V1&, const A1&>);
- static_assert(std::is_constructible_v<M2, std::sorted_unique_t, const V2&, const A2&>);
- static_assert(!std::is_constructible_v<M1, std::sorted_unique_t, const V1&, const A2&>);
- static_assert(!std::is_constructible_v<M2, std::sorted_unique_t, const V2&, const A1&>);
-
- static_assert(std::is_constructible_v<M1, std::sorted_unique_t, const V1&, const C&, const A1&>);
- static_assert(std::is_constructible_v<M2, std::sorted_unique_t, const V2&, const C&, const A2&>);
- static_assert(!std::is_constructible_v<M1, std::sorted_unique_t, const V1&, const C&, const A2&>);
- static_assert(!std::is_constructible_v<M2, std::sorted_unique_t, const V2&, const C&, const A1&>);
- }
+template <template <class...> class KeyContainer>
+constexpr void test() {
{
// flat_set(sorted_unique_t, container_type)
- using M = std::flat_set<int>;
- std::vector<int> ks = {1, 2, 4, 10};
- auto ks2 = ks;
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int>>;
+ KeyContainer<int> ks = {1, 2, 4, 10};
+ auto ks2 = ks;
auto m = M(std::sorted_unique, ks);
assert((m == M{1, 2, 4, 10}));
@@ -71,7 +51,7 @@ void test() {
{
// flat_set(sorted_unique_t, container_type)
// non-default container, comparator and allocator type
- using Ks = std::deque<int, min_allocator<int>>;
+ using Ks = KeyContainer<int, min_allocator<int>>;
using M = std::flat_set<int, std::greater<int>, Ks>;
Ks ks = {10, 4, 2, 1};
auto m = M(std::sorted_unique, ks);
@@ -84,8 +64,8 @@ void test() {
// flat_set(sorted_unique_t, container_type)
// allocator copied into the containers
using A = test_allocator<int>;
- using M = std::flat_set<int, std::less<int>, std::deque<int, A>>;
- auto ks = std::deque<int, A>({1, 2, 4, 10}, A(4));
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int, A>>;
+ auto ks = KeyContainer<int, A>({1, 2, 4, 10}, A(4));
auto m = M(std::sorted_unique, std::move(ks));
assert(ks.empty()); // it was moved-from
assert((m == M{1, 2, 4, 10}));
@@ -93,9 +73,9 @@ void test() {
}
{
// flat_set(sorted_unique_t, container_type , key_compare)
- using C = test_less<int>;
- using M = std::flat_set<int, C>;
- std::vector<int> ks = {1, 2, 4, 10};
+ using C = test_less<int>;
+ using M = std::flat_set<int, C, KeyContainer<int>>;
+ KeyContainer<int> ks = {1, 2, 4, 10};
auto m = M(std::sorted_unique, ks, C(4));
assert((m == M{1, 2, 4, 10}));
@@ -108,11 +88,11 @@ void test() {
}
{
// flat_set(sorted_unique_t, container_type , key_compare, const Allocator&)
- using C = test_less<int>;
- using A = test_allocator<int>;
- using M = std::flat_set<int, C, std::vector<int, A>>;
- std::vector<int, A> ks = {1, 2, 4, 10};
- auto m = M(std::sorted_unique, ks, C(4), A(5));
+ using C = test_less<int>;
+ using A = test_allocator<int>;
+ using M = std::flat_set<int, C, KeyContainer<int, A>>;
+ KeyContainer<int, A> ks = {1, 2, 4, 10};
+ auto m = M(std::sorted_unique, ks, C(4), A(5));
assert((m == M{1, 2, 4, 10}));
assert(m.key_comp() == C(4));
assert(M(m).extract().get_allocator() == A(5));
@@ -126,8 +106,8 @@ void test() {
{
// flat_set(sorted_unique_t, container_type , const Allocator&)
using A = test_allocator<int>;
- using M = std::flat_set<int, std::less<int>, std::deque<int, A>>;
- auto ks = std::deque<int, A>({1, 2, 4, 10}, A(4));
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int, A>>;
+ auto ks = KeyContainer<int, A>({1, 2, 4, 10}, A(4));
auto m = M(std::sorted_unique, ks, A(6)); // replaces the allocators
assert(!ks.empty()); // it was an lvalue above
assert((m == M{1, 2, 4, 10}));
@@ -140,8 +120,43 @@ void test() {
}
}
+constexpr bool test() {
+ {
+ // The constructors in this subclause shall not participate in overload
+ // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+ using C = test_less<int>;
+ using A1 = test_allocator<int>;
+ using A2 = other_allocator<int>;
+ using V1 = std::vector<int, A1>;
+ using V2 = std::vector<int, A2>;
+ using M1 = std::flat_set<int, C, V1>;
+ using M2 = std::flat_set<int, C, V2>;
+ static_assert(std::is_constructible_v<M1, std::sorted_unique_t, const V1&, const A1&>);
+ static_assert(std::is_constructible_v<M2, std::sorted_unique_t, const V2&, const A2&>);
+ static_assert(!std::is_constructible_v<M1, std::sorted_unique_t, const V1&, const A2&>);
+ static_assert(!std::is_constructible_v<M2, std::sorted_unique_t, const V2&, const A1&>);
+
+ static_assert(std::is_constructible_v<M1, std::sorted_unique_t, const V1&, const C&, const A1&>);
+ static_assert(std::is_constructible_v<M2, std::sorted_unique_t, const V2&, const C&, const A2&>);
+ static_assert(!std::is_constructible_v<M1, std::sorted_unique_t, const V1&, const C&, const A2&>);
+ static_assert(!std::is_constructible_v<M2, std::sorted_unique_t, const V2&, const C&, const A1&>);
+ }
+
+ test<std::vector>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test<std::deque>();
+
+ return true;
+}
+
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_initializer_list.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_initializer_list.pass.cpp
index a8dac35aefee8..993a01208fb76 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_initializer_list.pass.cpp
@@ -31,60 +31,16 @@
#include "../../../test_compare.h"
template <class T>
-std::initializer_list<T> il = {1, 2, 4, 5};
+constexpr std::initializer_list<T> il = {1, 2, 4, 5};
-void test() {
+template <template <class...> class KeyContainer>
+constexpr void test() {
const auto il1 = il<int>;
const auto il2 = il<short>;
- {
- // The constructors in this subclause shall not participate in overload
- // resolution unless uses_allocator_v<container_type, Alloc> is true.
-
- using C = test_less<int>;
- using A1 = test_allocator<int>;
- using A2 = other_allocator<int>;
- using V1 = std::vector<int, A1>;
- using V2 = std::vector<int, A2>;
- using M1 = std::flat_set<int, C, V1>;
- using M2 = std::flat_set<int, C, V2>;
- using IL = std::initializer_list<int>;
-
- static_assert(std::is_constructible_v<M1, std::sorted_unique_t, IL, const A1&>);
- static_assert(std::is_constructible_v<M2, std::sorted_unique_t, IL, const A2&>);
- static_assert(!std::is_constructible_v<M1, std::sorted_unique_t, IL, const A2&>);
- static_assert(!std::is_constructible_v<M2, std::sorted_unique_t, IL, const A1&>);
-
- static_assert(std::is_constructible_v<M1, std::sorted_unique_t, IL, const C&, const A1&>);
- static_assert(std::is_constructible_v<M2, std::sorted_unique_t, IL, const C&, const A2&>);
- static_assert(!std::is_constructible_v<M1, std::sorted_unique_t, IL, const C&, const A2&>);
- static_assert(!std::is_constructible_v<M2, std::sorted_unique_t, IL, const C&, const A1&>);
- }
- {
- // initializer_list<value_type> needs to match exactly
- using M = std::flat_set<int>;
- using C = typename M::key_compare;
- static_assert(std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<int>>);
- static_assert(std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<int>, C>);
- static_assert(std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<int>, C, std::allocator<int>>);
- static_assert(std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<int>, std::allocator<int>>);
- static_assert(!std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<const int>>);
- static_assert(!std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<const int>, C>);
- static_assert(
- !std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<const int>, C, std::allocator<int>>);
- static_assert(
- !std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<const int>, std::allocator<int>>);
- static_assert(!std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<const int>>);
- static_assert(!std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<const int>, C>);
- static_assert(
- !std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<const int>, C, std::allocator<int>>);
- static_assert(
- !std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<const int>, std::allocator<int>>);
- }
-
{
// flat_set(sorted_unique_t, initializer_list<value_type>);
- using M = std::flat_set<int>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int>>;
auto m = M(std::sorted_unique, il1);
auto expected = M{1, 2, 4, 5};
assert(m == expected);
@@ -93,9 +49,9 @@ void test() {
M m2 = {std::sorted_unique, il1};
assert(m2 == m);
}
- {
+ if (!std::is_constant_evaluated()) {
// flat_set(sorted_unique_t, initializer_list<value_type>, const key_compare&);
- using M = std::flat_set<int, std::function<bool(int, int)>>;
+ using M = std::flat_set<int, std::function<bool(int, int)>, KeyContainer<int>>;
auto m = M(std::sorted_unique, il1, std::less<int>());
assert(m == M({1, 2, 4, 5}, std::less<>()));
assert(m.key_comp()(1, 2) == true);
@@ -107,7 +63,7 @@ void test() {
{
// flat_set(sorted_unique_t, initializer_list<value_type>, const key_compare&);
// greater
- using M = std::flat_set<int, std::greater<int>, std::deque<int, min_allocator<int>>>;
+ using M = std::flat_set<int, std::greater<int>, KeyContainer<int, min_allocator<int>>>;
std::initializer_list<int> il4{5, 4, 2, 1};
auto m = M(std::sorted_unique, il4, std::greater<int>());
assert((m == M{5, 4, 2, 1}));
@@ -115,7 +71,7 @@ void test() {
{
// flat_set(sorted_unique_t, initializer_list<value_type>, const Allocator&)
using A1 = test_allocator<short>;
- using M = std::flat_set<short, std::less<int>, std::deque<short, A1>>;
+ using M = std::flat_set<short, std::less<int>, KeyContainer<short, A1>>;
auto m = M(std::sorted_unique, il2, A1(5));
auto expected = M{1, 2, 4, 5};
assert(m == expected);
@@ -130,7 +86,7 @@ void test() {
// flat_set(sorted_unique_t, initializer_list<value_type>, const key_compare&, const Allocator&);
using C = test_less<int>;
using A1 = test_allocator<short>;
- using M = std::flat_set<short, C, std::vector<short, A1>>;
+ using M = std::flat_set<short, C, KeyContainer<short, A1>>;
auto m = M(std::sorted_unique, il2, C(3), A1(5));
assert((m == M{1, 2, 4, 5}));
assert(m.key_comp() == C(3));
@@ -140,15 +96,73 @@ void test() {
// flat_set(sorted_unique_t, initializer_list<value_type>, const key_compare&, const Allocator&);
// explicit(false)
using A1 = test_allocator<short>;
- using M = std::flat_set<short, std::less<int>, std::deque<short, A1>>;
+ using M = std::flat_set<short, std::less<int>, KeyContainer<short, A1>>;
M m = {std::sorted_unique, il2, {}, A1(5)}; // implicit ctor
assert((m == M{1, 2, 4, 5}));
assert(std::move(m).extract().get_allocator() == A1(5));
}
}
+constexpr bool test() {
+ {
+ // The constructors in this subclause shall not participate in overload
+ // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+ using C = test_less<int>;
+ using A1 = test_allocator<int>;
+ using A2 = other_allocator<int>;
+ using V1 = std::vector<int, A1>;
+ using V2 = std::vector<int, A2>;
+ using M1 = std::flat_set<int, C, V1>;
+ using M2 = std::flat_set<int, C, V2>;
+ using IL = std::initializer_list<int>;
+
+ static_assert(std::is_constructible_v<M1, std::sorted_unique_t, IL, const A1&>);
+ static_assert(std::is_constructible_v<M2, std::sorted_unique_t, IL, const A2&>);
+ static_assert(!std::is_constructible_v<M1, std::sorted_unique_t, IL, const A2&>);
+ static_assert(!std::is_constructible_v<M2, std::sorted_unique_t, IL, const A1&>);
+
+ static_assert(std::is_constructible_v<M1, std::sorted_unique_t, IL, const C&, const A1&>);
+ static_assert(std::is_constructible_v<M2, std::sorted_unique_t, IL, const C&, const A2&>);
+ static_assert(!std::is_constructible_v<M1, std::sorted_unique_t, IL, const C&, const A2&>);
+ static_assert(!std::is_constructible_v<M2, std::sorted_unique_t, IL, const C&, const A1&>);
+ }
+ {
+ // initializer_list<value_type> needs to match exactly
+ using M = std::flat_set<int>;
+ using C = typename M::key_compare;
+ static_assert(std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<int>>);
+ static_assert(std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<int>, C>);
+ static_assert(std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<int>, C, std::allocator<int>>);
+ static_assert(std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<int>, std::allocator<int>>);
+ static_assert(!std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<const int>>);
+ static_assert(!std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<const int>, C>);
+ static_assert(
+ !std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<const int>, C, std::allocator<int>>);
+ static_assert(
+ !std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<const int>, std::allocator<int>>);
+ static_assert(!std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<const int>>);
+ static_assert(!std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<const int>, C>);
+ static_assert(
+ !std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<const int>, C, std::allocator<int>>);
+ static_assert(
+ !std::is_constructible_v<M, std::sorted_unique_t, std::initializer_list<const int>, std::allocator<int>>);
+ }
+
+ test<std::vector>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test<std::deque>();
+
+ return true;
+}
+
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_iter_iter.pass.cpp
index b184ee9c3f5ab..2ebd3247abf42 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_iter_iter.pass.cpp
@@ -22,40 +22,19 @@
#include <functional>
#include <vector>
+#include "MinSequenceContainer.h"
#include "min_allocator.h"
#include "test_allocator.h"
#include "test_iterators.h"
#include "test_macros.h"
#include "../../../test_compare.h"
-void test() {
- {
- // The constructors in this subclause shall not participate in overload
- // resolution unless uses_allocator_v<container_type, Alloc> is true.
-
- using C = test_less<int>;
- using A1 = test_allocator<int>;
- using A2 = other_allocator<int>;
- using V1 = std::vector<int, A1>;
- using V2 = std::vector<int, A2>;
- using M1 = std::flat_set<int, C, V1>;
- using M2 = std::flat_set<int, C, V2>;
- using Iter1 = typename M1::iterator;
- using Iter2 = typename M2::iterator;
- static_assert(std::is_constructible_v<M1, std::sorted_unique_t, Iter1, Iter1, const A1&>);
- static_assert(std::is_constructible_v<M2, std::sorted_unique_t, Iter2, Iter2, const A2&>);
- static_assert(!std::is_constructible_v<M1, std::sorted_unique_t, Iter1, Iter1, const A2&>);
- static_assert(!std::is_constructible_v<M2, std::sorted_unique_t, Iter2, Iter2, const A1&>);
-
- static_assert(std::is_constructible_v<M1, std::sorted_unique_t, Iter1, Iter1, const C&, const A1&>);
- static_assert(std::is_constructible_v<M2, std::sorted_unique_t, Iter2, Iter2, const C&, const A2&>);
- static_assert(!std::is_constructible_v<M1, std::sorted_unique_t, Iter1, Iter1, const C&, const A2&>);
- static_assert(!std::is_constructible_v<M2, std::sorted_unique_t, Iter2, Iter2, const C&, const A1&>);
- }
+template <class KeyContainer>
+constexpr void test() {
{
// flat_set(sorted_unique_t, InputIterator, InputIterator);
// cpp17_input_iterator
- using M = std::flat_set<int>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer>;
int ar[] = {1, 2, 4, 5};
auto m = M(std::sorted_unique, cpp17_input_iterator<const int*>(ar), cpp17_input_iterator<const int*>(ar + 4));
auto expected = M{1, 2, 4, 5};
@@ -69,16 +48,16 @@ void test() {
// flat_set(sorted_unique_t, InputIterator, InputIterator);
// contiguous iterator
using C = test_less<int>;
- using M = std::flat_set<int, C, std::vector<int, min_allocator<int>>>;
+ using M = std::flat_set<int, C, KeyContainer>;
int ar[] = {1, 2, 4, 5};
auto m = M(std::sorted_unique, ar, ar + 4);
auto expected = M{1, 2, 4, 5};
assert(m == expected);
}
- {
+ if (!std::is_constant_evaluated()) {
// flat_set(sorted_unique_t, InputIterator, InputIterator, const key_compare&);
// cpp_17_input_iterator
- using M = std::flat_set<int, std::function<bool(int, int)>>;
+ using M = std::flat_set<int, std::function<bool(int, int)>, KeyContainer>;
int ar[] = {1, 2, 4, 5};
auto m = M(std::sorted_unique,
cpp17_input_iterator<const int*>(ar),
@@ -97,7 +76,7 @@ void test() {
{
// flat_set(sorted_unique_t, InputIterator, InputIterator, const key_compare&);
// greater
- using M = std::flat_set<int, std::greater<int>, std::deque<int, min_allocator<int>>>;
+ using M = std::flat_set<int, std::greater<int>, KeyContainer>;
int ar[] = {5, 4, 2, 1};
auto m = M(std::sorted_unique,
cpp17_input_iterator<const int*>(ar),
@@ -109,16 +88,20 @@ void test() {
// flat_set(sorted_unique_t, InputIterator, InputIterator, const key_compare&);
// contiguous iterator
using C = test_less<int>;
- using M = std::flat_set<int, C, std::vector<int, min_allocator<int>>>;
+ using M = std::flat_set<int, C, KeyContainer>;
int ar[1] = {42};
auto m = M(std::sorted_unique, ar, ar, C(5));
assert(m.empty());
assert(m.key_comp() == C(5));
}
+}
+
+template <template <class...> class KeyContainer>
+constexpr void test_alloc() {
{
// flat_set(sorted_unique_t, InputIterator , InputIterator, const Allocator&)
using A1 = test_allocator<int>;
- using M = std::flat_set<int, std::less<int>, std::vector<int, A1>>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer<int, A1>>;
int ar[] = {1, 2, 4, 5};
auto m = M(std::sorted_unique, ar, ar + 4, A1(5));
auto expected = M{1, 2, 4, 5};
@@ -134,7 +117,7 @@ void test() {
// flat_set(sorted_unique_t, InputIterator, InputIterator, const key_compare&, const Allocator&);
using C = test_less<int>;
using A1 = test_allocator<int>;
- using M = std::flat_set<int, C, std::deque<int, A1>>;
+ using M = std::flat_set<int, C, KeyContainer<int, A1>>;
int ar[] = {1, 2, 4, 5};
auto m = M(std::sorted_unique, ar, ar + 4, C(3), A1(5));
assert((m == M{1, 2, 4, 5}));
@@ -145,7 +128,7 @@ void test() {
// flat_set(sorted_unique_t, InputIterator, InputIterator, const key_compare&, const Allocator&);
// explicit(false)
using A1 = test_allocator<short>;
- using M = std::flat_set<short, std::less<int>, std::deque<short, A1>>;
+ using M = std::flat_set<short, std::less<int>, KeyContainer<short, A1>>;
int ar[] = {1, 2, 4, 5};
M m = {std::sorted_unique, ar, ar + 4, {}, A1(5)}; // implicit ctor
assert((m == M{1, 2, 4, 5}));
@@ -153,8 +136,52 @@ void test() {
}
}
+constexpr bool test() {
+ {
+ // The constructors in this subclause shall not participate in overload
+ // resolution unless uses_allocator_v<container_type, Alloc> is true.
+
+ using C = test_less<int>;
+ using A1 = test_allocator<int>;
+ using A2 = other_allocator<int>;
+ using V1 = std::vector<int, A1>;
+ using V2 = std::vector<int, A2>;
+ using M1 = std::flat_set<int, C, V1>;
+ using M2 = std::flat_set<int, C, V2>;
+ using Iter1 = typename M1::iterator;
+ using Iter2 = typename M2::iterator;
+ static_assert(std::is_constructible_v<M1, std::sorted_unique_t, Iter1, Iter1, const A1&>);
+ static_assert(std::is_constructible_v<M2, std::sorted_unique_t, Iter2, Iter2, const A2&>);
+ static_assert(!std::is_constructible_v<M1, std::sorted_unique_t, Iter1, Iter1, const A2&>);
+ static_assert(!std::is_constructible_v<M2, std::sorted_unique_t, Iter2, Iter2, const A1&>);
+
+ static_assert(std::is_constructible_v<M1, std::sorted_unique_t, Iter1, Iter1, const C&, const A1&>);
+ static_assert(std::is_constructible_v<M2, std::sorted_unique_t, Iter2, Iter2, const C&, const A2&>);
+ static_assert(!std::is_constructible_v<M1, std::sorted_unique_t, Iter1, Iter1, const C&, const A2&>);
+ static_assert(!std::is_constructible_v<M2, std::sorted_unique_t, Iter2, Iter2, const C&, const A1&>);
+ }
+
+ test<std::vector<int>>();
+ test<std::vector<int, min_allocator<int>>>();
+ test<MinSequenceContainer<int>>();
+ test_alloc<std::vector>();
+
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ {
+ test<std::deque<int>>();
+ test_alloc<std::deque>();
+ }
+
+ return true;
+}
+
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if.pass.cpp
index d7d7a98f49d77..fafbf46f13acb 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.erasure/erase_if.pass.cpp
@@ -32,7 +32,7 @@ static_assert(HasStdErase<std::vector<int>>);
static_assert(!HasStdErase<std::flat_set<int>>);
template <class M>
-M make(std::initializer_list<int> vals) {
+constexpr M make(std::initializer_list<int> vals) {
M ret;
for (int v : vals)
ret.emplace(v);
@@ -40,8 +40,8 @@ M make(std::initializer_list<int> vals) {
}
template <class M, class Pred>
-void test0(
- std::initializer_list<int> vals, Pred p, std::initializer_list<int> expected, std::size_t expected_erased_count) {
+constexpr void
+test0(std::initializer_list<int> vals, Pred p, std::initializer_list<int> expected, std::size_t expected_erased_count) {
M s = make<M>(vals);
ASSERT_SAME_TYPE(typename M::size_type, decltype(std::erase_if(s, p)));
assert(expected_erased_count == std::erase_if(s, p));
@@ -50,11 +50,11 @@ void test0(
struct NotBool {
bool b;
- explicit operator bool() const { return b; }
+ constexpr explicit operator bool() const { return b; }
};
template <class S>
-void test_one() {
+constexpr void test_one() {
// Test all the plausible signatures for this predicate.
auto is1 = [](typename S::const_reference v) { return v == 1; };
auto is2 = [](typename S::value_type v) { return v == 2; };
@@ -84,18 +84,28 @@ void test_one() {
test0<S>({1, 2, 3}, nonBoolIs1, {2, 3}, 1);
}
-void test() {
+constexpr bool test() {
test_one<std::flat_set<int>>();
test_one<std::flat_set<int, std::less<int>, std::vector<int, min_allocator<int>>>>();
test_one<std::flat_set<int, std::greater<int>, std::vector<int, test_allocator<int>>>>();
- test_one<std::flat_set<int, std::less<int>, std::deque<int, min_allocator<int>>>>();
- test_one<std::flat_set<int, std::greater<int>, std::deque<int, test_allocator<int>>>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ {
+ test_one<std::flat_set<int, std::less<int>, std::deque<int, min_allocator<int>>>>();
+ test_one<std::flat_set<int, std::greater<int>, std::deque<int, test_allocator<int>>>>();
+ }
test_one<std::flat_set<long>>();
test_one<std::flat_set<double>>();
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.iterators/iterator.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.iterators/iterator.pass.cpp
index 846bcff63d773..4b4abba094459 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.iterators/iterator.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.iterators/iterator.pass.cpp
@@ -30,7 +30,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
@@ -67,9 +67,12 @@ void test_one() {
assert(i == m.begin());
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
@@ -88,10 +91,15 @@ void test() {
assert(!(ii1 != cii));
assert(!(cii != ii1));
}
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.iterators/iterator_comparison.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.iterators/iterator_comparison.pass.cpp
index 3027cdd4076ee..46a781f44a642 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.iterators/iterator_comparison.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.iterators/iterator_comparison.pass.cpp
@@ -24,7 +24,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
using KI = typename KeyContainer::iterator;
@@ -144,15 +144,23 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.iterators/reverse_iterator.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.iterators/reverse_iterator.pass.cpp
index 4c2482cd0f3de..81ca5cd003204 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.iterators/reverse_iterator.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.iterators/reverse_iterator.pass.cpp
@@ -25,19 +25,22 @@
#include <iterator>
+#include "MinSequenceContainer.h"
+#include "min_allocator.h"
#include "test_macros.h"
-void test() {
+template <class KeyContainer>
+constexpr void test_one() {
{
- using M = std::flat_set<int, std::less<int>, std::deque<int>>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer>;
M m = {1, 2, 3, 4};
const M& cm = m;
- ASSERT_SAME_TYPE(decltype(m.rbegin()), M::reverse_iterator);
- ASSERT_SAME_TYPE(decltype(m.crbegin()), M::const_reverse_iterator);
- ASSERT_SAME_TYPE(decltype(cm.rbegin()), M::const_reverse_iterator);
- ASSERT_SAME_TYPE(decltype(m.rend()), M::reverse_iterator);
- ASSERT_SAME_TYPE(decltype(m.crend()), M::const_reverse_iterator);
- ASSERT_SAME_TYPE(decltype(cm.rend()), M::const_reverse_iterator);
+ ASSERT_SAME_TYPE(decltype(m.rbegin()), typename M::reverse_iterator);
+ ASSERT_SAME_TYPE(decltype(m.crbegin()), typename M::const_reverse_iterator);
+ ASSERT_SAME_TYPE(decltype(cm.rbegin()), typename M::const_reverse_iterator);
+ ASSERT_SAME_TYPE(decltype(m.rend()), typename M::reverse_iterator);
+ ASSERT_SAME_TYPE(decltype(m.crend()), typename M::const_reverse_iterator);
+ ASSERT_SAME_TYPE(decltype(cm.rend()), typename M::const_reverse_iterator);
static_assert(noexcept(m.rbegin()));
static_assert(noexcept(cm.rbegin()));
static_assert(noexcept(m.crbegin()));
@@ -49,12 +52,12 @@ void test() {
assert(std::distance(cm.rbegin(), cm.rend()) == 4);
assert(std::distance(m.crbegin(), m.crend()) == 4);
assert(std::distance(cm.crbegin(), cm.crend()) == 4);
- M::reverse_iterator i; // default-construct
+ typename M::reverse_iterator i; // default-construct
ASSERT_SAME_TYPE(decltype(*i), const int&);
- i = m.rbegin(); // move-assignment
- M::const_reverse_iterator k = i; // converting constructor
- assert(i == k); // comparison
- for (int j = 4; j >= 1; --j, ++i) { // pre-increment
+ i = m.rbegin(); // move-assignment
+ typename M::const_reverse_iterator k = i; // converting constructor
+ assert(i == k); // comparison
+ for (int j = 4; j >= 1; --j, ++i) { // pre-increment
assert(*i == j);
}
assert(i == m.rend());
@@ -65,11 +68,11 @@ void test() {
assert(i == m.rbegin());
}
{
+ using M = std::flat_set<int, std::less<int>, KeyContainer>;
// N3644 testing
- using C = std::flat_set<int>;
- C::reverse_iterator ii1{}, ii2{};
- C::reverse_iterator ii4 = ii1;
- C::const_reverse_iterator cii{};
+ typename M::reverse_iterator ii1{}, ii2{};
+ typename M::reverse_iterator ii4 = ii1;
+ typename M::const_reverse_iterator cii{};
assert(ii1 == ii2);
assert(ii1 == ii4);
assert(!(ii1 != ii2));
@@ -81,8 +84,23 @@ void test() {
}
}
+constexpr bool test() {
+ test_one<std::vector<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
+ test_one<MinSequenceContainer<int>>();
+ test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
+}
+
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/clear.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/clear.pass.cpp
index 5ecdc429b3c58..e3e5068fa06f8 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/clear.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/clear.pass.cpp
@@ -38,7 +38,7 @@ static_assert(NoExceptClear<std::flat_set<int, std::less<int>, ThrowOnMoveContai
#endif
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
{
@@ -58,17 +58,24 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/emplace.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/emplace.pass.cpp
index 79800e894afbf..1e615f94fee16 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/emplace.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/emplace.pass.cpp
@@ -28,7 +28,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
using R = std::pair<typename M::iterator, bool>;
@@ -98,7 +98,7 @@ void test_one() {
}
template <class KeyContainer>
-void test_emplaceable() {
+constexpr void test_emplaceable() {
using M = std::flat_set<Emplaceable, std::less<Emplaceable>, KeyContainer>;
using R = std::pair<typename M::iterator, bool>;
@@ -121,16 +121,24 @@ void test_emplaceable() {
assert(*m.begin() == Emplaceable(1, 3.5));
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
test_emplaceable<std::vector<Emplaceable>>();
- test_emplaceable<std::deque<Emplaceable>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_emplaceable<std::deque<Emplaceable>>();
test_emplaceable<MinSequenceContainer<Emplaceable>>();
test_emplaceable<std::vector<Emplaceable, min_allocator<Emplaceable>>>();
+
+ return true;
}
void test_exception() {
@@ -141,6 +149,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/emplace_hint.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/emplace_hint.pass.cpp
index b3bd8adf0c35d..27cd740eca64d 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/emplace_hint.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/emplace_hint.pass.cpp
@@ -27,7 +27,7 @@
#include "../helpers.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
using R = M::iterator;
@@ -114,7 +114,7 @@ void test_one() {
}
template <class KeyContainer>
-void test_emplaceable() {
+constexpr void test_emplaceable() {
using M = std::flat_set<Emplaceable, std::less<Emplaceable>, KeyContainer>;
using R = M::iterator;
@@ -134,16 +134,24 @@ void test_emplaceable() {
assert(*m.begin() == Emplaceable(1, 3.5));
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
test_emplaceable<std::vector<Emplaceable>>();
- test_emplaceable<std::vector<Emplaceable>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_emplaceable<std::deque<Emplaceable>>();
test_emplaceable<MinSequenceContainer<Emplaceable>>();
test_emplaceable<std::vector<Emplaceable, min_allocator<Emplaceable>>>();
+
+ return true;
}
void test_exception() {
@@ -154,6 +162,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/erase_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/erase_iter.pass.cpp
index 27c6fadb5341e..1ec4dc89f6516 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/erase_iter.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/erase_iter.pass.cpp
@@ -27,7 +27,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
using I = M::iterator;
@@ -94,11 +94,16 @@ void test_one() {
assert(i8 == m.end());
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
void test_exception() {
@@ -109,6 +114,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/erase_iter_iter.pass.cpp
index f44a8864bdbc8..ce5c214706c6b 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/erase_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/erase_iter_iter.pass.cpp
@@ -26,7 +26,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
using I = M::iterator;
@@ -78,11 +78,16 @@ void test_one() {
assert(i5 == m.end());
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
void test_exception() {
@@ -93,6 +98,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/erase_key.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/erase_key.pass.cpp
index c50b219895b17..c2e857e566ff7 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/erase_key.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/erase_key.pass.cpp
@@ -26,7 +26,7 @@
#include "min_allocator.h"
template <class KeyContainer, class Compare = std::less<>>
-void test_one() {
+constexpr void test_one() {
using M = std::flat_set<int, Compare, KeyContainer>;
auto make = [](std::initializer_list<int> il) {
@@ -74,12 +74,17 @@ void test_one() {
assert(m.empty());
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
test_one<std::vector<int>, std::greater<>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
void test_exception() {
@@ -95,6 +100,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/erase_key_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/erase_key_transparent.pass.cpp
index 9dd91628d1c29..e757669d79c1a 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/erase_key_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/erase_key_transparent.pass.cpp
@@ -38,10 +38,10 @@ static_assert(!CanErase<const NonTransparentSet>);
template <class Key, class It>
struct HeterogeneousKey {
- explicit HeterogeneousKey(Key key, It it) : key_(key), it_(it) {}
- operator It() && { return it_; }
- auto operator<=>(Key key) const { return key_ <=> key; }
- friend bool operator<(const HeterogeneousKey&, const HeterogeneousKey&) {
+ constexpr explicit HeterogeneousKey(Key key, It it) : key_(key), it_(it) {}
+ constexpr operator It() && { return it_; }
+ constexpr auto operator<=>(Key key) const { return key_ <=> key; }
+ constexpr friend bool operator<(const HeterogeneousKey&, const HeterogeneousKey&) {
assert(false);
return false;
}
@@ -50,7 +50,7 @@ struct HeterogeneousKey {
};
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
@@ -70,7 +70,7 @@ void test_one() {
}
template <class KeyContainer>
-void test_transparent_comparator() {
+constexpr void test_transparent_comparator() {
using M = std::flat_set<std::string, TransparentComparator, KeyContainer>;
{
M m = {"alpha", "beta", "epsilon", "eta", "gamma"};
@@ -95,14 +95,20 @@ void test_transparent_comparator() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
test_transparent_comparator<std::vector<std::string>>();
- test_transparent_comparator<std::deque<std::string>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_transparent_comparator<std::deque<std::string>>();
test_transparent_comparator<MinSequenceContainer<std::string>>();
test_transparent_comparator<std::vector<std::string, min_allocator<std::string>>>();
@@ -138,6 +144,8 @@ void test() {
assert(n == 1);
assert(transparent_used);
}
+
+ return true;
}
void test_exception() {
@@ -152,6 +160,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/extract.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/extract.pass.cpp
index 12e63e0d23e1d..23a3e93c7958b 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/extract.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/extract.pass.cpp
@@ -33,7 +33,7 @@ static_assert(!CanExtract<std::flat_set<int> const&>);
static_assert(!CanExtract<std::flat_set<int> const&&>);
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using M = std::flat_set<int, std::less<int>, KeyContainer>;
{
M m = M({1, 2, 3});
@@ -55,9 +55,12 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
@@ -70,6 +73,8 @@ void test() {
check_invariant(m);
LIBCPP_ASSERT(m.empty());
}
+
+ return true;
}
void test_exception() {
@@ -97,6 +102,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_cv.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_cv.pass.cpp
index e0cb80f74462c..227969700f051 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_cv.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_cv.pass.cpp
@@ -23,7 +23,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
using R = std::pair<typename M::iterator, bool>;
@@ -59,11 +59,16 @@ void test_one() {
assert(*r.first == 3);
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
void test_exception() {
@@ -78,6 +83,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_initializer_list.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_initializer_list.pass.cpp
index 992c96ecba1a2..9a717a1c39f9f 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_initializer_list.pass.cpp
@@ -23,7 +23,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
using V = typename M::value_type;
@@ -67,11 +67,16 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
void test_exception() {
@@ -87,6 +92,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_iter_cv.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_iter_cv.pass.cpp
index 76b4d5f0eb7cc..914640fd8e0fd 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_iter_cv.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_iter_cv.pass.cpp
@@ -23,7 +23,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
using R = typename M::iterator;
@@ -55,11 +55,16 @@ void test_one() {
assert(*r == 3);
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
void test_exception() {
@@ -75,6 +80,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_iter_iter.pass.cpp
index 8063686c960ed..a2f4fb58246bd 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_iter_iter.pass.cpp
@@ -36,7 +36,7 @@ static_assert(!CanInsert<Set, int, int>);
static_assert(!CanInsert<Set, cpp20_input_iterator<int*>, cpp20_input_iterator<int*>>);
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using M = std::flat_set<int, std::less<int>, KeyContainer>;
int ar1[] = {
@@ -74,11 +74,16 @@ void test_one() {
assert(m == expected2);
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
void test_exception() {
@@ -89,6 +94,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_iter_rv.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_iter_rv.pass.cpp
index d29de98e4d3dd..191f06f64239b 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_iter_rv.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_iter_rv.pass.cpp
@@ -22,7 +22,7 @@
#include "test_macros.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
using V = Key;
@@ -49,15 +49,22 @@ void test_one() {
assert(*r == V(3));
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
test_one<std::vector<MoveOnly>>();
- test_one<std::deque<int>>();
- test_one<std::deque<MoveOnly>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ {
+ test_one<std::deque<int>>();
+ test_one<std::deque<MoveOnly>>();
+ }
test_one<MinSequenceContainer<int>>();
test_one<MinSequenceContainer<MoveOnly>>();
test_one<std::vector<int, min_allocator<int>>>();
test_one<std::vector<MoveOnly, min_allocator<MoveOnly>>>();
+
+ return true;
}
void test_exception() {
@@ -73,6 +80,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_range.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_range.pass.cpp
index 966a696c096b9..90e7ce9f53c99 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_range.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_range.pass.cpp
@@ -39,7 +39,7 @@ static_assert(!CanInsertRange<Set, std::ranges::subrange<std::pair<int, int>*>>)
static_assert(!CanInsertRange<Set, std::ranges::subrange<std::pair<short, short>*>>);
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
{
@@ -65,7 +65,7 @@ void test_one() {
{
// The "uniquing" part uses the comparator, not operator==.
struct ModTen {
- bool operator()(int a, int b) const { return (a % 10) < (b % 10); }
+ constexpr bool operator()(int a, int b) const { return (a % 10) < (b % 10); }
};
using M = std::flat_set<Key, ModTen, KeyContainer>;
M m = {21, 43, 15, 37};
@@ -83,9 +83,12 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
{
@@ -96,6 +99,8 @@ void test() {
MoveOnly expected[] = {1, 3, 4, 5};
assert(std::ranges::equal(m, expected));
}
+
+ return true;
}
void test_exception() {
@@ -106,6 +111,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_rv.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_rv.pass.cpp
index a179632d64211..f0180f6899361 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_rv.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_rv.pass.cpp
@@ -25,7 +25,7 @@
#include "../helpers.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, TransparentComparator, KeyContainer>;
using R = std::pair<typename M::iterator, bool>;
@@ -57,15 +57,22 @@ void test_one() {
assert(*r.first == V(3));
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
test_one<std::vector<MoveOnly>>();
- test_one<std::deque<int>>();
- test_one<std::deque<MoveOnly>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ {
+ test_one<std::deque<int>>();
+ test_one<std::deque<MoveOnly>>();
+ }
test_one<MinSequenceContainer<int>>();
test_one<MinSequenceContainer<MoveOnly>>();
test_one<std::vector<int, min_allocator<int>>>();
test_one<std::vector<MoveOnly, min_allocator<MoveOnly>>>();
+
+ return true;
}
void test_exception() {
@@ -81,6 +88,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_sorted_initializer_list.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_sorted_initializer_list.pass.cpp
index fb0a8b049e72a..479340cd4e5e1 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_sorted_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_sorted_initializer_list.pass.cpp
@@ -23,7 +23,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
using V = Key;
@@ -47,11 +47,16 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
void test_exception() {
@@ -67,6 +72,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_sorted_iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_sorted_iter_iter.pass.cpp
index 6258c4dbfdcbb..5abeacebff6e7 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_sorted_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_sorted_iter_iter.pass.cpp
@@ -36,7 +36,7 @@ static_assert(!CanInsert<Set, std::sorted_unique_t, int, int>);
static_assert(!CanInsert<Set, std::sorted_unique_t, cpp20_input_iterator<int*>, cpp20_input_iterator<int*>>);
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
@@ -60,11 +60,16 @@ void test_one() {
assert(m == expected2);
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
void test_exception() {
@@ -77,6 +82,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_transparent.pass.cpp
index f60fd78008a30..66802053629ee 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_transparent.pass.cpp
@@ -46,7 +46,7 @@ static_assert(!CanInsert<NonTransparentSet, NonConvertibleTransparent<int>>);
static_assert(!CanInsert<NonTransparentSet, NonTransparentSetIter, NonConvertibleTransparent<int>>);
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, TransparentComparator, KeyContainer>;
@@ -105,9 +105,12 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
@@ -123,6 +126,8 @@ void test() {
ASSERT_SAME_TYPE(decltype(m.insert(m.begin(), Evil())), M::iterator);
ASSERT_SAME_TYPE(decltype(m.insert(m.begin(), m.end())), void);
}
+
+ return true;
}
void test_exception() {
@@ -145,6 +150,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/replace.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/replace.pass.cpp
index 591def4c0f938..dd783692e3d60 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/replace.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/replace.pass.cpp
@@ -31,7 +31,7 @@ static_assert(CanReplace<Set, std::vector<int>>);
static_assert(!CanReplace<Set, const std::vector<int>&>);
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
{
@@ -51,11 +51,16 @@ void test_one() {
assert(std::ranges::equal(m, expected_keys));
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
void test_exception() {
@@ -81,6 +86,9 @@ void test_exception() {
int main(int, char**) {
test();
test_exception();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/swap_free.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/swap_free.pass.cpp
index 686fe93a593f5..f86fa0cffed6a 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/swap_free.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/swap_free.pass.cpp
@@ -38,7 +38,7 @@ static_assert(NoExceptAdlSwap<std::flat_set<int, std::less<int>, ThrowOnMoveCont
#endif
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
@@ -84,15 +84,22 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
- test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/swap_member.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/swap_member.pass.cpp
index 1eac55d768ce0..7ce42ed4d935a 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/swap_member.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/swap_member.pass.cpp
@@ -37,7 +37,7 @@ static_assert(NoExceptMemberSwap<std::flat_set<int, std::less<int>, ThrowOnMoveC
#endif
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<Key>, KeyContainer>;
{
@@ -82,15 +82,23 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.observers/comp.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.observers/comp.pass.cpp
index ba2c428c9e30e..232c7c2bc9e93 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.observers/comp.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.observers/comp.pass.cpp
@@ -21,7 +21,7 @@
#include "test_macros.h"
-void test() {
+constexpr bool test() {
{
using M = std::flat_set<int>;
using Comp = std::less<int>; // the default
@@ -36,7 +36,7 @@ void test() {
assert(vc(1, 2));
assert(!vc(2, 1));
}
- {
+ if (!std::is_constant_evaluated()) {
using Comp = std::function<bool(int, int)>;
using M = std::flat_set<int, Comp>;
Comp comp = std::greater<int>();
@@ -67,10 +67,15 @@ void test() {
assert(vc(1, 2));
assert(!vc(2, 1));
}
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/contains.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/contains.pass.cpp
index e0416fc261ffc..b039a3bbca4ff 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/contains.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/contains.pass.cpp
@@ -23,7 +23,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
{
using M = std::flat_set<Key, std::less<>, KeyContainer>;
@@ -66,15 +66,23 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/contains_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/contains_transparent.pass.cpp
index cae8eea89471b..85cadabe43809 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/contains_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/contains_transparent.pass.cpp
@@ -34,7 +34,7 @@ static_assert(!CanContains<NonTransparentSet>);
static_assert(!CanContains<const NonTransparentSet>);
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, TransparentComparator, KeyContainer>;
@@ -59,9 +59,12 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<std::string>>();
- test_one<std::deque<std::string>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<std::string>>();
test_one<MinSequenceContainer<std::string>>();
test_one<std::vector<std::string, min_allocator<std::string>>>();
@@ -74,10 +77,15 @@ void test() {
assert(b);
assert(transparent_used);
}
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/count.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/count.pass.cpp
index 51aec21ca212b..3c1fa261a3b2a 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/count.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/count.pass.cpp
@@ -23,7 +23,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using S = typename KeyContainer::size_type;
@@ -66,15 +66,23 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/count_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/count_transparent.pass.cpp
index b24b6fa712fa9..2cbfce7d829cb 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/count_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/count_transparent.pass.cpp
@@ -34,7 +34,7 @@ static_assert(!CanCount<NonTransparentSet>);
static_assert(!CanCount<const NonTransparentSet>);
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, TransparentComparator, KeyContainer>;
{
@@ -58,9 +58,12 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<std::string>>();
- test_one<std::deque<std::string>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<std::string>>();
test_one<MinSequenceContainer<std::string>>();
test_one<std::vector<std::string, min_allocator<std::string>>>();
@@ -73,10 +76,15 @@ void test() {
assert(n == 1);
assert(transparent_used);
}
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/equal_range.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/equal_range.pass.cpp
index 7a8b19273289d..3ce9a49d24eb0 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/equal_range.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/equal_range.pass.cpp
@@ -24,7 +24,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
{
using M = std::flat_set<Key, std::less<>, KeyContainer>;
@@ -74,15 +74,23 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/equal_range_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/equal_range_transparent.pass.cpp
index 8a270ffa15915..e93c279e179f0 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/equal_range_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/equal_range_transparent.pass.cpp
@@ -35,7 +35,7 @@ static_assert(!CanEqualRange<NonTransparentSet>);
static_assert(!CanEqualRange<const NonTransparentSet>);
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, TransparentComparator, KeyContainer>;
@@ -86,9 +86,12 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<std::string>>();
- test_one<std::deque<std::string>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<std::string>>();
test_one<MinSequenceContainer<std::string>>();
test_one<std::vector<std::string, min_allocator<std::string>>>();
@@ -101,10 +104,15 @@ void test() {
assert(p.first != p.second);
assert(transparent_used);
}
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/find.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/find.pass.cpp
index 953b8fe638547..4786a59ce6124 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/find.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/find.pass.cpp
@@ -25,7 +25,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, std::less<>, KeyContainer>;
{
@@ -50,15 +50,23 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/find_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/find_transparent.pass.cpp
index 6ba91bd5ebe43..e5f1ce056d8e9 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/find_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/find_transparent.pass.cpp
@@ -35,7 +35,7 @@ static_assert(!CanFind<NonTransparentSet>);
static_assert(!CanFind<const NonTransparentSet>);
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, TransparentComparator, KeyContainer>;
@@ -76,8 +76,11 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<std::string>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
test_one<std::deque<std::string>>();
test_one<MinSequenceContainer<std::string>>();
test_one<std::vector<std::string, min_allocator<std::string>>>();
@@ -91,10 +94,15 @@ void test() {
assert(it != m.end());
assert(transparent_used);
}
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/lower_bound.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/lower_bound.pass.cpp
index 32796b7a164f7..2a28769746bb4 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/lower_bound.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/lower_bound.pass.cpp
@@ -24,7 +24,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
{
using M = std::flat_set<Key, std::less<>, KeyContainer>;
@@ -66,15 +66,23 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/lower_bound_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/lower_bound_transparent.pass.cpp
index 8fcfe4d9d432b..a0dde834307b9 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/lower_bound_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/lower_bound_transparent.pass.cpp
@@ -35,7 +35,7 @@ static_assert(!CanLowerBound<NonTransparentSet>);
static_assert(!CanLowerBound<const NonTransparentSet>);
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, TransparentComparator, KeyContainer>;
@@ -82,9 +82,12 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<std::string>>();
- test_one<std::deque<std::string>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<std::string>>();
test_one<MinSequenceContainer<std::string>>();
test_one<std::vector<std::string, min_allocator<std::string>>>();
@@ -97,10 +100,15 @@ void test() {
assert(it != m.end());
assert(transparent_used);
}
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/upper_bound.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/upper_bound.pass.cpp
index 6a967cb2371ba..487e11da214f3 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/upper_bound.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/upper_bound.pass.cpp
@@ -24,7 +24,7 @@
#include "min_allocator.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
{
using M = std::flat_set<Key, std::less<>, KeyContainer>;
@@ -67,15 +67,23 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/upper_bound_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/upper_bound_transparent.pass.cpp
index db89614dd815b..232df7ade2967 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/upper_bound_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/upper_bound_transparent.pass.cpp
@@ -35,7 +35,7 @@ static_assert(!CanUpperBound<NonTransparentSet>);
static_assert(!CanUpperBound<const NonTransparentSet>);
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
using M = std::flat_set<Key, TransparentComparator, KeyContainer>;
@@ -82,9 +82,12 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<std::string>>();
- test_one<std::deque<std::string>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<std::string>>();
test_one<MinSequenceContainer<std::string>>();
test_one<std::vector<std::string, min_allocator<std::string>>>();
@@ -97,10 +100,15 @@ void test() {
assert(it != m.end());
assert(transparent_used);
}
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/helpers.h b/libcxx/test/std/containers/container.adaptors/flat.set/helpers.h
index 4cc720311cf01..3f0dc403e4bc1 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/helpers.h
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/helpers.h
@@ -20,7 +20,7 @@
#include "test_macros.h"
template <class... Args>
-void check_invariant(const std::flat_set<Args...>& m) {
+constexpr void check_invariant(const std::flat_set<Args...>& m) {
assert(std::is_sorted(m.begin(), m.end(), m.key_comp()));
auto key_equal = [&](const auto& x, const auto& y) {
const auto& c = m.key_comp();
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/incomplete_type.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/incomplete_type.pass.cpp
index faf746861df30..8c47a63631efa 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/incomplete_type.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/incomplete_type.pass.cpp
@@ -15,6 +15,7 @@
#include <flat_set>
#include <vector>
+#include "test_macros.h"
struct A {
using Set = std::flat_set<A>;
@@ -25,12 +26,18 @@ struct A {
};
// Implement the operator< required in order to instantiate flat_set<A>
-bool operator<(A const& L, A const& R) { return L.data < R.data; }
+constexpr bool operator<(A const& L, A const& R) { return L.data < R.data; }
-void test() { A a; }
+constexpr bool test() {
+ A a;
+ return true;
+}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/op_compare.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/op_compare.pass.cpp
index 3e7aecee77fdd..0526873009428 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/op_compare.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/op_compare.pass.cpp
@@ -31,7 +31,7 @@
#include "test_container_comparisons.h"
template <class KeyContainer>
-void test_one() {
+constexpr void test_one() {
using Key = typename KeyContainer::value_type;
{
@@ -69,9 +69,12 @@ void test_one() {
}
}
-void test() {
+constexpr bool test() {
test_one<std::vector<int>>();
- test_one<std::deque<int>>();
+#ifndef __cpp_lib_constexpr_deque
+ if (!std::is_constant_evaluated())
+#endif
+ test_one<std::deque<int>>();
test_one<MinSequenceContainer<int>>();
test_one<std::vector<int, min_allocator<int>>>();
@@ -86,7 +89,7 @@ void test() {
{
// Comparisons use value_type's native operators, not the comparator
struct StrongComp {
- bool operator()(double a, double b) const { return std::strong_order(a, b) < 0; }
+ constexpr bool operator()(double a, double b) const { return std::strong_order(a, b) < 0; }
};
using C = std::flat_set<double, StrongComp>;
C s1 = {1};
@@ -101,10 +104,15 @@ void test() {
assert(s1 != s2);
assert((s1 <=> s2) == std::partial_ordering::unordered);
}
+
+ return true;
}
int main(int, char**) {
test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat_helpers.h b/libcxx/test/std/containers/container.adaptors/flat_helpers.h
index 9cd408ef960a9..c65d9e97ed0d1 100644
--- a/libcxx/test/std/containers/container.adaptors/flat_helpers.h
+++ b/libcxx/test/std/containers/container.adaptors/flat_helpers.h
@@ -9,6 +9,7 @@
#ifndef TEST_STD_CONTAINERS_CONTAINER_ADAPTORS_FLAT_HELPERS_H
#define TEST_STD_CONTAINERS_CONTAINER_ADAPTORS_FLAT_HELPERS_H
+#include <cstdint>
#include <vector>
#include "test_macros.h"
@@ -17,19 +18,20 @@ template <class T>
struct CopyOnlyVector : std::vector<T> {
using std::vector<T>::vector;
- CopyOnlyVector(const CopyOnlyVector&) = default;
- CopyOnlyVector(CopyOnlyVector&& other) : CopyOnlyVector(other) {}
- CopyOnlyVector(CopyOnlyVector&& other, std::vector<T>::allocator_type alloc) : CopyOnlyVector(other, alloc) {}
+ constexpr CopyOnlyVector(const CopyOnlyVector&) = default;
+ constexpr CopyOnlyVector(CopyOnlyVector&& other) : CopyOnlyVector(other) {}
+ constexpr CopyOnlyVector(CopyOnlyVector&& other, std::vector<T>::allocator_type alloc)
+ : CopyOnlyVector(other, alloc) {}
- CopyOnlyVector& operator=(const CopyOnlyVector&) = default;
- CopyOnlyVector& operator=(CopyOnlyVector& other) { return this->operator=(other); }
+ constexpr CopyOnlyVector& operator=(const CopyOnlyVector&) = default;
+ constexpr CopyOnlyVector& operator=(CopyOnlyVector& other) { return this->operator=(other); }
};
template <class T, bool ConvertibleToT = false>
struct Transparent {
T t;
- explicit operator T() const
+ constexpr explicit operator T() const
requires ConvertibleToT
{
return t;
@@ -50,10 +52,10 @@ struct TransparentComparator {
bool* transparent_used = nullptr;
TransparentComparator() = default;
- TransparentComparator(bool& used) : transparent_used(&used) {}
+ constexpr TransparentComparator(bool& used) : transparent_used(&used) {}
template <class T, bool Convertible>
- bool operator()(const T& t, const Transparent<T, Convertible>& transparent) const {
+ constexpr bool operator()(const T& t, const Transparent<T, Convertible>& transparent) const {
if (transparent_used != nullptr) {
*transparent_used = true;
}
@@ -61,7 +63,7 @@ struct TransparentComparator {
}
template <class T, bool Convertible>
- bool operator()(const Transparent<T, Convertible>& transparent, const T& t) const {
+ constexpr bool operator()(const Transparent<T, Convertible>& transparent, const T& t) const {
if (transparent_used != nullptr) {
*transparent_used = true;
}
@@ -69,7 +71,7 @@ struct TransparentComparator {
}
template <class T>
- bool operator()(const T& t1, const T& t2) const {
+ constexpr bool operator()(const T& t1, const T& t2) const {
return t1 < t2;
}
};
diff --git a/libcxx/test/std/containers/test_compare.h b/libcxx/test/std/containers/test_compare.h
index 18e0b27dc954d..1448a05e2f284 100644
--- a/libcxx/test/std/containers/test_compare.h
+++ b/libcxx/test/std/containers/test_compare.h
@@ -9,6 +9,7 @@
#ifndef TEST_COMPARE_H
#define TEST_COMPARE_H
+#include "test_macros.h"
template <class T>
struct test_equal_to {
int data_;
@@ -21,10 +22,10 @@ struct test_equal_to {
template <class T>
struct test_less {
int data_;
- explicit test_less() : data_(0) {}
- explicit test_less(int data) : data_(data) {}
- bool operator()(const T& a, const T& b) const { return a < b; }
- friend bool operator==(const test_less& a, const test_less& b) { return a.data_ == b.data_; }
+ TEST_CONSTEXPR_CXX14 explicit test_less() : data_(0) {}
+ TEST_CONSTEXPR_CXX14 explicit test_less(int data) : data_(data) {}
+ TEST_CONSTEXPR_CXX14 bool operator()(const T& a, const T& b) const { return a < b; }
+ TEST_CONSTEXPR_CXX14 friend bool operator==(const test_less& a, const test_less& b) { return a.data_ == b.data_; }
};
#endif // TEST_COMPARE_H
diff --git a/libcxx/test/support/MinSequenceContainer.h b/libcxx/test/support/MinSequenceContainer.h
index 7fee4dd0fbdc1..04e29cc53e947 100644
--- a/libcxx/test/support/MinSequenceContainer.h
+++ b/libcxx/test/support/MinSequenceContainer.h
@@ -13,6 +13,7 @@
#include <vector>
#include "test_iterators.h"
+#include "test_macros.h"
template <class T, class Iterator = random_access_iterator<T*>, class ConstIterator = random_access_iterator<const T*>>
struct MinSequenceContainer {
@@ -24,42 +25,48 @@ struct MinSequenceContainer {
explicit MinSequenceContainer() = default;
template <class It>
- explicit MinSequenceContainer(It first, It last) : data_(first, last) {}
- MinSequenceContainer(std::initializer_list<T> il) : data_(il) {}
- iterator begin() { return iterator(data_.data()); }
- const_iterator begin() const { return const_iterator(data_.data()); }
- const_iterator cbegin() const { return const_iterator(data_.data()); }
- iterator end() { return begin() + size(); }
- const_iterator end() const { return begin() + size(); }
- size_type size() const { return static_cast<size_type>(data_.size()); }
- bool empty() const { return data_.empty(); }
-
- void clear() { data_.clear(); }
+ TEST_CONSTEXPR_CXX23 explicit MinSequenceContainer(It first, It last) : data_(first, last) {}
+ TEST_CONSTEXPR_CXX23 MinSequenceContainer(std::initializer_list<T> il) : data_(il) {}
+ TEST_CONSTEXPR_CXX23 iterator begin() { return iterator(data_.data()); }
+ TEST_CONSTEXPR_CXX23 const_iterator begin() const { return const_iterator(data_.data()); }
+ TEST_CONSTEXPR_CXX23 const_iterator cbegin() const { return const_iterator(data_.data()); }
+ TEST_CONSTEXPR_CXX23 iterator end() { return begin() + size(); }
+ TEST_CONSTEXPR_CXX23 const_iterator end() const { return begin() + size(); }
+ TEST_CONSTEXPR_CXX23 size_type size() const { return static_cast<size_type>(data_.size()); }
+ TEST_CONSTEXPR_CXX23 bool empty() const { return data_.empty(); }
+
+ TEST_CONSTEXPR_CXX23 void clear() { data_.clear(); }
template <class It>
- iterator insert(const_iterator p, It first, It last) {
+ TEST_CONSTEXPR_CXX23 iterator insert(const_iterator p, It first, It last) {
return from_vector_iterator(data_.insert(to_vector_iterator(p), first, last));
}
- iterator insert(const_iterator p, T value) {
+ TEST_CONSTEXPR_CXX23 iterator insert(const_iterator p, T value) {
return from_vector_iterator(data_.insert(to_vector_iterator(p), std::move(value)));
}
- iterator erase(const_iterator first, const_iterator last) {
+ TEST_CONSTEXPR_CXX23 iterator erase(const_iterator first, const_iterator last) {
return from_vector_iterator(data_.erase(to_vector_iterator(first), to_vector_iterator(last)));
}
- iterator erase(const_iterator iter) { return from_vector_iterator(data_.erase(to_vector_iterator(iter))); }
+ TEST_CONSTEXPR_CXX23 iterator erase(const_iterator iter) {
+ return from_vector_iterator(data_.erase(to_vector_iterator(iter)));
+ }
template <class... Args>
- iterator emplace(const_iterator pos, Args&&... args) {
+ TEST_CONSTEXPR_CXX23 iterator emplace(const_iterator pos, Args&&... args) {
return from_vector_iterator(data_.emplace(to_vector_iterator(pos), std::forward<Args>(args)...));
}
private:
- std::vector<T>::const_iterator to_vector_iterator(const_iterator cit) const { return cit - cbegin() + data_.begin(); }
+ TEST_CONSTEXPR_CXX23 std::vector<T>::const_iterator to_vector_iterator(const_iterator cit) const {
+ return cit - cbegin() + data_.begin();
+ }
- iterator from_vector_iterator(std::vector<T>::iterator it) { return it - data_.begin() + begin(); }
+ TEST_CONSTEXPR_CXX23 iterator from_vector_iterator(std::vector<T>::iterator it) {
+ return it - data_.begin() + begin();
+ }
std::vector<T> data_;
};
>From 2dc7935ea1e56d76c23db444034b9da1112ff102 Mon Sep 17 00:00:00 2001
From: Hui Xie <hui.xie1990 at gmail.com>
Date: Sat, 17 May 2025 16:38:23 +0100
Subject: [PATCH 2/3] CI
---
libcxx/include/__flat_set/flat_set.h | 4 ++--
libcxx/test/std/containers/Emplaceable.h | 12 ++++++------
.../flat.set/flat.set.cons/sorted_iter_iter.pass.cpp | 3 ++-
.../flat.set.operations/find_transparent.pass.cpp | 2 +-
4 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/libcxx/include/__flat_set/flat_set.h b/libcxx/include/__flat_set/flat_set.h
index 3c44c796a3c59..45d39ad891563 100644
--- a/libcxx/include/__flat_set/flat_set.h
+++ b/libcxx/include/__flat_set/flat_set.h
@@ -758,8 +758,8 @@ class flat_set {
}
template <class _Key2, class _Compare2, class _KeyContainer2, class _Predicate>
- friend typename flat_set<_Key2, _Compare2, _KeyContainer2>::size_type
- _LIBCPP_CONSTEXPR_SINCE_CXX26 erase_if(flat_set<_Key2, _Compare2, _KeyContainer2>&, _Predicate);
+ friend typename flat_set<_Key2, _Compare2, _KeyContainer2>::size_type _LIBCPP_CONSTEXPR_SINCE_CXX26
+ erase_if(flat_set<_Key2, _Compare2, _KeyContainer2>&, _Predicate);
_KeyContainer __keys_;
_LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_;
diff --git a/libcxx/test/std/containers/Emplaceable.h b/libcxx/test/std/containers/Emplaceable.h
index 48d8eab0a9a09..04dcd3eddf7b7 100644
--- a/libcxx/test/std/containers/Emplaceable.h
+++ b/libcxx/test/std/containers/Emplaceable.h
@@ -22,13 +22,13 @@ class Emplaceable {
double double_;
public:
- TEST_CONSTEXPR Emplaceable() : int_(0), double_(0) {}
- TEST_CONSTEXPR Emplaceable(int i, double d) : int_(i), double_(d) {}
+ TEST_CONSTEXPR_CXX14 Emplaceable() : int_(0), double_(0) {}
+ TEST_CONSTEXPR_CXX14 Emplaceable(int i, double d) : int_(i), double_(d) {}
TEST_CONSTEXPR Emplaceable(Emplaceable&& x) : int_(x.int_), double_(x.double_) {
x.int_ = 0;
x.double_ = 0;
}
- TEST_CONSTEXPR Emplaceable& operator=(Emplaceable&& x) {
+ TEST_CONSTEXPR_CXX14 Emplaceable& operator=(Emplaceable&& x) {
int_ = x.int_;
x.int_ = 0;
double_ = x.double_;
@@ -36,12 +36,12 @@ class Emplaceable {
return *this;
}
- TEST_CONSTEXPR bool operator==(const Emplaceable& x) const { return int_ == x.int_ && double_ == x.double_; }
- TEST_CONSTEXPR bool operator<(const Emplaceable& x) const {
+ TEST_CONSTEXPR_CXX14 bool operator==(const Emplaceable& x) const { return int_ == x.int_ && double_ == x.double_; }
+ TEST_CONSTEXPR_CXX14 bool operator<(const Emplaceable& x) const {
return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);
}
- TEST_CONSTEXPR int get() const { return int_; }
+ TEST_CONSTEXPR_CXX14 int get() const { return int_; }
};
template <>
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_iter_iter.pass.cpp
index 2ebd3247abf42..4e445c448e64a 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.cons/sorted_iter_iter.pass.cpp
@@ -34,7 +34,8 @@ constexpr void test() {
{
// flat_set(sorted_unique_t, InputIterator, InputIterator);
// cpp17_input_iterator
- using M = std::flat_set<int, std::less<int>, KeyContainer>;
+ using M = std::flat_set<int, std::less<int>, KeyContainer>;
+
int ar[] = {1, 2, 4, 5};
auto m = M(std::sorted_unique, cpp17_input_iterator<const int*>(ar), cpp17_input_iterator<const int*>(ar + 4));
auto expected = M{1, 2, 4, 5};
diff --git a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/find_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/find_transparent.pass.cpp
index e5f1ce056d8e9..01ab9517fa0cd 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/find_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.set/flat.set.operations/find_transparent.pass.cpp
@@ -81,7 +81,7 @@ constexpr bool test() {
#ifndef __cpp_lib_constexpr_deque
if (!std::is_constant_evaluated())
#endif
- test_one<std::deque<std::string>>();
+ test_one<std::deque<std::string>>();
test_one<MinSequenceContainer<std::string>>();
test_one<std::vector<std::string, min_allocator<std::string>>>();
>From c045532a52c06ef79f547de722a539964b2d6d4e Mon Sep 17 00:00:00 2001
From: Hui Xie <hui.xie1990 at gmail.com>
Date: Sun, 18 May 2025 13:58:29 +0100
Subject: [PATCH 3/3] ci
---
libcxx/test/std/containers/Emplaceable.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/test/std/containers/Emplaceable.h b/libcxx/test/std/containers/Emplaceable.h
index 04dcd3eddf7b7..26167309e59d5 100644
--- a/libcxx/test/std/containers/Emplaceable.h
+++ b/libcxx/test/std/containers/Emplaceable.h
@@ -24,7 +24,7 @@ class Emplaceable {
public:
TEST_CONSTEXPR_CXX14 Emplaceable() : int_(0), double_(0) {}
TEST_CONSTEXPR_CXX14 Emplaceable(int i, double d) : int_(i), double_(d) {}
- TEST_CONSTEXPR Emplaceable(Emplaceable&& x) : int_(x.int_), double_(x.double_) {
+ TEST_CONSTEXPR_CXX14 Emplaceable(Emplaceable&& x) : int_(x.int_), double_(x.double_) {
x.int_ = 0;
x.double_ = 0;
}
More information about the libcxx-commits
mailing list