Skip to content

Commit 7e1bdf8

Browse files
committed
added test
1 parent cc53c54 commit 7e1bdf8

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10+
11+
// <flat_set>
12+
//
13+
// flat_set should support comparator that return a non-boolean
14+
// value as long as the returned type is implicitly convertible to bool.
15+
16+
#include <flat_set>
17+
#include <vector>
18+
#include <ranges>
19+
20+
#include "boolean_testable.h"
21+
22+
void test() {
23+
using Key = StrictComparable<int>;
24+
std::vector<Key> v;
25+
std::flat_set<Key> m1;
26+
std::flat_set m2(std::from_range, v, StrictBinaryPredicate);
27+
std::flat_set m3(std::sorted_unique, v, StrictBinaryPredicate);
28+
std::flat_set m4(m1.begin(), m1.end(), StrictBinaryPredicate);
29+
m2.insert(m1.begin(), m1.end());
30+
m2.insert(std::sorted_unique, m1.begin(), m1.end());
31+
m2.insert_range(m1);
32+
m3.insert(1);
33+
m2.emplace(1);
34+
m2.emplace_hint(m2.begin(), 1);
35+
for (const auto& k : m2) {
36+
(void)k;
37+
}
38+
(void)m2.find(Key{1});
39+
(void)m2.equal_range(Key{1});
40+
(void)(m2 == m2);
41+
m2.erase(m2.begin());
42+
m2.erase(m2.begin(), m2.end());
43+
std::erase_if(m2, []<class T>(const StrictComparable<T>&) -> BooleanTestable const& { return yes; });
44+
}

0 commit comments

Comments
 (0)