Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libcxx/docs/FeatureTestMacroTable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_algorithms`` ``202306L``
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_flat_map`` ``202502L``
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_flat_set`` ``202502L``
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_forward_list`` ``202502L``
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_list`` ``202502L``
Expand Down
272 changes: 164 additions & 108 deletions libcxx/include/__flat_set/flat_multiset.h

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions libcxx/include/version
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ __cpp_lib_constexpr_charconv 202207L <charconv>
__cpp_lib_constexpr_cmath 202202L <cmath> <cstdlib>
__cpp_lib_constexpr_complex 201711L <complex>
__cpp_lib_constexpr_dynamic_alloc 201907L <memory>
__cpp_lib_constexpr_flat_map 202502L <flat_map>
__cpp_lib_constexpr_flat_set 202502L <flat_set>
__cpp_lib_constexpr_forward_list 202502L <forward_list>
__cpp_lib_constexpr_functional 201907L <functional>
__cpp_lib_constexpr_iterator 201811L <iterator>
Expand Down Expand Up @@ -549,6 +551,8 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_bitset 202306L
# undef __cpp_lib_constexpr_algorithms
# define __cpp_lib_constexpr_algorithms 202306L
# define __cpp_lib_constexpr_flat_map 202502L
# define __cpp_lib_constexpr_flat_set 202502L
# define __cpp_lib_constexpr_forward_list 202502L
# define __cpp_lib_constexpr_list 202502L
# if !defined(_LIBCPP_ABI_VCRUNTIME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "../flat_helpers.h"
#include "test_macros.h"

bool test() {
constexpr bool test() {
using M = std::flat_multiset<TrackCopyMove>;
{
M m;
Expand All @@ -43,6 +43,9 @@ bool test() {

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

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,33 @@
#include <vector>

#include "../flat_helpers.h"
#include "test_iterators.h"
#include "test_macros.h"

void test() {
constexpr bool test() {
NotQuiteSequenceContainer<int> v;
std::flat_multiset s(v);
std::istringstream ints("0 1 1 0");
auto r = std::ranges::subrange(std::istream_iterator<int>(ints), std::istream_iterator<int>()) |
std::views::transform([](int i) { return i * i; });

int ar[] = {0, 1, 1, 0};
using Iter = cpp20_input_iterator<const int*>;
using Sent = sentinel_wrapper<Iter>;
using R = std::ranges::subrange<Iter, Sent>;
auto r = R(Iter(ar), Sent(Iter(ar + 4)));

static_assert(
![](auto& t) { return requires { t.insert_range(t.end(), r); }; }(v),
"This test is to test the case where the underlying container does not provide insert_range");
s.insert_range(r);
assert(std::ranges::equal(s, std::vector<int>{0, 0, 1, 1}));

return true;
}

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

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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_multiset<Key, std::less<int>, KeyContainer>;
M m;
Expand All @@ -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 (!TEST_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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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_multiset<int, std::less<int>, std::vector<int, A1>>;
Expand Down Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=200000000
// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-ops-limit): -fconstexpr-ops-limit=800000000

// <flat_set>

Expand All @@ -23,7 +25,7 @@
#include "min_allocator.h"

template <class KeyContainer>
void test_one() {
constexpr void test_one() {
using M = std::flat_multiset<int, std::less<int>, KeyContainer>;
using S = typename M::size_type;
{
Expand All @@ -46,7 +48,7 @@ void test_one() {
}
{
M m;
S s = 500000;
S s = 5000;
for (std::size_t i = 0u; i < s; ++i) {
m.emplace(i);
m.emplace(i);
Expand All @@ -57,15 +59,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 (!TEST_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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// explicit flat_multiset(const Allocator& a);

#include <cassert>
#include <deque>
#include <flat_set>
#include <functional>
#include <vector>
Expand All @@ -22,7 +23,19 @@
#include "test_allocator.h"
#include "../../../test_compare.h"

void test() {
template <template <class...> class KeyContainer>
constexpr void test() {
{
using A = test_allocator<short>;
using M = std::flat_multiset<int, std::less<int>, KeyContainer<int, test_allocator<int>>>;
M m(A(0, 5));
assert(m.empty());
assert(m.begin() == m.end());
assert(std::move(m).extract().get_allocator().get_id() == 5);
}
}

constexpr bool test() {
{
// The constructors in this subclause shall not participate in overload
// resolution unless uses_allocator_v<container_type, Alloc> is true
Expand All @@ -46,18 +59,21 @@ void test() {
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_multiset<int, std::less<int>, std::vector<int, test_allocator<int>>>;
M m(A(0, 5));
assert(m.empty());
assert(m.begin() == m.end());
assert(std::move(m).extract().get_allocator().get_id() == 5);
}

test<std::vector>();
#ifndef __cpp_lib_constexpr_deque
if (!TEST_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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "test_allocator.h"

template <class KeyContainer>
void test() {
constexpr void test() {
using Key = typename KeyContainer::value_type;
using M = std::flat_multiset<Key, std::less<Key>, KeyContainer>;
{
Expand All @@ -53,16 +53,24 @@ void test() {
}
}

void test() {
constexpr bool test() {
test<std::vector<int>>();
test<std::vector<double>>();
test<std::deque<int>>();
#ifndef __cpp_lib_constexpr_deque
if (!TEST_IS_CONSTANT_EVALUATED)
#endif
test<std::deque<int>>();
test<MinSequenceContainer<int>>();
test<std::vector<int, min_allocator<int>>>();

return true;
}

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

return 0;
}
Loading
Loading