Skip to content

Commit 55f5300

Browse files
committed
ci
1 parent 46b3642 commit 55f5300

File tree

6 files changed

+190
-712
lines changed

6 files changed

+190
-712
lines changed

libcxx/test/std/containers/container.adaptors/flat.map/helpers.h

Lines changed: 1 addition & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <vector>
1616
#include <flat_map>
1717

18+
#include "../flat_helpers.h"
1819
#include "test_allocator.h"
1920
#include "test_macros.h"
2021

@@ -30,150 +31,6 @@ void check_invariant(const std::flat_map<Args...>& m) {
3031
assert(std::adjacent_find(keys.begin(), keys.end(), key_equal) == keys.end());
3132
}
3233

33-
struct StartsWith {
34-
explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch + 1) {}
35-
StartsWith(const StartsWith&) = delete;
36-
void operator=(const StartsWith&) = delete;
37-
struct Less {
38-
using is_transparent = void;
39-
bool operator()(const std::string& a, const std::string& b) const { return a < b; }
40-
bool operator()(const StartsWith& a, const std::string& b) const { return a.upper_ <= b; }
41-
bool operator()(const std::string& a, const StartsWith& b) const { return a < b.lower_; }
42-
bool operator()(const StartsWith&, const StartsWith&) const {
43-
assert(false); // should not be called
44-
return false;
45-
}
46-
};
47-
48-
private:
49-
std::string lower_;
50-
std::string upper_;
51-
};
52-
53-
template <class T>
54-
struct CopyOnlyVector : std::vector<T> {
55-
using std::vector<T>::vector;
56-
57-
CopyOnlyVector(const CopyOnlyVector&) = default;
58-
CopyOnlyVector(CopyOnlyVector&& other) : CopyOnlyVector(other) {}
59-
CopyOnlyVector(CopyOnlyVector&& other, std::vector<T>::allocator_type alloc) : CopyOnlyVector(other, alloc) {}
60-
61-
CopyOnlyVector& operator=(const CopyOnlyVector&) = default;
62-
CopyOnlyVector& operator=(CopyOnlyVector& other) { return this->operator=(other); }
63-
};
64-
65-
template <class T, bool ConvertibleToT = false>
66-
struct Transparent {
67-
T t;
68-
69-
operator T() const
70-
requires ConvertibleToT
71-
{
72-
return t;
73-
}
74-
};
75-
76-
template <class T>
77-
using ConvertibleTransparent = Transparent<T, true>;
78-
79-
template <class T>
80-
using NonConvertibleTransparent = Transparent<T, false>;
81-
82-
struct TransparentComparator {
83-
using is_transparent = void;
84-
85-
bool* transparent_used = nullptr;
86-
TransparentComparator() = default;
87-
TransparentComparator(bool& used) : transparent_used(&used) {}
88-
89-
template <class T, bool Convertible>
90-
bool operator()(const T& t, const Transparent<T, Convertible>& transparent) const {
91-
if (transparent_used != nullptr) {
92-
*transparent_used = true;
93-
}
94-
return t < transparent.t;
95-
}
96-
97-
template <class T, bool Convertible>
98-
bool operator()(const Transparent<T, Convertible>& transparent, const T& t) const {
99-
if (transparent_used != nullptr) {
100-
*transparent_used = true;
101-
}
102-
return transparent.t < t;
103-
}
104-
105-
template <class T>
106-
bool operator()(const T& t1, const T& t2) const {
107-
return t1 < t2;
108-
}
109-
};
110-
111-
struct NonTransparentComparator {
112-
template <class T, bool Convertible>
113-
bool operator()(const T&, const Transparent<T, Convertible>&) const;
114-
115-
template <class T, bool Convertible>
116-
bool operator()(const Transparent<T, Convertible>&, const T&) const;
117-
118-
template <class T>
119-
bool operator()(const T&, const T&) const;
120-
};
121-
122-
struct NoDefaultCtr {
123-
NoDefaultCtr() = delete;
124-
};
125-
126-
#ifndef TEST_HAS_NO_EXCEPTIONS
127-
template <class T>
128-
struct EmplaceUnsafeContainer : std::vector<T> {
129-
using std::vector<T>::vector;
130-
131-
template <class... Args>
132-
auto emplace(Args&&... args) -> decltype(std::declval<std::vector<T>>().emplace(std::forward<Args>(args)...)) {
133-
if (this->size() > 1) {
134-
auto it1 = this->begin();
135-
auto it2 = it1 + 1;
136-
// messing up the container
137-
std::iter_swap(it1, it2);
138-
}
139-
140-
throw 42;
141-
}
142-
143-
template <class... Args>
144-
auto insert(Args&&... args) -> decltype(std::declval<std::vector<T>>().insert(std::forward<Args>(args)...)) {
145-
if (this->size() > 1) {
146-
auto it1 = this->begin();
147-
auto it2 = it1 + 1;
148-
// messing up the container
149-
std::iter_swap(it1, it2);
150-
}
151-
152-
throw 42;
153-
}
154-
};
155-
156-
template <class T>
157-
struct ThrowOnEraseContainer : std::vector<T> {
158-
using std::vector<T>::vector;
159-
160-
template <class... Args>
161-
auto erase(Args&&... args) -> decltype(std::declval<std::vector<T>>().erase(std::forward<Args>(args)...)) {
162-
throw 42;
163-
}
164-
};
165-
166-
template <class T>
167-
struct ThrowOnMoveContainer : std::vector<T> {
168-
using std::vector<T>::vector;
169-
170-
ThrowOnMoveContainer(ThrowOnMoveContainer&&) { throw 42; }
171-
172-
ThrowOnMoveContainer& operator=(ThrowOnMoveContainer&&) { throw 42; }
173-
};
174-
175-
#endif
176-
17734
template <class F>
17835
void test_emplace_exception_guarantee([[maybe_unused]] F&& emplace_function) {
17936
#ifndef TEST_HAS_NO_EXCEPTIONS
@@ -363,32 +220,5 @@ void test_erase_exception_guarantee([[maybe_unused]] F&& erase_function) {
363220
}
364221
#endif
365222
}
366-
class Moveable {
367-
int int_;
368-
double double_;
369-
370-
public:
371-
Moveable() : int_(0), double_(0) {}
372-
Moveable(int i, double d) : int_(i), double_(d) {}
373-
Moveable(Moveable&& x) : int_(x.int_), double_(x.double_) {
374-
x.int_ = -1;
375-
x.double_ = -1;
376-
}
377-
Moveable& operator=(Moveable&& x) {
378-
int_ = x.int_;
379-
x.int_ = -1;
380-
double_ = x.double_;
381-
x.double_ = -1;
382-
return *this;
383-
}
384-
385-
Moveable(const Moveable&) = delete;
386-
Moveable& operator=(const Moveable&) = delete;
387-
bool operator==(const Moveable& x) const { return int_ == x.int_ && double_ == x.double_; }
388-
bool operator<(const Moveable& x) const { return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_); }
389-
390-
int get() const { return int_; }
391-
bool moved() const { return int_ == -1; }
392-
};
393223

394224
#endif // SUPPORT_FLAT_MAP_HELPERS_H

libcxx/test/std/containers/container.adaptors/flat.multimap/helpers.h

Lines changed: 1 addition & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <vector>
1616
#include <flat_map>
1717

18+
#include "../flat_helpers.h"
1819
#include "test_allocator.h"
1920
#include "test_macros.h"
2021

@@ -25,150 +26,6 @@ void check_invariant(const std::flat_multimap<Args...>& m) {
2526
assert(std::is_sorted(keys.begin(), keys.end(), m.key_comp()));
2627
}
2728

28-
struct StartsWith {
29-
explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch + 1) {}
30-
StartsWith(const StartsWith&) = delete;
31-
void operator=(const StartsWith&) = delete;
32-
struct Less {
33-
using is_transparent = void;
34-
bool operator()(const std::string& a, const std::string& b) const { return a < b; }
35-
bool operator()(const StartsWith& a, const std::string& b) const { return a.upper_ <= b; }
36-
bool operator()(const std::string& a, const StartsWith& b) const { return a < b.lower_; }
37-
bool operator()(const StartsWith&, const StartsWith&) const {
38-
assert(false); // should not be called
39-
return false;
40-
}
41-
};
42-
43-
private:
44-
std::string lower_;
45-
std::string upper_;
46-
};
47-
48-
template <class T>
49-
struct CopyOnlyVector : std::vector<T> {
50-
using std::vector<T>::vector;
51-
52-
CopyOnlyVector(const CopyOnlyVector&) = default;
53-
CopyOnlyVector(CopyOnlyVector&& other) : CopyOnlyVector(other) {}
54-
CopyOnlyVector(CopyOnlyVector&& other, std::vector<T>::allocator_type alloc) : CopyOnlyVector(other, alloc) {}
55-
56-
CopyOnlyVector& operator=(const CopyOnlyVector&) = default;
57-
CopyOnlyVector& operator=(CopyOnlyVector& other) { return this->operator=(other); }
58-
};
59-
60-
template <class T, bool ConvertibleToT = false>
61-
struct Transparent {
62-
T t;
63-
64-
operator T() const
65-
requires ConvertibleToT
66-
{
67-
return t;
68-
}
69-
};
70-
71-
template <class T>
72-
using ConvertibleTransparent = Transparent<T, true>;
73-
74-
template <class T>
75-
using NonConvertibleTransparent = Transparent<T, false>;
76-
77-
struct TransparentComparator {
78-
using is_transparent = void;
79-
80-
bool* transparent_used = nullptr;
81-
TransparentComparator() = default;
82-
TransparentComparator(bool& used) : transparent_used(&used) {}
83-
84-
template <class T, bool Convertible>
85-
bool operator()(const T& t, const Transparent<T, Convertible>& transparent) const {
86-
if (transparent_used != nullptr) {
87-
*transparent_used = true;
88-
}
89-
return t < transparent.t;
90-
}
91-
92-
template <class T, bool Convertible>
93-
bool operator()(const Transparent<T, Convertible>& transparent, const T& t) const {
94-
if (transparent_used != nullptr) {
95-
*transparent_used = true;
96-
}
97-
return transparent.t < t;
98-
}
99-
100-
template <class T>
101-
bool operator()(const T& t1, const T& t2) const {
102-
return t1 < t2;
103-
}
104-
};
105-
106-
struct NonTransparentComparator {
107-
template <class T, bool Convertible>
108-
bool operator()(const T&, const Transparent<T, Convertible>&) const;
109-
110-
template <class T, bool Convertible>
111-
bool operator()(const Transparent<T, Convertible>&, const T&) const;
112-
113-
template <class T>
114-
bool operator()(const T&, const T&) const;
115-
};
116-
117-
struct NoDefaultCtr {
118-
NoDefaultCtr() = delete;
119-
};
120-
121-
#ifndef TEST_HAS_NO_EXCEPTIONS
122-
template <class T>
123-
struct EmplaceUnsafeContainer : std::vector<T> {
124-
using std::vector<T>::vector;
125-
126-
template <class... Args>
127-
auto emplace(Args&&... args) -> decltype(std::declval<std::vector<T>>().emplace(std::forward<Args>(args)...)) {
128-
if (this->size() > 1) {
129-
auto it1 = this->begin();
130-
auto it2 = it1 + 1;
131-
// messing up the container
132-
std::iter_swap(it1, it2);
133-
}
134-
135-
throw 42;
136-
}
137-
138-
template <class... Args>
139-
auto insert(Args&&... args) -> decltype(std::declval<std::vector<T>>().insert(std::forward<Args>(args)...)) {
140-
if (this->size() > 1) {
141-
auto it1 = this->begin();
142-
auto it2 = it1 + 1;
143-
// messing up the container
144-
std::iter_swap(it1, it2);
145-
}
146-
147-
throw 42;
148-
}
149-
};
150-
151-
template <class T>
152-
struct ThrowOnEraseContainer : std::vector<T> {
153-
using std::vector<T>::vector;
154-
155-
template <class... Args>
156-
auto erase(Args&&... args) -> decltype(std::declval<std::vector<T>>().erase(std::forward<Args>(args)...)) {
157-
throw 42;
158-
}
159-
};
160-
161-
template <class T>
162-
struct ThrowOnMoveContainer : std::vector<T> {
163-
using std::vector<T>::vector;
164-
165-
ThrowOnMoveContainer(ThrowOnMoveContainer&&) { throw 42; }
166-
167-
ThrowOnMoveContainer& operator=(ThrowOnMoveContainer&&) { throw 42; }
168-
};
169-
170-
#endif
171-
17229
template <class F>
17330
void test_emplace_exception_guarantee([[maybe_unused]] F&& emplace_function) {
17431
#ifndef TEST_HAS_NO_EXCEPTIONS
@@ -358,32 +215,5 @@ void test_erase_exception_guarantee([[maybe_unused]] F&& erase_function) {
358215
}
359216
#endif
360217
}
361-
class Moveable {
362-
int int_;
363-
double double_;
364-
365-
public:
366-
Moveable() : int_(0), double_(0) {}
367-
Moveable(int i, double d) : int_(i), double_(d) {}
368-
Moveable(Moveable&& x) : int_(x.int_), double_(x.double_) {
369-
x.int_ = -1;
370-
x.double_ = -1;
371-
}
372-
Moveable& operator=(Moveable&& x) {
373-
int_ = x.int_;
374-
x.int_ = -1;
375-
double_ = x.double_;
376-
x.double_ = -1;
377-
return *this;
378-
}
379-
380-
Moveable(const Moveable&) = delete;
381-
Moveable& operator=(const Moveable&) = delete;
382-
bool operator==(const Moveable& x) const { return int_ == x.int_ && double_ == x.double_; }
383-
bool operator<(const Moveable& x) const { return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_); }
384-
385-
int get() const { return int_; }
386-
bool moved() const { return int_ == -1; }
387-
};
388218

389219
#endif // SUPPORT_FLAT_MULTIMAP_HELPERS_H

0 commit comments

Comments
 (0)