[libcxx-commits] [libcxx] [libc++] Implement P0429R9 `std::flat_map` (PR #98643)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jul 19 10:00:49 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff c91b50ed92dc1c498aae9c428ace85edc974a8f3 7524429224449c7fa1eb674bfadd965427449b6e --extensions ,cpp,h -- libcxx/include/__flat_map/flat_map.h libcxx/include/__flat_map/sorted_unique.h libcxx/include/flat_map libcxx/test/libcxx/containers/containers.adaptors/flat.map/container_stability.pass.cpp libcxx/test/std/containers/container.adaptors/NaiveStaticVector.h libcxx/test/std/containers/container.adaptors/flat.map/clear.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/comp.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/contains.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/contains_transparent.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/count.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/count_transparent.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/empty.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/empty.verify.cpp libcxx/test/std/containers/container.adaptors/flat.map/equal_range.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/equal_range_transparent.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/erase_key.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/erase_key_transparent.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/find.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/find_transparent.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/alloc.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/assign_initializer_list.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/compare.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/containers.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/containers_compare.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_alloc.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_assign.addressof.compile.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_assign.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct.verify.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/default.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/default_noexcept.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/dtor_noexcept.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/initializer_list.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/initializer_list_compare.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter_comp.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter_stability.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_alloc.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_clears.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_exceptions.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_noexcept.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_container.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_iter_iter_comp.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/incomplete_type.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/insert_range.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/insert_range_stability.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/insert_transparent.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/iterator.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/iterator_comparison.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/iterator_concept_conformance.compile.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/lower_bound.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/lower_bound_transparent.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/max_size.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/op_compare.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/range_concept_conformance.compile.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/reverse_iterator.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/types.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/upper_bound.pass.cpp libcxx/test/std/containers/container.adaptors/flat.map/upper_bound_transparent.pass.cpp libcxx/include/__memory/allocator_traits.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/test/libcxx/containers/containers.adaptors/flat.map/container_stability.pass.cpp b/libcxx/test/libcxx/containers/containers.adaptors/flat.map/container_stability.pass.cpp
index a76d78ac81..0d90c32500 100644
--- a/libcxx/test/libcxx/containers/containers.adaptors/flat.map/container_stability.pass.cpp
+++ b/libcxx/test/libcxx/containers/containers.adaptors/flat.map/container_stability.pass.cpp
@@ -30,12 +30,11 @@ struct Mod256 {
bool operator()(int x, int y) const { return (x % 256) < (y % 256); }
};
-int main(int, char**)
-{
+int main(int, char**) {
std::mt19937 randomness;
std::vector<uint16_t> values;
std::vector<std::pair<uint16_t, uint16_t>> pairs;
- for (int i=0; i < 200; ++i) {
+ for (int i = 0; i < 200; ++i) {
uint16_t r = randomness();
values.push_back(r);
pairs.emplace_back(r, r);
diff --git a/libcxx/test/std/containers/container.adaptors/NaiveStaticVector.h b/libcxx/test/std/containers/container.adaptors/NaiveStaticVector.h
index 1f5d24c0e4..e0177e3c65 100644
--- a/libcxx/test/std/containers/container.adaptors/NaiveStaticVector.h
+++ b/libcxx/test/std/containers/container.adaptors/NaiveStaticVector.h
@@ -12,28 +12,32 @@
#include "test_iterators.h"
#include "test_macros.h"
-template<class T, size_t N>
+template <class T, size_t N>
struct NaiveStaticVector {
struct CapacityError {};
- using value_type = T;
+ using value_type = T;
using difference_type = short;
- using size_type = unsigned short;
- using iterator = random_access_iterator<T*>;
- using const_iterator = random_access_iterator<const T*>;
+ using size_type = unsigned short;
+ using iterator = random_access_iterator<T*>;
+ using const_iterator = random_access_iterator<const T*>;
explicit NaiveStaticVector() = default;
- template<class It> explicit NaiveStaticVector(It first, It last) { while (first != last) insert(*first++); }
+ template <class It>
+ explicit NaiveStaticVector(It first, It last) {
+ while (first != last)
+ insert(*first++);
+ }
// Moving-from a NaiveStaticVector leaves the source vector holding moved-from objects.
// This is intentional (the "Naive" in the name).
// Specifically, moving-out-of a sorted+uniqued NaiveStaticVector<MoveOnly>
// will leave it in a non-sorted+uniqued state.
- NaiveStaticVector(const NaiveStaticVector&) = default;
- NaiveStaticVector(NaiveStaticVector&&) = default; // deliberately don't reset size_
+ NaiveStaticVector(const NaiveStaticVector&) = default;
+ NaiveStaticVector(NaiveStaticVector&&) = default; // deliberately don't reset size_
NaiveStaticVector& operator=(const NaiveStaticVector&) = default;
- NaiveStaticVector& operator=(NaiveStaticVector&&) = default;
+ NaiveStaticVector& operator=(NaiveStaticVector&&) = default;
iterator begin() { return iterator(data_); }
const_iterator begin() const { return const_iterator(data_); }
@@ -45,7 +49,7 @@ struct NaiveStaticVector {
void clear() { size_ = 0; }
- template<class It>
+ template <class It>
iterator insert(const_iterator pos, It first, It last) {
iterator result = pos - cbegin() + begin();
while (first != last) {
@@ -78,9 +82,7 @@ struct NaiveStaticVector {
return begin() + i;
}
- iterator erase(const_iterator pos) {
- return erase(pos, std::next(pos));
- }
+ iterator erase(const_iterator pos) { return erase(pos, std::next(pos)); }
private:
T data_[N];
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/clear.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/clear.pass.cpp
index ec01723476..0ad01d93c9 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/clear.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/clear.pass.cpp
@@ -23,11 +23,10 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
using M = std::flat_map<int, int>;
- M m = {{1,2}, {2,1}, {3,3}, {4,1}, {5,0}};
+ M m = {{1, 2}, {2, 1}, {3, 3}, {4, 1}, {5, 0}};
assert(m.size() == 5);
ASSERT_NOEXCEPT(m.clear());
ASSERT_SAME_TYPE(decltype(m.clear()), void);
@@ -35,8 +34,13 @@ int main(int, char**)
assert(m.size() == 0);
}
{
- using M = std::flat_map<int, int, std::greater<int>, std::deque<int, min_allocator<int>>, std::vector<int, min_allocator<int>>>;
- M m = {{1,2}, {2,1}, {3,3}, {4,1}, {5,0}};
+ using M =
+ std::flat_map<int,
+ int,
+ std::greater<int>,
+ std::deque<int, min_allocator<int>>,
+ std::vector<int, min_allocator<int>>>;
+ M m = {{1, 2}, {2, 1}, {3, 3}, {4, 1}, {5, 0}};
assert(m.size() == 5);
ASSERT_NOEXCEPT(m.clear());
ASSERT_SAME_TYPE(decltype(m.clear()), void);
@@ -45,7 +49,7 @@ int main(int, char**)
}
{
using M = std::flat_map<bool, bool>;
- M m = {{true,false}, {false,true}};
+ M m = {{true, false}, {false, true}};
assert(m.size() == 2);
ASSERT_NOEXCEPT(m.clear());
ASSERT_SAME_TYPE(decltype(m.clear()), void);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/comp.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/comp.pass.cpp
index c1cf9307ce..d86224952d 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/comp.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/comp.pass.cpp
@@ -23,9 +23,9 @@
int main(int, char**) {
{
- using M = std::flat_map<int, char>;
+ using M = std::flat_map<int, char>;
using Comp = std::less<int>; // the default
- M m = {};
+ M m = {};
ASSERT_SAME_TYPE(M::key_compare, Comp);
static_assert(!std::is_same_v<M::value_compare, Comp>);
ASSERT_SAME_TYPE(decltype(m.key_comp()), Comp);
@@ -40,8 +40,8 @@ int main(int, char**) {
}
{
using Comp = std::function<bool(int, int)>;
- using M = std::flat_map<int, int, Comp>;
- Comp comp = std::greater<int>();
+ using M = std::flat_map<int, int, Comp>;
+ Comp comp = std::greater<int>();
M m({}, comp);
ASSERT_SAME_TYPE(M::key_compare, Comp);
ASSERT_SAME_TYPE(decltype(m.key_comp()), Comp);
@@ -50,7 +50,7 @@ int main(int, char**) {
assert(!kc(1, 2));
assert(kc(2, 1));
auto vc = m.value_comp();
- auto a = std::make_pair(1, 2);
+ auto a = std::make_pair(1, 2);
ASSERT_SAME_TYPE(decltype(vc(a, a)), bool);
static_assert(!noexcept(vc(a, a)));
assert(!vc({1, 2}, {2, 1}));
@@ -58,8 +58,8 @@ int main(int, char**) {
}
{
using Comp = std::less<>;
- using M = std::flat_map<int, int, Comp>;
- M m = {};
+ using M = std::flat_map<int, int, Comp>;
+ M m = {};
ASSERT_SAME_TYPE(M::key_compare, Comp);
ASSERT_SAME_TYPE(decltype(m.key_comp()), Comp);
ASSERT_SAME_TYPE(decltype(m.value_comp()), M::value_compare);
@@ -67,26 +67,26 @@ int main(int, char**) {
assert(kc(1, 2));
assert(!kc(2, 1));
auto vc = m.value_comp();
- auto a = std::make_pair(1, 2);
+ auto a = std::make_pair(1, 2);
ASSERT_SAME_TYPE(decltype(vc(a, a)), bool);
assert(vc({1, 2}, {2, 1}));
assert(!vc({2, 1}, {1, 2}));
}
{
using Comp = std::function<bool(const std::vector<int>&, const std::vector<int>&)>;
- using M = std::flat_map<std::vector<int>, int, Comp>;
- Comp comp = [i=1](const auto& x, const auto& y) { return x[i] < y[i]; };
+ using M = std::flat_map<std::vector<int>, int, Comp>;
+ Comp comp = [i = 1](const auto& x, const auto& y) { return x[i] < y[i]; };
M m({}, comp);
auto vc = m.value_comp();
static_assert(sizeof(vc) >= sizeof(Comp));
comp = nullptr;
- m = M({}, nullptr);
+ m = M({}, nullptr);
assert(m.key_comp() == nullptr);
// At this point, m.key_comp() is disengaged.
// But the std::function captured by copy inside `vc` remains valid.
- auto a = std::make_pair(std::vector<int>{2,1,4}, 42);
- auto b = std::make_pair(std::vector<int>{1,2,3}, 42);
- auto c = std::make_pair(std::vector<int>{0,3,2}, 42);
+ auto a = std::make_pair(std::vector<int>{2, 1, 4}, 42);
+ auto b = std::make_pair(std::vector<int>{1, 2, 3}, 42);
+ auto c = std::make_pair(std::vector<int>{0, 3, 2}, 42);
assert(vc(a, b));
assert(vc(b, c));
assert(!vc(b, a));
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/contains.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/contains.pass.cpp
index 5f1def4304..930ee4329d 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/contains.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/contains.pass.cpp
@@ -21,51 +21,50 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
using M = std::flat_map<int, const char*>;
- M m = {{1,""}, {2,""}, {4,""}, {5,""}, {8,""}};
+ M m = {{1, ""}, {2, ""}, {4, ""}, {5, ""}, {8, ""}};
assert(!m.contains(0));
- assert( m.contains(1));
- assert( m.contains(2));
+ assert(m.contains(1));
+ assert(m.contains(2));
assert(!m.contains(3));
- assert( m.contains(4));
- assert( m.contains(5));
+ assert(m.contains(4));
+ assert(m.contains(5));
assert(!m.contains(6));
assert(!m.contains(7));
- assert( std::as_const(m).contains(8));
+ assert(std::as_const(m).contains(8));
assert(!std::as_const(m).contains(9));
m.clear();
assert(!m.contains(1));
}
{
using M = std::flat_map<int, int, std::greater<int>, std::deque<int, min_allocator<int>>>;
- M m = {{1,0}, {2,0}, {4,0}, {5,0}, {8,0}};
+ M m = {{1, 0}, {2, 0}, {4, 0}, {5, 0}, {8, 0}};
assert(!m.contains(0));
- assert( m.contains(1));
- assert( m.contains(2));
+ assert(m.contains(1));
+ assert(m.contains(2));
assert(!m.contains(3));
- assert( m.contains(4));
- assert( m.contains(5));
+ assert(m.contains(4));
+ assert(m.contains(5));
assert(!m.contains(6));
assert(!m.contains(7));
- assert( std::as_const(m).contains(8));
+ assert(std::as_const(m).contains(8));
assert(!std::as_const(m).contains(9));
m.clear();
assert(!m.contains(1));
}
{
using M = std::flat_map<bool, int>;
- M m = {{true,1}, {false,2}};
- assert( m.contains(true));
- assert( m.contains(false));
- m = {{true,3}};
- assert( m.contains(true));
+ M m = {{true, 1}, {false, 2}};
+ assert(m.contains(true));
+ assert(m.contains(false));
+ m = {{true, 3}};
+ assert(m.contains(true));
assert(!m.contains(false));
- m = {{false,4}};
+ m = {{false, 4}};
assert(!std::as_const(m).contains(true));
- assert( std::as_const(m).contains(false));
+ assert(std::as_const(m).contains(false));
m.clear();
assert(!m.contains(true));
assert(!m.contains(false));
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/contains_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/contains_transparent.pass.cpp
index 0c4c9fcefa..0237470d73 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/contains_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/contains_transparent.pass.cpp
@@ -20,8 +20,8 @@
#include "test_macros.h"
struct StartsWith {
- explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch+1) {}
- StartsWith(const StartsWith&) = delete;
+ explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch + 1) {}
+ StartsWith(const StartsWith&) = delete;
void operator=(const StartsWith&) = delete;
struct Less {
using is_transparent = void;
@@ -29,16 +29,16 @@ struct StartsWith {
bool operator()(const StartsWith& a, const std::string& b) const { return a.upper_ <= b; }
bool operator()(const std::string& a, const StartsWith& b) const { return a < b.lower_; }
};
+
private:
std::string lower_;
std::string upper_;
};
-int main(int, char**)
-{
+int main(int, char**) {
{
using M = std::flat_map<std::string, int, StartsWith::Less>;
- M m = { {"alpha", 1}, {"beta", 2}, {"epsilon", 3}, {"eta", 4}, {"gamma", 5} };
+ M m = {{"alpha", 1}, {"beta", 2}, {"epsilon", 3}, {"eta", 4}, {"gamma", 5}};
ASSERT_SAME_TYPE(decltype(m.contains(StartsWith('b'))), bool);
ASSERT_SAME_TYPE(decltype(std::as_const(m).contains(StartsWith('b'))), bool);
assert(m.contains("beta") == true);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/count.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/count.pass.cpp
index bca4251bdb..a0858c6adc 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/count.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/count.pass.cpp
@@ -21,11 +21,10 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
using M = std::flat_map<int, const char*>;
- M m = {{1,""}, {2,""}, {4,""}, {5,""}, {8,""}};
+ M m = {{1, ""}, {2, ""}, {4, ""}, {5, ""}, {8, ""}};
ASSERT_SAME_TYPE(decltype(m.count(0)), size_t);
assert(m.count(0) == 0);
assert(m.count(1) == 1);
@@ -40,7 +39,7 @@ int main(int, char**)
}
{
using M = std::flat_map<int, int, std::greater<int>, std::deque<int, min_allocator<int>>>;
- M m = {{1,0}, {2,0}, {4,0}, {5,0}, {8,0}};
+ M m = {{1, 0}, {2, 0}, {4, 0}, {5, 0}, {8, 0}};
ASSERT_SAME_TYPE(decltype(m.count(0)), size_t);
assert(m.count(0) == 0);
assert(m.count(1) == 1);
@@ -55,14 +54,14 @@ int main(int, char**)
}
{
using M = std::flat_map<bool, int>;
- M m = {{true,1}, {false,2}};
+ M m = {{true, 1}, {false, 2}};
ASSERT_SAME_TYPE(decltype(m.count(0)), size_t);
assert(m.count(true) == 1);
assert(m.count(false) == 1);
- m = {{true,3}};
+ m = {{true, 3}};
assert(m.count(true) == 1);
assert(m.count(false) == 0);
- m = {{false,4}};
+ m = {{false, 4}};
assert(std::as_const(m).count(true) == 0);
assert(std::as_const(m).count(false) == 1);
m.clear();
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/count_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/count_transparent.pass.cpp
index 2ca6bd9ec1..793cef5ee8 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/count_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/count_transparent.pass.cpp
@@ -20,8 +20,8 @@
#include "test_macros.h"
struct StartsWith {
- explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch+1) {}
- StartsWith(const StartsWith&) = delete;
+ explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch + 1) {}
+ StartsWith(const StartsWith&) = delete;
void operator=(const StartsWith&) = delete;
struct Less {
using is_transparent = void;
@@ -29,16 +29,16 @@ struct StartsWith {
bool operator()(const StartsWith& a, const std::string& b) const { return a.upper_ <= b; }
bool operator()(const std::string& a, const StartsWith& b) const { return a < b.lower_; }
};
+
private:
std::string lower_;
std::string upper_;
};
-int main(int, char**)
-{
+int main(int, char**) {
{
using M = std::flat_map<std::string, int, StartsWith::Less>;
- M m = { {"alpha", 1}, {"beta", 2}, {"epsilon", 3}, {"eta", 4}, {"gamma", 5} };
+ M m = {{"alpha", 1}, {"beta", 2}, {"epsilon", 3}, {"eta", 4}, {"gamma", 5}};
ASSERT_SAME_TYPE(decltype(m.count(StartsWith('b'))), M::size_type);
ASSERT_SAME_TYPE(decltype(std::as_const(m).count(StartsWith('b'))), M::size_type);
assert(m.count("beta") == 1);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/empty.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/empty.pass.cpp
index 000b36daa9..72ac225e25 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/empty.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/empty.pass.cpp
@@ -21,8 +21,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
typedef std::flat_map<int, int> M;
M m;
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/empty.verify.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/empty.verify.cpp
index 8d98abf10a..cc8016182d 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/empty.verify.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/empty.verify.cpp
@@ -16,8 +16,7 @@
#include "test_macros.h"
-int main(int, char**)
-{
+int main(int, char**) {
std::flat_map<int, int> c;
c.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/equal_range.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/equal_range.pass.cpp
index 6d1c3fd4d3..1c95006bdd 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/equal_range.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/equal_range.pass.cpp
@@ -22,59 +22,63 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
- using M = std::flat_map<int, char>;
- using R = std::pair<M::iterator, M::iterator>;
+ using M = std::flat_map<int, char>;
+ using R = std::pair<M::iterator, M::iterator>;
using CR = std::pair<M::const_iterator, M::const_iterator>;
- M m = {{1,'a'}, {2,'b'}, {4,'d'}, {5,'e'}, {8,'h'}};
+ M m = {{1, 'a'}, {2, 'b'}, {4, 'd'}, {5, 'e'}, {8, 'h'}};
ASSERT_SAME_TYPE(decltype(m.equal_range(0)), R);
ASSERT_SAME_TYPE(decltype(std::as_const(m).equal_range(0)), CR);
auto begin = m.begin();
assert(m.equal_range(0) == std::pair(begin, begin));
- assert(m.equal_range(1) == std::pair(begin, begin+1));
- assert(m.equal_range(2) == std::pair(begin+1, begin+2));
- assert(m.equal_range(3) == std::pair(begin+2, begin+2));
- assert(m.equal_range(4) == std::pair(begin+2, begin+3));
- assert(m.equal_range(5) == std::pair(begin+3, begin+4));
- assert(m.equal_range(6) == std::pair(begin+4, begin+4));
- assert(m.equal_range(7) == std::pair(begin+4, begin+4));
- assert(std::as_const(m).equal_range(8) == std::pair(m.cbegin()+4, m.cbegin()+5));
- assert(std::as_const(m).equal_range(9) == std::pair(m.cbegin()+5, m.cbegin()+5));
+ assert(m.equal_range(1) == std::pair(begin, begin + 1));
+ assert(m.equal_range(2) == std::pair(begin + 1, begin + 2));
+ assert(m.equal_range(3) == std::pair(begin + 2, begin + 2));
+ assert(m.equal_range(4) == std::pair(begin + 2, begin + 3));
+ assert(m.equal_range(5) == std::pair(begin + 3, begin + 4));
+ assert(m.equal_range(6) == std::pair(begin + 4, begin + 4));
+ assert(m.equal_range(7) == std::pair(begin + 4, begin + 4));
+ assert(std::as_const(m).equal_range(8) == std::pair(m.cbegin() + 4, m.cbegin() + 5));
+ assert(std::as_const(m).equal_range(9) == std::pair(m.cbegin() + 5, m.cbegin() + 5));
}
{
- using M = std::flat_map<int, char, std::greater<int>, std::deque<int, min_allocator<int>>, std::deque<char, min_allocator<char>>>;
- using R = std::pair<M::iterator, M::iterator>;
+ using M =
+ std::flat_map<int,
+ char,
+ std::greater<int>,
+ std::deque<int, min_allocator<int>>,
+ std::deque<char, min_allocator<char>>>;
+ using R = std::pair<M::iterator, M::iterator>;
using CR = std::pair<M::const_iterator, M::const_iterator>;
- M m = {{1,'a'}, {2,'b'}, {4,'d'}, {5,'e'}, {8,'h'}};
+ M m = {{1, 'a'}, {2, 'b'}, {4, 'd'}, {5, 'e'}, {8, 'h'}};
ASSERT_SAME_TYPE(decltype(m.equal_range(0)), R);
ASSERT_SAME_TYPE(decltype(std::as_const(m).equal_range(0)), CR);
auto begin = m.begin();
- assert(m.equal_range(0) == std::pair(begin+5, begin+5));
- assert(m.equal_range(1) == std::pair(begin+4, begin+5));
- assert(m.equal_range(2) == std::pair(begin+3, begin+4));
- assert(m.equal_range(3) == std::pair(begin+3, begin+3));
- assert(m.equal_range(4) == std::pair(begin+2, begin+3));
- assert(m.equal_range(5) == std::pair(begin+1, begin+2));
- assert(m.equal_range(6) == std::pair(begin+1, begin+1));
- assert(m.equal_range(7) == std::pair(begin+1, begin+1));
- assert(std::as_const(m).equal_range(8) == std::pair(m.cbegin(), m.cbegin()+1));
+ assert(m.equal_range(0) == std::pair(begin + 5, begin + 5));
+ assert(m.equal_range(1) == std::pair(begin + 4, begin + 5));
+ assert(m.equal_range(2) == std::pair(begin + 3, begin + 4));
+ assert(m.equal_range(3) == std::pair(begin + 3, begin + 3));
+ assert(m.equal_range(4) == std::pair(begin + 2, begin + 3));
+ assert(m.equal_range(5) == std::pair(begin + 1, begin + 2));
+ assert(m.equal_range(6) == std::pair(begin + 1, begin + 1));
+ assert(m.equal_range(7) == std::pair(begin + 1, begin + 1));
+ assert(std::as_const(m).equal_range(8) == std::pair(m.cbegin(), m.cbegin() + 1));
assert(std::as_const(m).equal_range(9) == std::pair(m.cbegin(), m.cbegin()));
}
{
- using M = std::flat_map<bool, bool>;
- using R = std::pair<M::iterator, M::iterator>;
+ using M = std::flat_map<bool, bool>;
+ using R = std::pair<M::iterator, M::iterator>;
using CR = std::pair<M::const_iterator, M::const_iterator>;
- M m = {{true,false}, {false,true}};
+ M m = {{true, false}, {false, true}};
ASSERT_SAME_TYPE(decltype(m.equal_range(0)), R);
ASSERT_SAME_TYPE(decltype(std::as_const(m).equal_range(0)), CR);
- assert(m.equal_range(true) == std::pair(m.begin()+1, m.end()));
- assert(m.equal_range(false) == std::pair(m.begin(), m.begin()+1));
- m = {{true,true}};
+ assert(m.equal_range(true) == std::pair(m.begin() + 1, m.end()));
+ assert(m.equal_range(false) == std::pair(m.begin(), m.begin() + 1));
+ m = {{true, true}};
assert(m.equal_range(true) == std::pair(m.begin(), m.end()));
assert(m.equal_range(false) == std::pair(m.begin(), m.begin()));
- m = {{false,false}};
+ m = {{false, false}};
assert(std::as_const(m).equal_range(true) == std::pair(m.cend(), m.cend()));
assert(std::as_const(m).equal_range(false) == std::pair(m.cbegin(), m.cend()));
m.clear();
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/equal_range_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/equal_range_transparent.pass.cpp
index ee6bc7ef88..df0bfd01d3 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/equal_range_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/equal_range_transparent.pass.cpp
@@ -21,8 +21,8 @@
#include "test_macros.h"
struct StartsWith {
- explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch+1) {}
- StartsWith(const StartsWith&) = delete;
+ explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch + 1) {}
+ StartsWith(const StartsWith&) = delete;
void operator=(const StartsWith&) = delete;
struct Less {
using is_transparent = void;
@@ -30,28 +30,28 @@ struct StartsWith {
bool operator()(const StartsWith& a, const std::string& b) const { return a.upper_ <= b; }
bool operator()(const std::string& a, const StartsWith& b) const { return a < b.lower_; }
};
+
private:
std::string lower_;
std::string upper_;
};
-int main(int, char**)
-{
+int main(int, char**) {
{
- using M = std::flat_map<std::string, int, StartsWith::Less>;
- using R = std::pair<M::iterator, M::iterator>;
+ using M = std::flat_map<std::string, int, StartsWith::Less>;
+ using R = std::pair<M::iterator, M::iterator>;
using CR = std::pair<M::const_iterator, M::const_iterator>;
- M m = { {"alpha", 1}, {"beta", 2}, {"epsilon", 3}, {"eta", 4}, {"gamma", 5} };
+ M m = {{"alpha", 1}, {"beta", 2}, {"epsilon", 3}, {"eta", 4}, {"gamma", 5}};
ASSERT_SAME_TYPE(decltype(m.equal_range(StartsWith('b'))), R);
ASSERT_SAME_TYPE(decltype(std::as_const(m).equal_range(StartsWith('b'))), CR);
auto begin = m.begin();
- assert(m.equal_range("beta") == std::pair(begin+1, begin+2));
- assert(m.equal_range("delta") == std::pair(begin+2, begin+2));
- assert(m.equal_range("zeta") == std::pair(begin+5, begin+5));
- assert(m.equal_range(StartsWith('b')) == std::pair(begin+1, begin+2));
- assert(m.equal_range(StartsWith('d')) == std::pair(begin+2, begin+2));
- assert(m.equal_range(StartsWith('e')) == std::pair(begin+2, begin+4));
- assert(m.equal_range(StartsWith('z')) == std::pair(begin+5, begin+5));
+ assert(m.equal_range("beta") == std::pair(begin + 1, begin + 2));
+ assert(m.equal_range("delta") == std::pair(begin + 2, begin + 2));
+ assert(m.equal_range("zeta") == std::pair(begin + 5, begin + 5));
+ assert(m.equal_range(StartsWith('b')) == std::pair(begin + 1, begin + 2));
+ assert(m.equal_range(StartsWith('d')) == std::pair(begin + 2, begin + 2));
+ assert(m.equal_range(StartsWith('e')) == std::pair(begin + 2, begin + 4));
+ assert(m.equal_range(StartsWith('z')) == std::pair(begin + 5, begin + 5));
}
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/erase_key.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/erase_key.pass.cpp
index 8b76882138..50dd566b0b 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/erase_key.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/erase_key.pass.cpp
@@ -22,10 +22,9 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
- using M = std::flat_map<int, char>;
+ using M = std::flat_map<int, char>;
auto make = [](std::initializer_list<int> il) {
M m;
for (int i : il) {
@@ -33,32 +32,32 @@ int main(int, char**)
}
return m;
};
- M m = make({1,2,3,4,5,6,7,8});
+ M m = make({1, 2, 3, 4, 5, 6, 7, 8});
ASSERT_SAME_TYPE(decltype(m.erase(9)), M::size_type);
auto n = m.erase(9);
assert(n == 0);
- assert(m == make({1,2,3,4,5,6,7,8}));
+ assert(m == make({1, 2, 3, 4, 5, 6, 7, 8}));
n = m.erase(4);
assert(n == 1);
- assert(m == make({1,2,3,5,6,7,8}));
+ assert(m == make({1, 2, 3, 5, 6, 7, 8}));
n = m.erase(1);
assert(n == 1);
- assert(m == make({2,3,5,6,7,8}));
+ assert(m == make({2, 3, 5, 6, 7, 8}));
n = m.erase(8);
assert(n == 1);
- assert(m == make({2,3,5,6,7}));
+ assert(m == make({2, 3, 5, 6, 7}));
n = m.erase(3);
assert(n == 1);
- assert(m == make({2,5,6,7}));
+ assert(m == make({2, 5, 6, 7}));
n = m.erase(4);
assert(n == 0);
- assert(m == make({2,5,6,7}));
+ assert(m == make({2, 5, 6, 7}));
n = m.erase(6);
assert(n == 1);
- assert(m == make({2,5,7}));
+ assert(m == make({2, 5, 7}));
n = m.erase(7);
assert(n == 1);
- assert(m == make({2,5}));
+ assert(m == make({2, 5}));
n = m.erase(2);
assert(n == 1);
assert(m == make({5}));
@@ -67,7 +66,7 @@ int main(int, char**)
assert(m.empty());
}
{
- using M = std::flat_map<int, int, std::greater<>, std::deque<int, min_allocator<int>>, std::deque<int>>;
+ using M = std::flat_map<int, int, std::greater<>, std::deque<int, min_allocator<int>>, std::deque<int>>;
auto make = [](std::initializer_list<int> il) {
M m;
for (int i : il) {
@@ -75,34 +74,34 @@ int main(int, char**)
}
return m;
};
- M::key_container_type container = {5,6,7,8};
- container.insert(container.begin(), {1,2,3,4});
- M m = M(std::move(container), {1,2,3,4,5,6,7,8});
+ M::key_container_type container = {5, 6, 7, 8};
+ container.insert(container.begin(), {1, 2, 3, 4});
+ M m = M(std::move(container), {1, 2, 3, 4, 5, 6, 7, 8});
ASSERT_SAME_TYPE(decltype(m.erase(9)), M::size_type);
auto n = m.erase(9);
assert(n == 0);
- assert(m == make({1,2,3,4,5,6,7,8}));
+ assert(m == make({1, 2, 3, 4, 5, 6, 7, 8}));
n = m.erase(4);
assert(n == 1);
- assert(m == make({1,2,3,5,6,7,8}));
+ assert(m == make({1, 2, 3, 5, 6, 7, 8}));
n = m.erase(1);
assert(n == 1);
- assert(m == make({2,3,5,6,7,8}));
+ assert(m == make({2, 3, 5, 6, 7, 8}));
n = m.erase(8);
assert(n == 1);
- assert(m == make({2,3,5,6,7}));
+ assert(m == make({2, 3, 5, 6, 7}));
n = m.erase(3);
assert(n == 1);
- assert(m == make({2,5,6,7}));
+ assert(m == make({2, 5, 6, 7}));
n = m.erase(4);
assert(n == 0);
- assert(m == make({2,5,6,7}));
+ assert(m == make({2, 5, 6, 7}));
n = m.erase(6);
assert(n == 1);
- assert(m == make({2,5,7}));
+ assert(m == make({2, 5, 7}));
n = m.erase(7);
assert(n == 1);
- assert(m == make({2,5}));
+ assert(m == make({2, 5}));
n = m.erase(2);
assert(n == 1);
assert(m == make({5}));
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/erase_key_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/erase_key_transparent.pass.cpp
index cad13d18f1..ed22b3eff3 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/erase_key_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/erase_key_transparent.pass.cpp
@@ -23,7 +23,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-template<class Key, class It>
+template <class Key, class It>
struct HeterogeneousKey {
explicit HeterogeneousKey(Key key, It it) : key_(key), it_(it) {}
operator It() && { return it_; }
@@ -33,8 +33,8 @@ struct HeterogeneousKey {
};
struct StartsWith {
- explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch+1) {}
- StartsWith(const StartsWith&) = delete;
+ explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch + 1) {}
+ StartsWith(const StartsWith&) = delete;
void operator=(const StartsWith&) = delete;
struct Less {
using is_transparent = void;
@@ -42,78 +42,78 @@ struct StartsWith {
bool operator()(const StartsWith& a, const std::string& b) const { return a.upper_ <= b; }
bool operator()(const std::string& a, const StartsWith& b) const { return a < b.lower_; }
};
+
private:
std::string lower_;
std::string upper_;
};
-int main(int, char**)
-{
+int main(int, char**) {
{
using M = std::flat_map<std::string, int, StartsWith::Less>;
- M m = { {"alpha", 1}, {"beta", 2}, {"epsilon", 3}, {"eta", 4}, {"gamma", 5} };
+ M m = {{"alpha", 1}, {"beta", 2}, {"epsilon", 3}, {"eta", 4}, {"gamma", 5}};
ASSERT_SAME_TYPE(decltype(m.erase(StartsWith('b'))), M::size_type);
M::size_type n = m.erase(StartsWith('e'));
assert(n == 2);
- assert((m == M{ {"alpha", 1}, {"beta", 2}, {"gamma", 5} }));
+ assert((m == M{{"alpha", 1}, {"beta", 2}, {"gamma", 5}}));
n = m.erase(StartsWith('d'));
assert(n == 0);
- assert((m == M{ {"alpha", 1}, {"beta", 2}, {"gamma", 5} }));
+ assert((m == M{{"alpha", 1}, {"beta", 2}, {"gamma", 5}}));
}
{
using M = std::flat_map<int, int, std::less<>>;
- M m = {{1,1}, {2,2}, {3,3}, {4,4}};
+ M m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}};
ASSERT_SAME_TYPE(decltype(m.erase(9)), M::size_type);
auto n = m.erase(3); // erase(K&&) [with K=int]
assert(n == 1);
- assert((m == M{{1,1}, {2,2}, {4,4}}));
+ assert((m == M{{1, 1}, {2, 2}, {4, 4}}));
M::key_type lvalue = 2;
- n = m.erase(lvalue); // erase(K&&) [with K=int&]
+ n = m.erase(lvalue); // erase(K&&) [with K=int&]
assert(n == 1);
- assert((m == M{{1,1}, {4,4}}));
+ assert((m == M{{1, 1}, {4, 4}}));
const M::key_type const_lvalue = 1;
- n = m.erase(const_lvalue); // erase(const key_type&)
+ n = m.erase(const_lvalue); // erase(const key_type&)
assert(n == 1);
- assert((m == M{{4,4}}));
+ assert((m == M{{4, 4}}));
}
{
using M = std::flat_map<int, int, std::less<>, std::deque<int, min_allocator<int>>, std::deque<int>>;
- M m = {{1,1}, {2,2}, {3,3}, {4,4}};
+ M m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}};
ASSERT_SAME_TYPE(decltype(m.erase(9)), M::size_type);
auto n = m.erase(3); // erase(K&&) [with K=int]
assert(n == 1);
- assert((m == M{{1,1}, {2,2}, {4,4}}));
+ assert((m == M{{1, 1}, {2, 2}, {4, 4}}));
M::key_type lvalue = 2;
- n = m.erase(lvalue); // erase(K&&) [with K=int&]
+ n = m.erase(lvalue); // erase(K&&) [with K=int&]
assert(n == 1);
- assert((m == M{{1,1}, {4,4}}));
+ assert((m == M{{1, 1}, {4, 4}}));
const M::key_type const_lvalue = 1;
- n = m.erase(const_lvalue); // erase(const key_type&)
+ n = m.erase(const_lvalue); // erase(const key_type&)
assert(n == 1);
- assert((m == M{{4,4}}));
+ assert((m == M{{4, 4}}));
}
{
// P2077's HeterogeneousKey example
- using M = std::flat_map<int, int, std::less<>>;
- M m = {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}, {7,7}, {8,8}};
- auto h1 = HeterogeneousKey<int, M::iterator>(8, m.begin());
+ using M = std::flat_map<int, int, std::less<>>;
+ M m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}, {8, 8}};
+ auto h1 = HeterogeneousKey<int, M::iterator>(8, m.begin());
std::same_as<M::size_type> auto n = m.erase(h1); // lvalue is not convertible to It; erase(K&&) is the best match
assert(n == 1);
- assert((m == M{{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}, {7,7}}));
+ assert((m == M{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}}));
std::same_as<M::iterator> auto it = m.erase(std::move(h1)); // rvalue is convertible to It; erase(K&&) drops out
assert(it == m.begin());
- assert((m == M{{2,2}, {3,3}, {4,4}, {5,5}, {6,6}, {7,7}}));
+ assert((m == M{{2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}}));
}
{
- using M = std::flat_map<int, int, std::less<>>;
- M m = {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}, {7,7}, {8,8}};
- auto h1 = HeterogeneousKey<int, M::const_iterator>(8, m.begin());
+ using M = std::flat_map<int, int, std::less<>>;
+ M m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}, {8, 8}};
+ auto h1 = HeterogeneousKey<int, M::const_iterator>(8, m.begin());
std::same_as<M::size_type> auto n = m.erase(h1); // lvalue is not convertible to It; erase(K&&) is the best match
assert(n == 1);
- assert((m == M{{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}, {7,7}}));
+ assert((m == M{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}}));
std::same_as<M::iterator> auto it = m.erase(std::move(h1)); // rvalue is convertible to It; erase(K&&) drops out
assert(it == m.begin());
- assert((m == M{{2,2}, {3,3}, {4,4}, {5,5}, {6,6}, {7,7}}));
+ assert((m == M{{2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}}));
}
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/find.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/find.pass.cpp
index 4f3f4a832d..786bec307c 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/find.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/find.pass.cpp
@@ -23,11 +23,10 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
using M = std::flat_map<int, char>;
- M m = {{1,'a'}, {2,'b'}, {4,'d'}, {5,'e'}, {8,'h'}};
+ M m = {{1, 'a'}, {2, 'b'}, {4, 'd'}, {5, 'e'}, {8, 'h'}};
ASSERT_SAME_TYPE(decltype(m.find(0)), M::iterator);
ASSERT_SAME_TYPE(decltype(std::as_const(m).find(0)), M::const_iterator);
assert(m.find(0) == m.end());
@@ -43,7 +42,7 @@ int main(int, char**)
}
{
using M = std::flat_map<int, char, std::greater<int>, std::deque<int, min_allocator<int>>, std::string>;
- M m = {{1,'a'}, {2,'b'}, {4,'d'}, {5,'e'}, {8,'h'}};
+ M m = {{1, 'a'}, {2, 'b'}, {4, 'd'}, {5, 'e'}, {8, 'h'}};
ASSERT_SAME_TYPE(decltype(m.find(0)), M::iterator);
ASSERT_SAME_TYPE(decltype(std::as_const(m).find(0)), M::const_iterator);
assert(m.find(0) == m.end());
@@ -59,15 +58,15 @@ int main(int, char**)
}
{
using M = std::flat_map<bool, bool>;
- M m = {{true,false}, {false,true}};
+ M m = {{true, false}, {false, true}};
ASSERT_SAME_TYPE(decltype(m.find(0)), M::iterator);
ASSERT_SAME_TYPE(decltype(std::as_const(m).find(0)), M::const_iterator);
assert(m.find(true) == m.begin() + 1);
assert(m.find(false) == m.begin());
- m = {{true,true}};
+ m = {{true, true}};
assert(m.find(true) == m.begin());
assert(m.find(false) == m.end());
- m = {{false,false}};
+ m = {{false, false}};
assert(std::as_const(m).find(true) == m.end());
assert(std::as_const(m).find(false) == m.begin());
m.clear();
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/find_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/find_transparent.pass.cpp
index 860959ed4f..206583c20b 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/find_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/find_transparent.pass.cpp
@@ -21,8 +21,8 @@
#include "test_macros.h"
struct StartsWith {
- explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch+1) {}
- StartsWith(const StartsWith&) = delete;
+ explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch + 1) {}
+ StartsWith(const StartsWith&) = delete;
void operator=(const StartsWith&) = delete;
struct Less {
using is_transparent = void;
@@ -30,16 +30,16 @@ struct StartsWith {
bool operator()(const StartsWith& a, const std::string& b) const { return a.upper_ <= b; }
bool operator()(const std::string& a, const StartsWith& b) const { return a < b.lower_; }
};
+
private:
std::string lower_;
std::string upper_;
};
-int main(int, char**)
-{
+int main(int, char**) {
{
using M = std::flat_map<std::string, int, StartsWith::Less>;
- M m = { {"alpha", 1}, {"beta", 2}, {"epsilon", 3}, {"eta", 4}, {"gamma", 5} };
+ M m = {{"alpha", 1}, {"beta", 2}, {"epsilon", 3}, {"eta", 4}, {"gamma", 5}};
ASSERT_SAME_TYPE(decltype(m.find(StartsWith('b'))), M::iterator);
ASSERT_SAME_TYPE(decltype(std::as_const(m).find(StartsWith('b'))), M::const_iterator);
assert(m.find("beta") == m.begin() + 1);
@@ -49,7 +49,7 @@ int main(int, char**)
assert(m.find(StartsWith('d')) == m.end());
auto it = m.find(StartsWith('e'));
assert(m.begin() + 2 <= it && it <= m.begin() + 3); // either is acceptable
- LIBCPP_ASSERT(it == m.begin() + 2); // return the earliest match
+ LIBCPP_ASSERT(it == m.begin() + 2); // return the earliest match
assert(m.find(StartsWith('z')) == m.end());
}
return 0;
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/alloc.pass.cpp
index cbfefa8a66..4aa55c1a0f 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/alloc.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/alloc.pass.cpp
@@ -22,11 +22,15 @@
#include "test_macros.h"
#include "test_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
using A = test_allocator<short>;
- using M = std::flat_map<int, long, std::less<int>, std::vector<int, test_allocator<int>>, std::vector<long, test_allocator<long>>>;
+ using M =
+ std::flat_map<int,
+ long,
+ std::less<int>,
+ std::vector<int, test_allocator<int>>,
+ std::vector<long, test_allocator<long>>>;
M m(A(0, 5));
assert(m.empty());
assert(m.begin() == m.end());
@@ -37,7 +41,7 @@ int main(int, char**)
using M = std::flat_map<int, short, std::less<int>, std::pmr::vector<int>, std::pmr::vector<short>>;
std::pmr::monotonic_buffer_resource mr;
std::pmr::polymorphic_allocator<int> pa = &mr;
- auto m1 = M(pa);
+ auto m1 = M(pa);
assert(m1.empty());
assert(m1.keys().get_allocator() == pa);
assert(m1.values().get_allocator() == pa);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/assign_initializer_list.pass.cpp
index 91e969b8e1..1d0c8657f7 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/assign_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/assign_initializer_list.pass.cpp
@@ -27,37 +27,43 @@
int main(int, char**) {
{
using C = std::flat_map<int, int>;
- C m = {{8,8}, {10,10}};
+ C m = {{8, 8}, {10, 10}};
assert(m.size() == 2);
- m = {{3,0}, {1,0}, {2,0}, {2,1}, {3,1}, {4,0}, {3,2}, {5,0}, {6,0}, {5,1}};
- std::pair<int, int> expected[] = {{1,0}, {2,0}, {3,0}, {4,0}, {5,0}, {6,0}};
+ m = {{3, 0}, {1, 0}, {2, 0}, {2, 1}, {3, 1}, {4, 0}, {3, 2}, {5, 0}, {6, 0}, {5, 1}};
+ std::pair<int, int> expected[] = {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}};
assert(std::ranges::equal(m.keys(), expected | std::views::elements<0>));
LIBCPP_ASSERT(std::ranges::equal(m, expected));
}
{
- using C = std::flat_map<int, int, std::less<>, std::vector<int, min_allocator<int>>, std::vector<int, min_allocator<int>>>;
- C m = {{1,1}, {2,1}, {3,1}, {4,1}, {5,1}, {6,1}, {7,1}, {8,1}, {9,1}, {10,1}};
+ using C = std::
+ flat_map<int, int, std::less<>, std::vector<int, min_allocator<int>>, std::vector<int, min_allocator<int>>>;
+ C m = {{1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {6, 1}, {7, 1}, {8, 1}, {9, 1}, {10, 1}};
assert(m.size() == 10);
- m = {{1,1}, {3,2}, {4,3}, {5,4}, {6,5}, {5,6}, {2,7}};
- std::pair<int, int> expected[] = {{1,1}, {2,7}, {3,2}, {4,3}, {5,4}, {6,5}};
+ m = {{1, 1}, {3, 2}, {4, 3}, {5, 4}, {6, 5}, {5, 6}, {2, 7}};
+ std::pair<int, int> expected[] = {{1, 1}, {2, 7}, {3, 2}, {4, 3}, {5, 4}, {6, 5}};
assert(std::ranges::equal(m.keys(), expected | std::views::elements<0>));
LIBCPP_ASSERT(std::ranges::equal(m, expected));
}
{
- using C = std::flat_map<double, int, std::less<>, std::deque<double, min_allocator<double>>, std::vector<int, min_allocator<int>>>;
+ using C =
+ std::flat_map<double,
+ int,
+ std::less<>,
+ std::deque<double, min_allocator<double>>,
+ std::vector<int, min_allocator<int>>>;
C m = {};
assert(m.size() == 0);
- m = {{3,0}, {1,0}, {2,0}, {2,1}, {3,1}, {4,0}, {3,2}, {5,0}, {6,0}, {5,1}};
- std::pair<double, int> expected[] = {{1,0}, {2,0}, {3,0}, {4,0}, {5,0}, {6,0}};
+ m = {{3, 0}, {1, 0}, {2, 0}, {2, 1}, {3, 1}, {4, 0}, {3, 2}, {5, 0}, {6, 0}, {5, 1}};
+ std::pair<double, int> expected[] = {{1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}};
assert(std::ranges::equal(m.keys(), expected | std::views::elements<0>));
LIBCPP_ASSERT(std::ranges::equal(m, expected));
}
{
using C = std::flat_map<double, double, std::less<>, std::deque<double>, std::deque<double>>;
- C m = {{10,1}, {8,1}};
+ C m = {{10, 1}, {8, 1}};
assert(m.size() == 2);
- m = {{3,2}};
- std::pair<double, double> expected[] = {{3,2}};
+ m = {{3, 2}};
+ std::pair<double, double> expected[] = {{3, 2}};
assert(std::ranges::equal(m, expected));
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/compare.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/compare.pass.cpp
index 445095742b..9cce469782 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/compare.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/compare.pass.cpp
@@ -25,11 +25,10 @@
#include "../../../test_compare.h"
#include "test_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
using C = test_less<int>;
- auto m = std::flat_map<int, char*, C>(C(3));
+ auto m = std::flat_map<int, char*, C>(C(3));
assert(m.empty());
assert(m.begin() == m.end());
assert(m.key_comp() == C(3));
@@ -44,10 +43,10 @@ int main(int, char**)
static_assert(!std::is_convertible_v<std::less<int>, std::flat_map<int, char*>>);
}
{
- using C = test_less<int>;
+ using C = test_less<int>;
using A1 = test_allocator<int>;
using A2 = test_allocator<short>;
- auto m = std::flat_map<int, short, C, std::vector<int, A1>, std::vector<short, A2>>(C(4), A1(5));
+ auto m = std::flat_map<int, short, C, std::vector<int, A1>, std::vector<short, A2>>(C(4), A1(5));
assert(m.empty());
assert(m.begin() == m.end());
assert(m.key_comp() == C(4));
@@ -55,10 +54,10 @@ int main(int, char**)
assert(m.values().get_allocator() == A2(5));
}
{
- using C = test_less<int>;
- using A1 = test_allocator<int>;
- using A2 = test_allocator<short>;
- std::flat_map<int, short, C, std::deque<int, A1>, std::deque<short, A2>> m = { C(4), A1(5) }; // implicit ctor
+ using C = test_less<int>;
+ using A1 = test_allocator<int>;
+ using A2 = test_allocator<short>;
+ std::flat_map<int, short, C, std::deque<int, A1>, std::deque<short, A2>> m = {C(4), A1(5)}; // implicit ctor
assert(m.empty());
assert(m.begin() == m.end());
assert(m.key_comp() == C(4));
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/containers.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/containers.pass.cpp
index 0c8d414c9d..70b99b33b8 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/containers.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/containers.pass.cpp
@@ -32,33 +32,32 @@
struct P {
int first;
int second;
- template<class T, class U>
+ template <class T, class U>
bool operator==(const std::pair<T, U>& rhs) const {
return MoveOnly(first) == rhs.first && MoveOnly(second) == rhs.second;
}
};
-int main(int, char**)
-{
+int main(int, char**) {
{
- using M = std::flat_map<int, char>;
- std::vector<int> ks = {1,1,1,2,2,3,2,3,3};
- std::vector<char> vs = {1,2,3,4,5,6,7,8,9};
- auto m = M(ks, vs);
- assert((m.keys() == std::vector<int>{1,2,3}));
- LIBCPP_ASSERT((m.values() == std::vector<char>{1,4,6}));
+ using M = std::flat_map<int, char>;
+ std::vector<int> ks = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+ std::vector<char> vs = {1, 2, 3, 4, 5, 6, 7, 8, 9};
+ auto m = M(ks, vs);
+ assert((m.keys() == std::vector<int>{1, 2, 3}));
+ LIBCPP_ASSERT((m.values() == std::vector<char>{1, 4, 6}));
m = M(std::move(ks), std::move(vs));
assert(ks.empty()); // it was moved-from
assert(vs.empty()); // it was moved-from
- assert((m.keys() == std::vector<int>{1,2,3}));
- LIBCPP_ASSERT((m.values() == std::vector<char>{1,4,6}));
+ assert((m.keys() == std::vector<int>{1, 2, 3}));
+ LIBCPP_ASSERT((m.values() == std::vector<char>{1, 4, 6}));
}
{
- P expected[] = {{3,2}, {2,1}, {1,3}};
- using Ks = std::deque<int, min_allocator<int>>;
- using Vs = std::vector<MoveOnly, min_allocator<MoveOnly>>;
- using M = std::flat_map<int, MoveOnly, std::greater<int>, Ks, Vs>;
- Ks ks = {1,3,2};
+ P expected[] = {{3, 2}, {2, 1}, {1, 3}};
+ using Ks = std::deque<int, min_allocator<int>>;
+ using Vs = std::vector<MoveOnly, min_allocator<MoveOnly>>;
+ using M = std::flat_map<int, MoveOnly, std::greater<int>, Ks, Vs>;
+ Ks ks = {1, 3, 2};
Vs vs;
vs.push_back(3);
vs.push_back(2);
@@ -71,36 +70,36 @@ int main(int, char**)
{
using A = test_allocator<int>;
using M = std::flat_map<int, int, std::less<int>, std::vector<int, A>, std::deque<int, A>>;
- auto ks = std::vector<int, A>({1,1,1,2,2,3,2,3,3}, A(5));
- auto vs = std::deque<int, A>({1,1,1,2,2,3,2,3,3}, A(6));
- auto m = M(std::move(ks), std::move(vs));
+ auto ks = std::vector<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(5));
+ auto vs = std::deque<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(6));
+ auto m = M(std::move(ks), std::move(vs));
assert(ks.empty()); // it was moved-from
assert(vs.empty()); // it was moved-from
- assert((m == M{{1,1}, {2,2}, {3,3}}));
+ assert((m == M{{1, 1}, {2, 2}, {3, 3}}));
assert(m.keys().get_allocator() == A(5));
assert(m.values().get_allocator() == A(6));
}
{
using A = test_allocator<int>;
using M = std::flat_map<int, int, std::less<int>, std::vector<int, A>, std::deque<int, A>>;
- auto ks = std::vector<int, A>({1,1,1,2,2,3,2,3,3}, A(5));
- auto vs = std::deque<int, A>({1,1,1,2,2,3,2,3,3}, A(6));
- auto m = M(ks, vs, A(4)); // replaces the allocators
- assert(!ks.empty()); // it was an lvalue above
- assert(!vs.empty()); // it was an lvalue above
- assert((m == M{{1,1}, {2,2}, {3,3}}));
+ auto ks = std::vector<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(5));
+ auto vs = std::deque<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(6));
+ auto m = M(ks, vs, A(4)); // replaces the allocators
+ assert(!ks.empty()); // it was an lvalue above
+ assert(!vs.empty()); // it was an lvalue above
+ assert((m == M{{1, 1}, {2, 2}, {3, 3}}));
assert(m.keys().get_allocator() == A(4));
assert(m.values().get_allocator() == A(4));
}
{
using A = test_allocator<int>;
using M = std::flat_map<int, int, std::less<int>, std::vector<int, A>, std::deque<int, A>>;
- auto ks = std::vector<int, A>({1,1,1,2,2,3,2,3,3}, A(5));
- auto vs = std::deque<int, A>({1,1,1,2,2,3,2,3,3}, A(6));
- M m = { ks, vs, A(4) }; // implicit ctor
- assert(!ks.empty()); // it was an lvalue above
- assert(!vs.empty()); // it was an lvalue above
- assert((m == M{{1,1}, {2,2}, {3,3}}));
+ auto ks = std::vector<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(5));
+ auto vs = std::deque<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(6));
+ M m = {ks, vs, A(4)}; // implicit ctor
+ assert(!ks.empty()); // it was an lvalue above
+ assert(!vs.empty()); // it was an lvalue above
+ assert((m == M{{1, 1}, {2, 2}, {3, 3}}));
assert(m.keys().get_allocator() == A(4));
assert(m.values().get_allocator() == A(4));
}
@@ -108,14 +107,14 @@ int main(int, char**)
using M = std::flat_map<int, int, std::less<int>, std::pmr::vector<int>, std::pmr::vector<int>>;
std::pmr::monotonic_buffer_resource mr;
std::pmr::vector<M> vm(&mr);
- std::pmr::vector<int> ks = {1,1,1,2,2,3,2,3,3};
- std::pmr::vector<int> vs = {1,1,1,2,2,3,2,3,3};
+ std::pmr::vector<int> ks = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+ std::pmr::vector<int> vs = {1, 1, 1, 2, 2, 3, 2, 3, 3};
assert(ks.get_allocator().resource() != &mr);
assert(vs.get_allocator().resource() != &mr);
vm.emplace_back(ks, vs);
assert(ks.size() == 9); // ks' value is unchanged, since it was an lvalue above
assert(vs.size() == 9); // vs' value is unchanged, since it was an lvalue above
- assert((vm[0] == M{{1,1}, {2,2}, {3,3}}));
+ assert((vm[0] == M{{1, 1}, {2, 2}, {3, 3}}));
assert(vm[0].keys().get_allocator().resource() == &mr);
assert(vm[0].values().get_allocator().resource() == &mr);
}
@@ -123,14 +122,14 @@ int main(int, char**)
using M = std::flat_map<int, int, std::less<int>, std::pmr::vector<int>, std::pmr::vector<int>>;
std::pmr::monotonic_buffer_resource mr;
std::pmr::vector<M> vm(&mr);
- std::pmr::vector<int> ks = {1,1,1,2,2,3,2,3,3};
- std::pmr::vector<int> vs = {1,1,1,2,2,3,2,3,3};
+ std::pmr::vector<int> ks = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+ std::pmr::vector<int> vs = {1, 1, 1, 2, 2, 3, 2, 3, 3};
assert(ks.get_allocator().resource() != &mr);
assert(vs.get_allocator().resource() != &mr);
vm.emplace_back(std::move(ks), std::move(vs));
LIBCPP_ASSERT(ks.size() == 9); // ks' size is unchanged, since it uses a different allocator
LIBCPP_ASSERT(vs.size() == 9); // vs' size is unchanged, since it uses a different allocator
- assert((vm[0] == M{{1,1}, {2,2}, {3,3}}));
+ assert((vm[0] == M{{1, 1}, {2, 2}, {3, 3}}));
assert(vm[0].keys().get_allocator().resource() == &mr);
assert(vm[0].values().get_allocator().resource() == &mr);
}
@@ -223,6 +222,6 @@ int main(int, char**)
assert(vm[0].values().get_allocator().resource() == &mr);
}
}
- #endif
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/containers_compare.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/containers_compare.pass.cpp
index e26f016280..a48b5d2d67 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/containers_compare.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/containers_compare.pass.cpp
@@ -33,36 +33,35 @@
struct P {
int first;
int second;
- template<class T, class U>
+ template <class T, class U>
bool operator==(const std::pair<T, U>& rhs) const {
return MoveOnly(first) == rhs.first && MoveOnly(second) == rhs.second;
}
};
-int main(int, char**)
-{
+int main(int, char**) {
using C = test_less<int>;
{
- using M = std::flat_map<int, char, C>;
- std::vector<int> ks = {1,1,1,2,2,3,2,3,3};
- std::vector<char> vs = {1,2,3,4,5,6,7,8,9};
- auto m = M(ks, vs, C(2));
- assert((m.keys() == std::vector<int>{1,2,3}));
- LIBCPP_ASSERT((m.values() == std::vector<char>{1,4,6}));
+ using M = std::flat_map<int, char, C>;
+ std::vector<int> ks = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+ std::vector<char> vs = {1, 2, 3, 4, 5, 6, 7, 8, 9};
+ auto m = M(ks, vs, C(2));
+ assert((m.keys() == std::vector<int>{1, 2, 3}));
+ LIBCPP_ASSERT((m.values() == std::vector<char>{1, 4, 6}));
assert(m.key_comp() == C(2));
m = M(std::move(ks), std::move(vs), C(3));
assert(ks.empty()); // it was moved-from
assert(vs.empty()); // it was moved-from
- assert((m.keys() == std::vector<int>{1,2,3}));
- LIBCPP_ASSERT((m.values() == std::vector<char>{1,4,6}));
+ assert((m.keys() == std::vector<int>{1, 2, 3}));
+ LIBCPP_ASSERT((m.values() == std::vector<char>{1, 4, 6}));
assert(m.key_comp() == C(3));
}
{
- P expected[] = {{1,3}, {2,1}, {3,2}};
- using Ks = std::deque<int, min_allocator<int>>;
- using Vs = std::vector<MoveOnly, min_allocator<MoveOnly>>;
- using M = std::flat_map<int, MoveOnly, C, Ks, Vs>;
- Ks ks = {1,3,2};
+ P expected[] = {{1, 3}, {2, 1}, {3, 2}};
+ using Ks = std::deque<int, min_allocator<int>>;
+ using Vs = std::vector<MoveOnly, min_allocator<MoveOnly>>;
+ using M = std::flat_map<int, MoveOnly, C, Ks, Vs>;
+ Ks ks = {1, 3, 2};
Vs vs;
vs.push_back(3);
vs.push_back(2);
@@ -76,12 +75,12 @@ int main(int, char**)
{
using A = test_allocator<int>;
using M = std::flat_map<int, int, C, std::vector<int, A>, std::deque<int, A>>;
- auto ks = std::vector<int, A>({1,1,1,2,2,3,2,3,3}, A(5));
- auto vs = std::deque<int, A>({1,1,1,2,2,3,2,3,3}, A(6));
- auto m = M(std::move(ks), std::move(vs), C(2));
+ auto ks = std::vector<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(5));
+ auto vs = std::deque<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(6));
+ auto m = M(std::move(ks), std::move(vs), C(2));
assert(ks.empty()); // it was moved-from
assert(vs.empty()); // it was moved-from
- assert((m == M{{1,1}, {2,2}, {3,3}}));
+ assert((m == M{{1, 1}, {2, 2}, {3, 3}}));
assert(m.key_comp() == C(2));
assert(m.keys().get_allocator() == A(5));
assert(m.values().get_allocator() == A(6));
@@ -89,12 +88,12 @@ int main(int, char**)
{
using A = test_allocator<int>;
using M = std::flat_map<int, int, C, std::vector<int, A>, std::deque<int, A>>;
- auto ks = std::vector<int, A>({1,1,1,2,2,3,2,3,3}, A(5));
- auto vs = std::deque<int, A>({1,1,1,2,2,3,2,3,3}, A(6));
- auto m = M(ks, vs, C(2), A(4)); // replaces the allocators
- assert(!ks.empty()); // it was an lvalue above
- assert(!vs.empty()); // it was an lvalue above
- assert((m == M{{1,1}, {2,2}, {3,3}}));
+ auto ks = std::vector<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(5));
+ auto vs = std::deque<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(6));
+ auto m = M(ks, vs, C(2), A(4)); // replaces the allocators
+ assert(!ks.empty()); // it was an lvalue above
+ assert(!vs.empty()); // it was an lvalue above
+ assert((m == M{{1, 1}, {2, 2}, {3, 3}}));
assert(m.key_comp() == C(2));
assert(m.keys().get_allocator() == A(4));
assert(m.values().get_allocator() == A(4));
@@ -102,12 +101,12 @@ int main(int, char**)
{
using A = test_allocator<int>;
using M = std::flat_map<int, int, C, std::vector<int, A>, std::deque<int, A>>;
- auto ks = std::vector<int, A>({1,1,1,2,2,3,2,3,3}, A(5));
- auto vs = std::deque<int, A>({1,1,1,2,2,3,2,3,3}, A(6));
- M m = { ks, vs, C(2), A(4) }; // implicit ctor
- assert(!ks.empty()); // it was an lvalue above
- assert(!vs.empty()); // it was an lvalue above
- assert((m == M{{1,1}, {2,2}, {3,3}}));
+ auto ks = std::vector<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(5));
+ auto vs = std::deque<int, A>({1, 1, 1, 2, 2, 3, 2, 3, 3}, A(6));
+ M m = {ks, vs, C(2), A(4)}; // implicit ctor
+ assert(!ks.empty()); // it was an lvalue above
+ assert(!vs.empty()); // it was an lvalue above
+ assert((m == M{{1, 1}, {2, 2}, {3, 3}}));
assert(m.key_comp() == C(2));
assert(m.keys().get_allocator() == A(4));
assert(m.values().get_allocator() == A(4));
@@ -116,14 +115,14 @@ int main(int, char**)
using M = std::flat_map<int, int, C, std::pmr::vector<int>, std::pmr::vector<int>>;
std::pmr::monotonic_buffer_resource mr;
std::pmr::vector<M> vm(&mr);
- std::pmr::vector<int> ks = {1,1,1,2,2,3,2,3,3};
- std::pmr::vector<int> vs = {1,1,1,2,2,3,2,3,3};
+ std::pmr::vector<int> ks = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+ std::pmr::vector<int> vs = {1, 1, 1, 2, 2, 3, 2, 3, 3};
assert(ks.get_allocator().resource() != &mr);
assert(vs.get_allocator().resource() != &mr);
vm.emplace_back(ks, vs, C(2));
assert(ks.size() == 9); // ks' value is unchanged, since it was an lvalue above
assert(vs.size() == 9); // vs' value is unchanged, since it was an lvalue above
- assert((vm[0] == M{{1,1}, {2,2}, {3,3}}));
+ assert((vm[0] == M{{1, 1}, {2, 2}, {3, 3}}));
assert(vm[0].key_comp() == C(2));
assert(vm[0].keys().get_allocator().resource() == &mr);
assert(vm[0].values().get_allocator().resource() == &mr);
@@ -132,14 +131,14 @@ int main(int, char**)
using M = std::flat_map<int, int, C, std::pmr::vector<int>, std::pmr::vector<int>>;
std::pmr::monotonic_buffer_resource mr;
std::pmr::vector<M> vm(&mr);
- std::pmr::vector<int> ks = {1,1,1,2,2,3,2,3,3};
- std::pmr::vector<int> vs = {1,1,1,2,2,3,2,3,3};
+ std::pmr::vector<int> ks = {1, 1, 1, 2, 2, 3, 2, 3, 3};
+ std::pmr::vector<int> vs = {1, 1, 1, 2, 2, 3, 2, 3, 3};
assert(ks.get_allocator().resource() != &mr);
assert(vs.get_allocator().resource() != &mr);
vm.emplace_back(std::move(ks), std::move(vs), C(2));
LIBCPP_ASSERT(ks.size() == 9); // ks' size is unchanged, since it uses a different allocator
LIBCPP_ASSERT(vs.size() == 9); // vs' size is unchanged, since it uses a different allocator
- assert((vm[0] == M{{1,1}, {2,2}, {3,3}}));
+ assert((vm[0] == M{{1, 1}, {2, 2}, {3, 3}}));
assert(vm[0].key_comp() == C(2));
assert(vm[0].keys().get_allocator().resource() == &mr);
assert(vm[0].values().get_allocator().resource() == &mr);
@@ -241,6 +240,6 @@ int main(int, char**)
assert(vm[0].values().get_allocator().resource() == &mr);
}
}
- #endif
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy.pass.cpp
index bc1d713abb..a09e10e63b 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy.pass.cpp
@@ -21,15 +21,14 @@
#include "../../../test_compare.h"
#include "test_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
using C = test_less<int>;
std::vector<int, test_allocator<int>> ks({1, 3, 5}, test_allocator<int>(6));
std::vector<char, test_allocator<char>> vs({2, 2, 1}, test_allocator<char>(7));
using M = std::flat_map<int, char, C, decltype(ks), decltype(vs)>;
auto mo = M(ks, vs, C(5));
- auto m = mo;
+ auto m = mo;
assert(m.key_comp() == C(5));
assert(m.keys() == ks);
@@ -45,14 +44,14 @@ int main(int, char**)
assert(mo.values().get_allocator() == test_allocator<char>(7));
}
{
- using C = test_less<int>;
+ using C = test_less<int>;
using Ks = std::vector<int, other_allocator<int>>;
using Vs = std::vector<char, other_allocator<char>>;
- auto ks = Ks({1, 3, 5}, other_allocator<int>(6));
- auto vs = Vs({2, 2, 1}, other_allocator<char>(7));
- using M = std::flat_map<int, char, C, Ks, Vs>;
- auto mo = M(Ks(ks, other_allocator<int>(6)), Vs(vs, other_allocator<int>(7)), C(5));
- auto m = mo;
+ auto ks = Ks({1, 3, 5}, other_allocator<int>(6));
+ auto vs = Vs({2, 2, 1}, other_allocator<char>(7));
+ using M = std::flat_map<int, char, C, Ks, Vs>;
+ auto mo = M(Ks(ks, other_allocator<int>(6)), Vs(vs, other_allocator<int>(7)), C(5));
+ auto m = mo;
assert(m.key_comp() == C(5));
assert(m.keys() == ks);
@@ -71,18 +70,18 @@ int main(int, char**)
using C = test_less<int>;
std::pmr::monotonic_buffer_resource mr;
using M = std::flat_map<int, int, C, std::pmr::vector<int>, std::pmr::vector<int>>;
- auto mo = M({{1,1}, {2,2}, {3,3}}, C(5), &mr);
- auto m = mo;
+ auto mo = M({{1, 1}, {2, 2}, {3, 3}}, C(5), &mr);
+ auto m = mo;
assert(m.key_comp() == C(5));
- assert((m == M{{1,1}, {2,2}, {3,3}}));
+ assert((m == M{{1, 1}, {2, 2}, {3, 3}}));
auto [ks, vs] = std::move(m).extract();
assert(ks.get_allocator().resource() == std::pmr::get_default_resource());
assert(vs.get_allocator().resource() == std::pmr::get_default_resource());
// mo is unchanged
assert(mo.key_comp() == C(5));
- assert((mo == M{{1,1}, {2,2}, {3,3}}));
+ assert((mo == M{{1, 1}, {2, 2}, {3, 3}}));
auto [kso, vso] = std::move(mo).extract();
assert(kso.get_allocator().resource() == &mr);
assert(vso.get_allocator().resource() == &mr);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_alloc.pass.cpp
index a7ff983a22..91204f1688 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_alloc.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_alloc.pass.cpp
@@ -23,15 +23,14 @@
#include "../../../test_compare.h"
#include "test_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
using C = test_less<int>;
std::vector<int, test_allocator<int>> ks({1, 3, 5}, test_allocator<int>(6));
std::vector<char, test_allocator<char>> vs({2, 2, 1}, test_allocator<char>(7));
using M = std::flat_map<int, char, C, decltype(ks), decltype(vs)>;
auto mo = M(ks, vs, C(5));
- auto m = M(mo, test_allocator<int>(3));
+ auto m = M(mo, test_allocator<int>(3));
assert(m.key_comp() == C(5));
assert(m.keys() == ks);
@@ -51,26 +50,26 @@ int main(int, char**)
using M = std::flat_map<int, int, C, std::pmr::vector<int>, std::pmr::vector<int>>;
std::pmr::monotonic_buffer_resource mr1;
std::pmr::monotonic_buffer_resource mr2;
- M mo = M({1,2,3}, {2,2,1}, C(5), &mr1);
- M m = {mo, &mr2}; // also test the implicitness of this constructor
+ M mo = M({1, 2, 3}, {2, 2, 1}, C(5), &mr1);
+ M m = {mo, &mr2}; // also test the implicitness of this constructor
assert(m.key_comp() == C(5));
- assert((m.keys() == std::pmr::vector<int>{1,2,3}));
- assert((m.values() == std::pmr::vector<int>{2,2,1}));
+ assert((m.keys() == std::pmr::vector<int>{1, 2, 3}));
+ assert((m.values() == std::pmr::vector<int>{2, 2, 1}));
assert(m.keys().get_allocator().resource() == &mr2);
assert(m.values().get_allocator().resource() == &mr2);
// mo is unchanged
assert(mo.key_comp() == C(5));
- assert((mo.keys() == std::pmr::vector<int>{1,2,3}));
- assert((mo.values() == std::pmr::vector<int>{2,2,1}));
+ assert((mo.keys() == std::pmr::vector<int>{1, 2, 3}));
+ assert((mo.values() == std::pmr::vector<int>{2, 2, 1}));
assert(mo.keys().get_allocator().resource() == &mr1);
assert(mo.values().get_allocator().resource() == &mr1);
}
{
using M = std::flat_map<int, int, std::less<>, std::pmr::vector<int>, std::pmr::deque<int>>;
std::pmr::vector<M> vs;
- M m = {{1,2}, {2,2}, {3,1}};
+ M m = {{1, 2}, {2, 2}, {3, 1}};
vs.push_back(m);
assert(vs[0] == m);
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_assign.pass.cpp
index 9b78fbd7a7..4f429bdc20 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_assign.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/copy_assign.pass.cpp
@@ -22,8 +22,7 @@
#include "../../../test_compare.h"
#include "test_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
// test_allocator is not propagated
using C = test_less<int>;
@@ -31,8 +30,8 @@ int main(int, char**)
std::vector<char, test_allocator<char>> vs({2, 2, 1}, test_allocator<char>(7));
using M = std::flat_map<int, char, C, decltype(ks), decltype(vs)>;
auto mo = M(ks, vs, C(5));
- auto m = M({{3,3}, {4,4}, {5,5}}, C(3), test_allocator<int>(2));
- m = mo;
+ auto m = M({{3, 3}, {4, 4}, {5, 5}}, C(3), test_allocator<int>(2));
+ m = mo;
assert(m.key_comp() == C(5));
assert(m.keys() == ks);
@@ -49,15 +48,15 @@ int main(int, char**)
}
{
// other_allocator is propagated
- using C = test_less<int>;
+ using C = test_less<int>;
using Ks = std::vector<int, other_allocator<int>>;
using Vs = std::vector<char, other_allocator<char>>;
- auto ks = Ks({1, 3, 5}, other_allocator<int>(6));
- auto vs = Vs({2, 2, 1}, other_allocator<char>(7));
- using M = std::flat_map<int, char, C, Ks, Vs>;
- auto mo = M(Ks(ks, other_allocator<int>(6)), Vs(vs, other_allocator<int>(7)), C(5));
- auto m = M({{3,3}, {4,4}, {5,5}}, C(3), other_allocator<int>(2));
- m = mo;
+ auto ks = Ks({1, 3, 5}, other_allocator<int>(6));
+ auto vs = Vs({2, 2, 1}, other_allocator<char>(7));
+ using M = std::flat_map<int, char, C, Ks, Vs>;
+ auto mo = M(Ks(ks, other_allocator<int>(6)), Vs(vs, other_allocator<int>(7)), C(5));
+ auto m = M({{3, 3}, {4, 4}, {5, 5}}, C(3), other_allocator<int>(2));
+ m = mo;
assert(m.key_comp() == C(5));
assert(m.keys() == ks);
@@ -77,22 +76,22 @@ int main(int, char**)
using M = std::flat_map<int, int, std::less<>, std::pmr::deque<int>, std::pmr::vector<int>>;
std::pmr::monotonic_buffer_resource mr1;
std::pmr::monotonic_buffer_resource mr2;
- M mo = M({{1,1}, {2,2}, {3,3}}, &mr1);
- M m = M({{4,4}, {5,5}}, &mr2);
- m = mo;
- assert((m == M{{1,1}, {2,2}, {3,3}}));
+ M mo = M({{1, 1}, {2, 2}, {3, 3}}, &mr1);
+ M m = M({{4, 4}, {5, 5}}, &mr2);
+ m = mo;
+ assert((m == M{{1, 1}, {2, 2}, {3, 3}}));
assert(m.keys().get_allocator().resource() == &mr2);
assert(m.values().get_allocator().resource() == &mr2);
// mo is unchanged
- assert((mo == M{{1,1}, {2,2}, {3,3}}));
+ assert((mo == M{{1, 1}, {2, 2}, {3, 3}}));
assert(mo.keys().get_allocator().resource() == &mr1);
}
{
// comparator is copied and invariant is preserved
using M = std::flat_map<int, int, std::function<bool(int, int)>>;
- M mo = M({{1,2}, {3,4}}, std::less<int>());
- M m = M({{1,2}, {3,4}}, std::greater<int>());
+ M mo = M({{1, 2}, {3, 4}}, std::less<int>());
+ M m = M({{1, 2}, {3, 4}}, std::greater<int>());
assert(m.key_comp()(2, 1) == true);
assert(m != mo);
m = mo;
@@ -102,9 +101,9 @@ int main(int, char**)
{
// self-assignment
using M = std::flat_map<int, int>;
- M m = {{1,2}, {3,4}};
- m = static_cast<const M&>(m);
- assert((m == M{{1,2}, {3,4}}));
+ M m = {{1, 2}, {3, 4}};
+ m = static_cast<const M&>(m);
+ assert((m == M{{1, 2}, {3, 4}}));
}
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct.pass.cpp
index 56558bdf2e..af15889a8c 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct.pass.cpp
@@ -27,24 +27,24 @@
#include "deduction_guides_sfinae_checks.h"
#include "test_allocator.h"
-using P = std::pair<int, long>;
+using P = std::pair<int, long>;
using PC = std::pair<const int, long>;
void test_copy() {
{
- std::flat_map<long, short> source = {{1,2}, {2,3}};
+ std::flat_map<long, short> source = {{1, 2}, {2, 3}};
std::flat_map s(source);
ASSERT_SAME_TYPE(decltype(s), decltype(source));
assert(s == source);
}
{
- std::flat_map<long, short, std::greater<long>> source = {{1,2}, {2,3}};
- std::flat_map s{ source }; // braces instead of parens
+ std::flat_map<long, short, std::greater<long>> source = {{1, 2}, {2, 3}};
+ std::flat_map s{source}; // braces instead of parens
ASSERT_SAME_TYPE(decltype(s), decltype(source));
assert(s == source);
}
{
- std::flat_map<long, short, std::greater<long>> source = {{1,2}, {2,3}};
+ std::flat_map<long, short, std::greater<long>> source = {{1, 2}, {2, 3}};
std::flat_map s(source, std::allocator<int>());
ASSERT_SAME_TYPE(decltype(s), decltype(source));
assert(s == source);
@@ -52,13 +52,11 @@ void test_copy() {
}
void test_containers() {
- std::deque<int, test_allocator<int>> ks({ 1, 2, 1, INT_MAX, 3 }, test_allocator<int>(0, 42));
- std::deque<short, test_allocator<short>> vs({ 1, 2, 1, 4, 5 }, test_allocator<int>(0, 43));
- std::deque<int, test_allocator<int>> sorted_ks({ 1, 2, 3, INT_MAX }, test_allocator<int>(0, 42));
- std::deque<short, test_allocator<short>> sorted_vs({ 1, 2, 5, 4 }, test_allocator<int>(0, 43));
- const std::pair<int, short> expected[] = {
- {1, 1}, {2, 2}, {3, 5}, {INT_MAX, 4}
- };
+ std::deque<int, test_allocator<int>> ks({1, 2, 1, INT_MAX, 3}, test_allocator<int>(0, 42));
+ std::deque<short, test_allocator<short>> vs({1, 2, 1, 4, 5}, test_allocator<int>(0, 43));
+ std::deque<int, test_allocator<int>> sorted_ks({1, 2, 3, INT_MAX}, test_allocator<int>(0, 42));
+ std::deque<short, test_allocator<short>> sorted_vs({1, 2, 5, 4}, test_allocator<int>(0, 43));
+ const std::pair<int, short> expected[] = {{1, 1}, {2, 2}, {3, 5}, {INT_MAX, 4}};
{
std::flat_map s(ks, vs);
@@ -98,7 +96,8 @@ void test_containers() {
std::pmr::deque<short> pvs(vs.begin(), vs.end(), &mr);
std::flat_map s(std::move(pks), std::move(pvs), &mr2);
- ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::less<int>, std::pmr::deque<int>, std::pmr::deque<short>>);
+ ASSERT_SAME_TYPE(
+ decltype(s), std::flat_map<int, short, std::less<int>, std::pmr::deque<int>, std::pmr::deque<short>>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().resource() == &mr2);
assert(s.values().get_allocator().resource() == &mr2);
@@ -110,7 +109,8 @@ void test_containers() {
std::pmr::deque<short> pvs(sorted_vs.begin(), sorted_vs.end(), &mr);
std::flat_map s(std::sorted_unique, std::move(pks), std::move(pvs), &mr2);
- ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::less<int>, std::pmr::deque<int>, std::pmr::deque<short>>);
+ ASSERT_SAME_TYPE(
+ decltype(s), std::flat_map<int, short, std::less<int>, std::pmr::deque<int>, std::pmr::deque<short>>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().resource() == &mr2);
assert(s.values().get_allocator().resource() == &mr2);
@@ -118,13 +118,11 @@ void test_containers() {
}
void test_containers_compare() {
- std::deque<int, test_allocator<int>> ks({ 1, 2, 1, INT_MAX, 3 }, test_allocator<int>(0, 42));
- std::deque<short, test_allocator<short>> vs({ 1, 2, 1, 4, 5 }, test_allocator<int>(0, 43));
- std::deque<int, test_allocator<int>> sorted_ks({ INT_MAX, 3, 2, 1 }, test_allocator<int>(0, 42));
- std::deque<short, test_allocator<short>> sorted_vs({ 4, 5, 2, 1 }, test_allocator<int>(0, 43));
- const std::pair<int, short> expected[] = {
- {INT_MAX, 4}, {3, 5}, {2, 2}, {1, 1}
- };
+ std::deque<int, test_allocator<int>> ks({1, 2, 1, INT_MAX, 3}, test_allocator<int>(0, 42));
+ std::deque<short, test_allocator<short>> vs({1, 2, 1, 4, 5}, test_allocator<int>(0, 43));
+ std::deque<int, test_allocator<int>> sorted_ks({INT_MAX, 3, 2, 1}, test_allocator<int>(0, 42));
+ std::deque<short, test_allocator<short>> sorted_vs({4, 5, 2, 1}, test_allocator<int>(0, 43));
+ const std::pair<int, short> expected[] = {{INT_MAX, 4}, {3, 5}, {2, 2}, {1, 1}};
{
std::flat_map s(ks, vs, std::greater<int>());
@@ -164,7 +162,8 @@ void test_containers_compare() {
std::pmr::deque<short> pvs(vs.begin(), vs.end(), &mr);
std::flat_map s(std::move(pks), std::move(pvs), std::greater<int>(), &mr2);
- ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::greater<int>, std::pmr::deque<int>, std::pmr::deque<short>>);
+ ASSERT_SAME_TYPE(
+ decltype(s), std::flat_map<int, short, std::greater<int>, std::pmr::deque<int>, std::pmr::deque<short>>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().resource() == &mr2);
assert(s.values().get_allocator().resource() == &mr2);
@@ -176,7 +175,8 @@ void test_containers_compare() {
std::pmr::deque<short> pvs(sorted_vs.begin(), sorted_vs.end(), &mr);
std::flat_map s(std::sorted_unique, std::move(pks), std::move(pvs), std::greater<int>(), &mr2);
- ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::greater<int>, std::pmr::deque<int>, std::pmr::deque<short>>);
+ ASSERT_SAME_TYPE(
+ decltype(s), std::flat_map<int, short, std::greater<int>, std::pmr::deque<int>, std::pmr::deque<short>>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().resource() == &mr2);
assert(s.values().get_allocator().resource() == &mr2);
@@ -184,10 +184,10 @@ void test_containers_compare() {
}
void test_iter_iter() {
- const P arr[] = { {1,1L}, {2,2L}, {1,1L}, {INT_MAX,1L}, {3,1L} };
- const P sorted_arr[] = { {1,1L}, {2,2L}, {3,1L}, {INT_MAX,1L} };
- const PC arrc[] = { {1,1L}, {2,2L}, {1,1L}, {INT_MAX,1L}, {3,1L} };
- const PC sorted_arrc[] = { {1,1L}, {2,2L}, {3,1L}, {INT_MAX,1L} };
+ const P arr[] = {{1, 1L}, {2, 2L}, {1, 1L}, {INT_MAX, 1L}, {3, 1L}};
+ const P sorted_arr[] = {{1, 1L}, {2, 2L}, {3, 1L}, {INT_MAX, 1L}};
+ const PC arrc[] = {{1, 1L}, {2, 2L}, {1, 1L}, {INT_MAX, 1L}, {3, 1L}};
+ const PC sorted_arrc[] = {{1, 1L}, {2, 2L}, {3, 1L}, {INT_MAX, 1L}};
{
std::flat_map m(std::begin(arr), std::end(arr));
@@ -212,7 +212,7 @@ void test_iter_iter() {
ASSERT_SAME_TYPE(decltype(m), std::flat_map<int, long>);
assert(std::ranges::equal(m, sorted_arr));
}
- #if 0
+#if 0
{
std::flat_map m(std::begin(arr), std::end(arr), test_allocator<short>(0, 44));
@@ -245,7 +245,7 @@ void test_iter_iter() {
assert(m.keys().get_allocator().get_id() == 44);
assert(m.values().get_allocator().get_id() == 44);
}
- #endif
+#endif
{
std::flat_map<int, short> mo;
std::flat_map m(mo.begin(), mo.end());
@@ -259,11 +259,11 @@ void test_iter_iter() {
}
void test_iter_iter_compare() {
- const P arr[] = { {1,1L}, {2,2L}, {1,1L}, {INT_MAX,1L}, {3,1L} };
- const P sorted_arr[] = { {INT_MAX,1L}, {3,1L}, {2,2L}, {1,1L} };
- const PC arrc[] = { {1,1L}, {2,2L}, {1,1L}, {INT_MAX,1L}, {3,1L} };
- const PC sorted_arrc[] = { {INT_MAX,1L}, {3,1L}, {2,2L}, {1,1L} };
- using C = std::greater<long long>;
+ const P arr[] = {{1, 1L}, {2, 2L}, {1, 1L}, {INT_MAX, 1L}, {3, 1L}};
+ const P sorted_arr[] = {{INT_MAX, 1L}, {3, 1L}, {2, 2L}, {1, 1L}};
+ const PC arrc[] = {{1, 1L}, {2, 2L}, {1, 1L}, {INT_MAX, 1L}, {3, 1L}};
+ const PC sorted_arrc[] = {{INT_MAX, 1L}, {3, 1L}, {2, 2L}, {1, 1L}};
+ using C = std::greater<long long>;
{
std::flat_map m(std::begin(arr), std::end(arr), C());
@@ -288,7 +288,7 @@ void test_iter_iter_compare() {
ASSERT_SAME_TYPE(decltype(m), std::flat_map<int, long, C>);
assert(std::ranges::equal(m, sorted_arr));
}
- #if 0
+#if 0
{
std::flat_map m(std::begin(arr), std::end(arr), C(), test_allocator<short>(0, 44));
@@ -321,7 +321,7 @@ void test_iter_iter_compare() {
assert(m.keys().get_allocator().get_id() == 44);
assert(m.values().get_allocator().get_id() == 44);
}
- #endif
+#endif
{
std::flat_map<int, short> mo;
std::flat_map m(mo.begin(), mo.end(), C());
@@ -335,20 +335,20 @@ void test_iter_iter_compare() {
}
void test_initializer_list() {
- const P sorted_arr[] = { {1,1L}, {2,2L}, {3,1L}, {INT_MAX,1L} };
+ const P sorted_arr[] = {{1, 1L}, {2, 2L}, {3, 1L}, {INT_MAX, 1L}};
{
- std::flat_map m{ std::pair{1,1L}, {2,2L}, {1,1L}, {INT_MAX,1L}, {3,1L} };
+ std::flat_map m{std::pair{1, 1L}, {2, 2L}, {1, 1L}, {INT_MAX, 1L}, {3, 1L}};
ASSERT_SAME_TYPE(decltype(m), std::flat_map<int, long>);
assert(std::ranges::equal(m, sorted_arr));
}
{
- std::flat_map m(std::sorted_unique, { std::pair{1,1L}, {2,2L}, {3,1L}, {INT_MAX,1L} });
+ std::flat_map m(std::sorted_unique, {std::pair{1, 1L}, {2, 2L}, {3, 1L}, {INT_MAX, 1L}});
ASSERT_SAME_TYPE(decltype(m), std::flat_map<int, long>);
assert(std::ranges::equal(m, sorted_arr));
}
- #if 0
+#if 0
{
std::flat_map m({ std::pair{1,1L}, {2,2L}, {1,1L}, {INT_MAX,1L}, {3,1L} }, test_allocator<long>(0, 42));
@@ -365,25 +365,25 @@ void test_initializer_list() {
assert(m.keys().get_allocator().get_id() == 42);
assert(m.values().get_allocator().get_id() == 42);
}
- #endif
+#endif
}
void test_initializer_list_compare() {
- const P sorted_arr[] = { {INT_MAX,1L}, {3,1L}, {2,2L}, {1,1L} };
- using C = std::greater<long long>;
+ const P sorted_arr[] = {{INT_MAX, 1L}, {3, 1L}, {2, 2L}, {1, 1L}};
+ using C = std::greater<long long>;
{
- std::flat_map m({ std::pair{1,1L}, {2,2L}, {1,1L}, {INT_MAX,1L}, {3,1L} }, C());
+ std::flat_map m({std::pair{1, 1L}, {2, 2L}, {1, 1L}, {INT_MAX, 1L}, {3, 1L}}, C());
ASSERT_SAME_TYPE(decltype(m), std::flat_map<int, long, C>);
assert(std::ranges::equal(m, sorted_arr));
}
{
- std::flat_map m(std::sorted_unique, { std::pair{INT_MAX,1L}, {3,1L}, {2,2L}, {1,1L} }, C());
+ std::flat_map m(std::sorted_unique, {std::pair{INT_MAX, 1L}, {3, 1L}, {2, 2L}, {1, 1L}}, C());
ASSERT_SAME_TYPE(decltype(m), std::flat_map<int, long, C>);
assert(std::ranges::equal(m, sorted_arr));
}
- #if 0
+#if 0
{
std::flat_map m({ std::pair{1,1L}, {2,2L}, {1,1L}, {INT_MAX,1L}, {3,1L} }, C(), test_allocator<long>(0, 42));
@@ -400,12 +400,12 @@ void test_initializer_list_compare() {
assert(m.keys().get_allocator().get_id() == 42);
assert(m.values().get_allocator().get_id() == 42);
}
- #endif
+#endif
}
void test_from_range() {
- std::list<std::pair<int, short>> r = { {1,1}, {2,2}, {1,1}, {INT_MAX,4}, {3,5} };
- const std::pair<int, short> expected[] = { {1,1}, {2,2}, {3,5}, {INT_MAX,4} };
+ std::list<std::pair<int, short>> r = {{1, 1}, {2, 2}, {1, 1}, {INT_MAX, 4}, {3, 5}};
+ const std::pair<int, short> expected[] = {{1, 1}, {2, 2}, {3, 5}, {INT_MAX, 4}};
{
std::flat_map s(std::from_range, r);
ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::less<int>>);
@@ -413,7 +413,13 @@ void test_from_range() {
}
{
std::flat_map s(std::from_range, r, test_allocator<long>(0, 42));
- ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::less<int>, std::vector<int, test_allocator<int>>, std::vector<short, test_allocator<short>>>);
+ ASSERT_SAME_TYPE(
+ decltype(s),
+ std::flat_map<int,
+ short,
+ std::less<int>,
+ std::vector<int, test_allocator<int>>,
+ std::vector<short, test_allocator<short>>>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().get_id() == 42);
assert(s.values().get_allocator().get_id() == 42);
@@ -421,8 +427,8 @@ void test_from_range() {
}
void test_from_range_compare() {
- std::list<std::pair<int, short>> r = { {1,1}, {2,2}, {1,1}, {INT_MAX,4}, {3,5} };
- const std::pair<int, short> expected[] = { {INT_MAX,4}, {3,5}, {2,2}, {1,1} };
+ std::list<std::pair<int, short>> r = {{1, 1}, {2, 2}, {1, 1}, {INT_MAX, 4}, {3, 5}};
+ const std::pair<int, short> expected[] = {{INT_MAX, 4}, {3, 5}, {2, 2}, {1, 1}};
{
std::flat_map s(std::from_range, r, std::greater<int>());
ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::greater<int>>);
@@ -430,15 +436,20 @@ void test_from_range_compare() {
}
{
std::flat_map s(std::from_range, r, std::greater<int>(), test_allocator<long>(0, 42));
- ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::greater<int>, std::vector<int, test_allocator<int>>, std::vector<short, test_allocator<short>>>);
+ ASSERT_SAME_TYPE(
+ decltype(s),
+ std::flat_map<int,
+ short,
+ std::greater<int>,
+ std::vector<int, test_allocator<int>>,
+ std::vector<short, test_allocator<short>>>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().get_id() == 42);
assert(s.values().get_allocator().get_id() == 42);
}
}
-int main(int, char **)
-{
+int main(int, char**) {
// Each test function also tests the sorted_unique-prefixed and allocator-suffixed overloads.
test_copy();
test_containers();
@@ -453,34 +464,34 @@ int main(int, char **)
AssociativeContainerDeductionGuidesSfinaeAway<std::flat_map, std::flat_map<int, short>>();
{
- std::flat_map s = { std::make_pair(1, 'a') }; // flat_map(initializer_list<pair<int, char>>)
+ std::flat_map s = {std::make_pair(1, 'a')}; // flat_map(initializer_list<pair<int, char>>)
ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, char>);
assert(s.size() == 1);
}
{
using M = std::flat_map<int, short>;
M m;
- std::flat_map s = { std::make_pair(m, m) }; // flat_map(initializer_list<pair<M, M>>)
+ std::flat_map s = {std::make_pair(m, m)}; // flat_map(initializer_list<pair<M, M>>)
ASSERT_SAME_TYPE(decltype(s), std::flat_map<M, M>);
assert(s.size() == 1);
assert(s[m] == m);
}
{
- std::pair<int, int> source[3] = { {1,1}, {2,2}, {3,3} };
- std::flat_map s = { source, source + 3 }; // flat_map(InputIterator, InputIterator)
+ std::pair<int, int> source[3] = {{1, 1}, {2, 2}, {3, 3}};
+ std::flat_map s = {source, source + 3}; // flat_map(InputIterator, InputIterator)
ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, int>);
assert(s.size() == 3);
}
{
- std::pair<int, int> source[3] = { {1,1}, {2,2}, {3,3} };
- std::flat_map s{ source, source + 3 }; // flat_map(InputIterator, InputIterator)
+ std::pair<int, int> source[3] = {{1, 1}, {2, 2}, {3, 3}};
+ std::flat_map s{source, source + 3}; // flat_map(InputIterator, InputIterator)
ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, int>);
assert(s.size() == 3);
}
{
- std::pair<int, int> source[3] = { {1,1}, {2,2}, {3,3} };
- std::flat_map s{ std::sorted_unique, source, source + 3 }; // flat_map(sorted_unique_t, InputIterator, InputIterator)
+ std::pair<int, int> source[3] = {{1, 1}, {2, 2}, {3, 3}};
+ std::flat_map s{std::sorted_unique, source, source + 3}; // flat_map(sorted_unique_t, InputIterator, InputIterator)
static_assert(std::is_same_v<decltype(s), std::flat_map<int, int>>);
assert(s.size() == 3);
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct.verify.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct.verify.cpp
index 1213279a8e..8da08a968b 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct.verify.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct.verify.cpp
@@ -22,7 +22,7 @@ struct NotAnAllocator {
friend bool operator<(NotAnAllocator, NotAnAllocator) { return false; }
};
-using P = std::pair<int, long>;
+using P = std::pair<int, long>;
using PC = std::pair<const int, long>;
void test() {
@@ -30,68 +30,68 @@ void test() {
// cannot deduce Key and T from just (KeyContainer), even if it's a container of pairs
std::vector<std::pair<int, int>> v;
std::flat_map s(v);
- // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
+ // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
}
{
// cannot deduce Key and T from just (KeyContainer, Allocator)
std::vector<int> v;
std::flat_map s(v, std::allocator<std::pair<const int, int>>());
- // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
+ // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
}
{
// cannot deduce Key and T from nothing
std::flat_map m;
- // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
+ // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
}
{
// cannot deduce Key and T from just (Compare)
std::flat_map m(std::less<int>{});
- // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
+ // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
}
{
// cannot deduce Key and T from just (Compare, Allocator)
std::flat_map m(std::less<int>{}, std::allocator<PC>{});
- // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
+ // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
}
{
// cannot deduce Key and T from just (Allocator)
std::flat_map m(std::allocator<PC>{});
- // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
+ // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
}
{
// cannot convert from some arbitrary unrelated type
NotAnAllocator a;
std::flat_map m(a);
- // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
+ // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
}
{
// cannot deduce that the inner braced things should be std::pair and not something else
- std::flat_map m{ {1,1L}, {2,2L}, {3,3L} };
- // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
+ std::flat_map m{{1, 1L}, {2, 2L}, {3, 3L}};
+ // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
}
{
// cannot deduce that the inner braced things should be std::pair and not something else
- std::flat_map m({ {1,1L}, {2,2L}, {3,3L} }, std::less<int>());
- // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
+ std::flat_map m({{1, 1L}, {2, 2L}, {3, 3L}}, std::less<int>());
+ // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
}
{
// cannot deduce that the inner braced things should be std::pair and not something else
- std::flat_map m({ {1,1L}, {2,2L}, {3,3L} }, std::less<int>(), std::allocator<PC>());
- // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
+ std::flat_map m({{1, 1L}, {2, 2L}, {3, 3L}}, std::less<int>(), std::allocator<PC>());
+ // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
}
{
// cannot deduce that the inner braced things should be std::pair and not something else
- std::flat_map m({ {1,1L}, {2,2L}, {3,3L} }, std::allocator<PC>());
- // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
+ std::flat_map m({{1, 1L}, {2, 2L}, {3, 3L}}, std::allocator<PC>());
+ // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
}
{
// since we have parens, not braces, this deliberately does not find the initializer_list constructor
- std::flat_map m(P{1,1L});
- // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
+ std::flat_map m(P{1, 1L});
+ // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
}
{
// since we have parens, not braces, this deliberately does not find the initializer_list constructor
- std::flat_map m(PC{1,1L});
- // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
+ std::flat_map m(PC{1, 1L});
+ // expected-error at -1{{no viable constructor or deduction guide for deduction of template arguments of 'std::flat_map'}}
}
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/default.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/default.pass.cpp
index 4d39c094f1..8841571d6b 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/default.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/default.pass.cpp
@@ -29,8 +29,7 @@ struct DefaultCtableComp {
bool default_constructed_ = false;
};
-int main(int, char**)
-{
+int main(int, char**) {
{
std::flat_map<int, char*> m;
assert(m.empty());
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/default_noexcept.pass.cpp
index 2b920cd28c..ac24c8a8ac 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/default_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/default_noexcept.pass.cpp
@@ -28,12 +28,11 @@
#include "test_allocator.h"
struct ThrowingCtorComp {
- ThrowingCtorComp() noexcept(false) {}
- bool operator()(const auto&, const auto&) const { return false; }
+ ThrowingCtorComp() noexcept(false) {}
+ bool operator()(const auto&, const auto&) const { return false; }
};
-int main(int, char**)
-{
+int main(int, char**) {
#if defined(_LIBCPP_VERSION)
{
using C = std::flat_map<MoveOnly, MoveOnly>;
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/dtor_noexcept.pass.cpp
index 43f9dcedfd..e3ab33a55d 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/dtor_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/dtor_noexcept.pass.cpp
@@ -27,8 +27,7 @@ struct ThrowingDtorComp {
~ThrowingDtorComp() noexcept(false);
};
-int main(int, char**)
-{
+int main(int, char**) {
{
using C = std::flat_map<MoveOnly, MoveOnly>;
static_assert(std::is_nothrow_destructible_v<C>);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/initializer_list.pass.cpp
index 8e62164be7..4a5a16e305 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/initializer_list.pass.cpp
@@ -30,36 +30,36 @@ struct DefaultCtableComp {
bool default_constructed_ = false;
};
-int main(int, char**)
-{
- std::pair<int, short> expected[] = {{1,1}, {2,2}, {3,3}, {5,2}};
+int main(int, char**) {
+ std::pair<int, short> expected[] = {{1, 1}, {2, 2}, {3, 3}, {5, 2}};
{
using M = std::flat_map<int, short>;
- M m = {{5,2}, {2,2}, {2,2}, {3,3}, {1,1}, {3,3}};
- assert(std::equal(m.begin(), m.end(), expected, expected+4));
+ M m = {{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}};
+ assert(std::equal(m.begin(), m.end(), expected, expected + 4));
}
{
using M = std::flat_map<int, short, std::greater<int>, std::deque<int, min_allocator<int>>>;
- M m = {{5,2}, {2,2}, {2,2}, {3,3}, {1,1}, {3,3}};
- assert(std::equal(m.rbegin(), m.rend(), expected, expected+4));
+ M m = {{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}};
+ assert(std::equal(m.rbegin(), m.rend(), expected, expected + 4));
}
{
- using M = std::flat_map<int, short>;
- std::initializer_list<M::value_type> il = {{5,2}, {2,2}, {2,2}, {3,3}, {1,1}, {3,3}};
- M m = il;
- assert(std::equal(m.begin(), m.end(), expected, expected+4));
- static_assert( std::is_constructible_v<M, std::initializer_list<std::pair<int, short>>>);
- static_assert( std::is_constructible_v<M, std::initializer_list<std::pair<int, short>>, std::allocator<int>>);
+ using M = std::flat_map<int, short>;
+ std::initializer_list<M::value_type> il = {{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}};
+ M m = il;
+ assert(std::equal(m.begin(), m.end(), expected, expected + 4));
+ static_assert(std::is_constructible_v<M, std::initializer_list<std::pair<int, short>>>);
+ static_assert(std::is_constructible_v<M, std::initializer_list<std::pair<int, short>>, std::allocator<int>>);
static_assert(!std::is_constructible_v<M, std::initializer_list<std::pair<const int, short>>>);
static_assert(!std::is_constructible_v<M, std::initializer_list<std::pair<const int, short>>, std::allocator<int>>);
static_assert(!std::is_constructible_v<M, std::initializer_list<std::pair<const int, const short>>>);
- static_assert(!std::is_constructible_v<M, std::initializer_list<std::pair<const int, const short>>, std::allocator<int>>);
+ static_assert(
+ !std::is_constructible_v<M, std::initializer_list<std::pair<const int, const short>>, std::allocator<int>>);
}
{
using A = explicit_allocator<int>;
{
using M = std::flat_map<int, int, DefaultCtableComp, std::vector<int, A>, std::deque<int, A>>;
- M m = {{1,1}, {2,2}, {3,3}};
+ M m = {{1, 1}, {2, 2}, {3, 3}};
assert(m.size() == 1);
assert(m.begin()->first == m.begin()->second);
LIBCPP_ASSERT(*m.begin() == std::make_pair(1, 1));
@@ -68,17 +68,17 @@ int main(int, char**)
{
using M = std::flat_map<int, int, std::greater<int>, std::deque<int, A>, std::vector<int, A>>;
A a;
- M m({{5,2}, {2,2}, {2,2}, {3,3}, {1,1}, {3,3}}, a);
- assert(std::equal(m.rbegin(), m.rend(), expected, expected+4));
+ M m({{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}}, a);
+ assert(std::equal(m.rbegin(), m.rend(), expected, expected + 4));
}
}
{
using M = std::flat_map<int, int, std::less<int>, std::pmr::vector<int>, std::pmr::vector<int>>;
std::pmr::monotonic_buffer_resource mr;
std::pmr::vector<M> vm(&mr);
- std::initializer_list<M::value_type> il = {{3,3}, {1,1}, {4,4}, {1,1}, {5,5}};
+ std::initializer_list<M::value_type> il = {{3, 3}, {1, 1}, {4, 4}, {1, 1}, {5, 5}};
vm.emplace_back(il);
- assert((vm[0] == M{{1,1}, {3,3}, {4,4}, {5,5}}));
+ assert((vm[0] == M{{1, 1}, {3, 3}, {4, 4}, {5, 5}}));
assert(vm[0].keys().get_allocator().resource() == &mr);
assert(vm[0].values().get_allocator().resource() == &mr);
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/initializer_list_compare.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/initializer_list_compare.pass.cpp
index 10f42816bc..6c61bfcc57 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/initializer_list_compare.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/initializer_list_compare.pass.cpp
@@ -25,52 +25,53 @@
#include "min_allocator.h"
#include "../../../test_compare.h"
-int main(int, char**)
-{
- std::pair<int, short> expected[] = {{1,1}, {2,2}, {3,3}, {5,2}};
+int main(int, char**) {
+ std::pair<int, short> expected[] = {{1, 1}, {2, 2}, {3, 3}, {5, 2}};
{
using C = test_less<int>;
using M = std::flat_map<int, short, C>;
- auto m = M({{5,2}, {2,2}, {2,2}, {3,3}, {1,1}, {3,3}}, C(10));
- assert(std::equal(m.begin(), m.end(), expected, expected+4));
+ auto m = M({{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}}, C(10));
+ assert(std::equal(m.begin(), m.end(), expected, expected + 4));
assert(m.key_comp() == C(10));
}
{
// Sorting uses the comparator that was passed in
using M = std::flat_map<int, short, std::function<bool(int, int)>, std::deque<int, min_allocator<int>>>;
- auto m = M({{5,2}, {2,2}, {2,2}, {3,3}, {1,1}, {3,3}}, std::greater<int>());
- assert(std::equal(m.rbegin(), m.rend(), expected, expected+4));
+ auto m = M({{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}}, std::greater<int>());
+ assert(std::equal(m.rbegin(), m.rend(), expected, expected + 4));
assert(m.key_comp()(2, 1) == true);
}
{
- using C = test_less<int>;
- using M = std::flat_map<int, short, C>;
- std::initializer_list<M::value_type> il = {{5,2}, {2,2}, {2,2}, {3,3}, {1,1}, {3,3}};
- auto m = M(il, C(10));
- assert(std::equal(m.begin(), m.end(), expected, expected+4));
+ using C = test_less<int>;
+ using M = std::flat_map<int, short, C>;
+ std::initializer_list<M::value_type> il = {{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}};
+ auto m = M(il, C(10));
+ assert(std::equal(m.begin(), m.end(), expected, expected + 4));
assert(m.key_comp() == C(10));
- static_assert( std::is_constructible_v<M, std::initializer_list<std::pair<int, short>>, C>);
- static_assert( std::is_constructible_v<M, std::initializer_list<std::pair<int, short>>, C, std::allocator<int>>);
+ static_assert(std::is_constructible_v<M, std::initializer_list<std::pair<int, short>>, C>);
+ static_assert(std::is_constructible_v<M, std::initializer_list<std::pair<int, short>>, C, std::allocator<int>>);
static_assert(!std::is_constructible_v<M, std::initializer_list<std::pair<const int, short>>, C>);
- static_assert(!std::is_constructible_v<M, std::initializer_list<std::pair<const int, short>>, C, std::allocator<int>>);
+ static_assert(
+ !std::is_constructible_v<M, std::initializer_list<std::pair<const int, short>>, C, std::allocator<int>>);
static_assert(!std::is_constructible_v<M, std::initializer_list<std::pair<const int, const short>>, C>);
- static_assert(!std::is_constructible_v<M, std::initializer_list<std::pair<const int, const short>>, C, std::allocator<int>>);
+ static_assert(
+ !std::is_constructible_v<M, std::initializer_list<std::pair<const int, const short>>, C, std::allocator<int>>);
}
{
using A = explicit_allocator<int>;
using M = std::flat_map<int, int, std::greater<int>, std::deque<int, A>, std::vector<int, A>>;
A a;
- M m({{5,2}, {2,2}, {2,2}, {3,3}, {1,1}, {3,3}}, {}, a);
- assert(std::equal(m.rbegin(), m.rend(), expected, expected+4));
+ M m({{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}}, {}, a);
+ assert(std::equal(m.rbegin(), m.rend(), expected, expected + 4));
}
{
using C = test_less<int>;
using M = std::flat_map<int, int, C, std::pmr::vector<int>, std::pmr::deque<int>>;
std::pmr::monotonic_buffer_resource mr;
std::pmr::vector<M> vm(&mr);
- std::initializer_list<M::value_type> il = {{3,3}, {1,1}, {4,4}, {1,1}, {5,5}};
+ std::initializer_list<M::value_type> il = {{3, 3}, {1, 1}, {4, 4}, {1, 1}, {5, 5}};
vm.emplace_back(il, C(5));
- assert((vm[0] == M{{1,1}, {3,3}, {4,4}, {5,5}}));
+ assert((vm[0] == M{{1, 1}, {3, 3}, {4, 4}, {5, 5}}));
assert(vm[0].keys().get_allocator().resource() == &mr);
assert(vm[0].values().get_allocator().resource() == &mr);
assert(vm[0].key_comp() == C(5));
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter.pass.cpp
index 389d3906b5..5f0b3be63c 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter.pass.cpp
@@ -27,34 +27,33 @@
#include "test_iterators.h"
#include "test_macros.h"
-int main(int, char**)
-{
- using P = std::pair<int, short>;
- P ar[] = {{1,1}, {1,2}, {1,3}, {2,4}, {2,5}, {3,6}, {2,7}, {3,8}, {3,9}};
- P expected[] = {{1,1}, {2,4}, {3,6}};
+int main(int, char**) {
+ using P = std::pair<int, short>;
+ P ar[] = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {3, 6}, {2, 7}, {3, 8}, {3, 9}};
+ P expected[] = {{1, 1}, {2, 4}, {3, 6}};
{
using M = std::flat_map<int, short>;
- auto m = M(cpp17_input_iterator<const P*>(ar), cpp17_input_iterator<const P*>(ar + 9));
+ auto m = M(cpp17_input_iterator<const P*>(ar), cpp17_input_iterator<const P*>(ar + 9));
assert(std::ranges::equal(m.keys(), expected | std::views::elements<0>));
LIBCPP_ASSERT(std::ranges::equal(m, expected));
}
{
using M = std::flat_map<int, short, std::greater<int>, std::deque<int, min_allocator<int>>, std::deque<short>>;
- auto m = M(cpp17_input_iterator<const P*>(ar), cpp17_input_iterator<const P*>(ar + 9));
- assert((m.keys() == std::deque<int, min_allocator<int>>{3,2,1}));
- LIBCPP_ASSERT((m.values() == std::deque<short>{6,4,1}));
+ auto m = M(cpp17_input_iterator<const P*>(ar), cpp17_input_iterator<const P*>(ar + 9));
+ assert((m.keys() == std::deque<int, min_allocator<int>>{3, 2, 1}));
+ LIBCPP_ASSERT((m.values() == std::deque<short>{6, 4, 1}));
}
{
// Test when the operands are of array type (also contiguous iterator type)
using M = std::flat_map<int, short, std::greater<int>, std::vector<int, min_allocator<int>>>;
- auto m = M(ar, ar);
+ auto m = M(ar, ar);
assert(m.empty());
}
{
using A1 = test_allocator<int>;
using A2 = test_allocator<short>;
- using M = std::flat_map<int, short, std::less<int>, std::vector<int, A1>, std::deque<short, A2>>;
- auto m = M(ar, ar + 9, A1(5));
+ using M = std::flat_map<int, short, std::less<int>, std::vector<int, A1>, std::deque<short, A2>>;
+ auto m = M(ar, ar + 9, A1(5));
assert(std::ranges::equal(m.keys(), expected | std::views::elements<0>));
LIBCPP_ASSERT(std::ranges::equal(m, expected));
assert(m.keys().get_allocator() == A1(5));
@@ -63,10 +62,10 @@ int main(int, char**)
{
using A1 = test_allocator<int>;
using A2 = test_allocator<short>;
- using M = std::flat_map<int, short, std::less<int>, std::vector<int, A1>, std::deque<short, A2>>;
- M m = { ar, ar + 9, A1(5) }; // implicit ctor
+ using M = std::flat_map<int, short, std::less<int>, std::vector<int, A1>, std::deque<short, A2>>;
+ M m = {ar, ar + 9, A1(5)}; // implicit ctor
assert(std::ranges::equal(m.keys(), expected | std::views::elements<0>));
- LIBCPP_ASSERT(std::ranges::equal(m, expected));
+ LIBCPP_ASSERT(std::ranges::equal(m, expected));
assert(m.keys().get_allocator() == A1(5));
assert(m.values().get_allocator() == A2(5));
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter_comp.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter_comp.pass.cpp
index e2e264edd8..d18994082e 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter_comp.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter_comp.pass.cpp
@@ -28,21 +28,20 @@
#include "test_macros.h"
#include "../../../test_compare.h"
-int main(int, char**)
-{
- using P = std::pair<int, short>;
- P ar[] = {{1,1}, {1,2}, {1,3}, {2,4}, {2,5}, {3,6}, {2,7}, {3,8}, {3,9}};
- P expected[] = {{1,1}, {2,4}, {3,6}};
+int main(int, char**) {
+ using P = std::pair<int, short>;
+ P ar[] = {{1, 1}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {3, 6}, {2, 7}, {3, 8}, {3, 9}};
+ P expected[] = {{1, 1}, {2, 4}, {3, 6}};
{
- using M = std::flat_map<int, short, std::function<bool(int,int)>>;
- auto m = M(cpp17_input_iterator<const P*>(ar), cpp17_input_iterator<const P*>(ar + 9), std::less<int>());
+ using M = std::flat_map<int, short, std::function<bool(int, int)>>;
+ auto m = M(cpp17_input_iterator<const P*>(ar), cpp17_input_iterator<const P*>(ar + 9), std::less<int>());
assert(std::ranges::equal(m.keys(), expected | std::views::elements<0>));
LIBCPP_ASSERT(std::ranges::equal(m, expected));
assert(m.key_comp()(1, 2) == true);
}
{
using M = std::flat_map<int, short, std::greater<int>, std::deque<int, min_allocator<int>>>;
- auto m = M(cpp17_input_iterator<const P*>(ar), cpp17_input_iterator<const P*>(ar + 9), std::greater<int>());
+ auto m = M(cpp17_input_iterator<const P*>(ar), cpp17_input_iterator<const P*>(ar + 9), std::greater<int>());
assert(std::ranges::equal(m.keys(), expected | std::views::reverse | std::views::elements<0>));
LIBCPP_ASSERT(std::ranges::equal(m, expected | std::views::reverse));
}
@@ -50,18 +49,18 @@ int main(int, char**)
// Test when the operands are of array type (also contiguous iterator type)
using C = test_less<int>;
using M = std::flat_map<int, short, C, std::vector<int, min_allocator<int>>>;
- auto m = M(ar, ar, C(5));
+ auto m = M(ar, ar, C(5));
assert(m.empty());
assert(m.key_comp() == C(5));
}
{
- using C = test_less<int>;
+ using C = test_less<int>;
using A1 = test_allocator<int>;
using A2 = test_allocator<short>;
- using M = std::flat_map<int, short, C, std::vector<int, A1>, std::deque<short, A2>>;
- auto m = M(ar, ar + 9, C(3), A1(5));
+ using M = std::flat_map<int, short, C, std::vector<int, A1>, std::deque<short, A2>>;
+ auto m = M(ar, ar + 9, C(3), A1(5));
assert(std::ranges::equal(m.keys(), expected | std::views::elements<0>));
- LIBCPP_ASSERT(std::ranges::equal(m, expected));
+ LIBCPP_ASSERT(std::ranges::equal(m, expected));
assert(m.key_comp() == C(3));
assert(m.keys().get_allocator() == A1(5));
assert(m.values().get_allocator() == A2(5));
@@ -69,8 +68,8 @@ int main(int, char**)
{
using A1 = test_allocator<int>;
using A2 = test_allocator<short>;
- using M = std::flat_map<int, short, std::less<int>, std::deque<int, A1>, std::vector<short, A2>>;
- M m = { ar, ar + 9, {}, A2(5) }; // implicit ctor
+ using M = std::flat_map<int, short, std::less<int>, std::deque<int, A1>, std::vector<short, A2>>;
+ M m = {ar, ar + 9, {}, A2(5)}; // implicit ctor
assert(std::ranges::equal(m.keys(), expected | std::views::elements<0>));
LIBCPP_ASSERT(std::ranges::equal(m, expected));
assert(m.keys().get_allocator() == A1(5));
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter_stability.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter_stability.pass.cpp
index 6eb19ce0e2..1ce859f6c7 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter_stability.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/iter_iter_stability.pass.cpp
@@ -30,12 +30,11 @@ struct Mod256 {
bool operator()(int x, int y) const { return (x % 256) < (y % 256); }
};
-int main(int, char**)
-{
+int main(int, char**) {
std::mt19937 randomness;
std::pair<uint16_t, uint16_t> pairs[200];
for (auto& pair : pairs) {
- pair = { uint16_t(randomness()), uint16_t(randomness()) };
+ pair = {uint16_t(randomness()), uint16_t(randomness())};
}
{
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move.pass.cpp
index 20f5c42689..4cd24e3df9 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move.pass.cpp
@@ -24,15 +24,14 @@
#include "test_allocator.h"
#include "min_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
using C = test_less<int>;
using A = test_allocator<int>;
using M = std::flat_map<int, int, C, std::vector<int, A>, std::deque<int, A>>;
- M mo = M({{1,1},{2,2},{3,1}}, C(5), A(7));
- M m = std::move(mo);
- assert((m == M{{1,1},{2,2},{3,1}}));
+ M mo = M({{1, 1}, {2, 2}, {3, 1}}, C(5), A(7));
+ M m = std::move(mo);
+ assert((m == M{{1, 1}, {2, 2}, {3, 1}}));
assert(m.key_comp() == C(5));
assert(m.keys().get_allocator() == A(7));
assert(m.values().get_allocator() == A(7));
@@ -46,9 +45,9 @@ int main(int, char**)
using C = test_less<int>;
using A = min_allocator<int>;
using M = std::flat_map<int, int, C, std::vector<int, A>, std::deque<int, A>>;
- M mo = M({{1,1},{2,2},{3,1}}, C(5), A());
- M m = std::move(mo);
- assert((m == M{{1,1},{2,2},{3,1}}));
+ M mo = M({{1, 1}, {2, 2}, {3, 1}}, C(5), A());
+ M m = std::move(mo);
+ assert((m == M{{1, 1}, {2, 2}, {3, 1}}));
assert(m.key_comp() == C(5));
assert(m.keys().get_allocator() == A());
assert(m.values().get_allocator() == A());
@@ -60,17 +59,17 @@ int main(int, char**)
}
{
// A moved-from flat_map maintains its class invariant in the presence of moved-from comparators.
- using M = std::flat_map<int, int, std::function<bool(int,int)>>;
- M mo = M({{1,1},{2,2},{3,1}}, std::less<int>());
- M m = std::move(mo);
+ using M = std::flat_map<int, int, std::function<bool(int, int)>>;
+ M mo = M({{1, 1}, {2, 2}, {3, 1}}, std::less<int>());
+ M m = std::move(mo);
assert(m.size() == 3);
assert(std::is_sorted(m.begin(), m.end(), m.value_comp()));
- assert(m.key_comp()(1,2) == true);
+ assert(m.key_comp()(1, 2) == true);
assert(std::is_sorted(mo.begin(), mo.end(), mo.value_comp()));
- LIBCPP_ASSERT(m.key_comp()(1,2) == true);
+ LIBCPP_ASSERT(m.key_comp()(1, 2) == true);
LIBCPP_ASSERT(mo.empty());
- mo.insert({{1,1},{2,2},{3,1}}); // insert has no preconditions
+ mo.insert({{1, 1}, {2, 2}, {3, 1}}); // insert has no preconditions
assert(m == mo);
}
return 0;
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_alloc.pass.cpp
index 745680c063..e225977c3e 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_alloc.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_alloc.pass.cpp
@@ -24,15 +24,14 @@
#include "../../../test_compare.h"
#include "test_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
- std::pair<int, int> expected[] = {{1,1}, {2,2}, {3,1}};
- using C = test_less<int>;
- using A = test_allocator<int>;
- using M = std::flat_map<int, int, C, std::vector<int, A>, std::deque<int, A>>;
- auto mo = M(expected, expected + 3, C(5), A(7));
- auto m = M(std::move(mo), A(3));
+ std::pair<int, int> expected[] = {{1, 1}, {2, 2}, {3, 1}};
+ using C = test_less<int>;
+ using A = test_allocator<int>;
+ using M = std::flat_map<int, int, C, std::vector<int, A>, std::deque<int, A>>;
+ auto mo = M(expected, expected + 3, C(5), A(7));
+ auto m = M(std::move(mo), A(3));
assert(m.key_comp() == C(5));
assert(m.size() == 3);
@@ -44,21 +43,21 @@ int main(int, char**)
// The original flat_map is moved-from.
assert(std::is_sorted(mo.begin(), mo.end(), mo.value_comp()));
- #if 0
+#if 0
assert(mo.empty());
- #endif
+#endif
assert(mo.key_comp() == C(5));
assert(mo.keys().get_allocator() == A(7));
assert(mo.values().get_allocator() == A(7));
}
{
- std::pair<int, int> expected[] = {{1,1}, {2,2}, {3,1}};
- using C = test_less<int>;
- using M = std::flat_map<int, int, C, std::pmr::vector<int>, std::pmr::deque<int>>;
+ std::pair<int, int> expected[] = {{1, 1}, {2, 2}, {3, 1}};
+ using C = test_less<int>;
+ using M = std::flat_map<int, int, C, std::pmr::vector<int>, std::pmr::deque<int>>;
std::pmr::monotonic_buffer_resource mr1;
std::pmr::monotonic_buffer_resource mr2;
- M mo = M({{1,1}, {3,1}, {1,1}, {2,2}}, C(5), &mr1);
- M m = {std::move(mo), &mr2}; // also test the implicitness of this constructor
+ M mo = M({{1, 1}, {3, 1}, {1, 1}, {2, 2}}, C(5), &mr1);
+ M m = {std::move(mo), &mr2}; // also test the implicitness of this constructor
assert(m.key_comp() == C(5));
assert(m.size() == 3);
@@ -75,10 +74,10 @@ int main(int, char**)
{
using M = std::flat_map<int, int, std::less<>, std::pmr::deque<int>, std::pmr::vector<int>>;
std::pmr::vector<M> vs;
- M m = {{1,1}, {3,1}, {1,1}, {2,2}};
+ M m = {{1, 1}, {3, 1}, {1, 1}, {2, 2}};
vs.push_back(std::move(m));
- assert((vs[0].keys() == std::pmr::deque<int>{1,2,3}));
- assert((vs[0].values() == std::pmr::vector<int>{1,2,1}));
+ assert((vs[0].keys() == std::pmr::deque<int>{1, 2, 3}));
+ assert((vs[0].values() == std::pmr::vector<int>{1, 2, 1}));
}
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign.pass.cpp
index bf0b0e71a3..e29c175500 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign.pass.cpp
@@ -27,17 +27,16 @@
#include "test_allocator.h"
#include "min_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
- using C = test_less<int>;
+ using C = test_less<int>;
using A1 = test_allocator<int>;
using A2 = test_allocator<char>;
- using M = std::flat_map<int, char, C, std::vector<int, A1>, std::vector<char, A2>>;
- M mo = M({{1,1},{2,3},{3,2}}, C(5), A1(7));
- M m = M({}, C(3), A1(7));
- m = std::move(mo);
- assert((m == M{{1,1},{2,3},{3,2}}));
+ using M = std::flat_map<int, char, C, std::vector<int, A1>, std::vector<char, A2>>;
+ M mo = M({{1, 1}, {2, 3}, {3, 2}}, C(5), A1(7));
+ M m = M({}, C(3), A1(7));
+ m = std::move(mo);
+ assert((m == M{{1, 1}, {2, 3}, {3, 2}}));
assert(m.key_comp() == C(5));
auto [ks, vs] = std::move(m).extract();
assert(ks.get_allocator() == A1(7));
@@ -45,14 +44,14 @@ int main(int, char**)
assert(mo.empty());
}
{
- using C = test_less<int>;
+ using C = test_less<int>;
using A1 = other_allocator<int>;
using A2 = other_allocator<char>;
- using M = std::flat_map<int, char, C, std::deque<int, A1>, std::deque<char, A2>>;
- M mo = M({{4,5},{5,4}}, C(5), A1(7));
- M m = M({{1,1},{2,2},{3,3},{4,4}}, C(3), A1(7));
- m = std::move(mo);
- assert((m == M{{4,5},{5,4}}));
+ using M = std::flat_map<int, char, C, std::deque<int, A1>, std::deque<char, A2>>;
+ M mo = M({{4, 5}, {5, 4}}, C(5), A1(7));
+ M m = M({{1, 1}, {2, 2}, {3, 3}, {4, 4}}, C(3), A1(7));
+ m = std::move(mo);
+ assert((m == M{{4, 5}, {5, 4}}));
assert(m.key_comp() == C(5));
auto [ks, vs] = std::move(m).extract();
assert(ks.get_allocator() == A1(7));
@@ -62,10 +61,10 @@ int main(int, char**)
{
using A = min_allocator<int>;
using M = std::flat_map<int, int, std::greater<int>, std::vector<int, A>, std::vector<int, A>>;
- M mo = M({{5,1},{4,2},{3,3}}, A());
- M m = M({{4,4},{3,3},{2,2},{1,1}}, A());
- m = std::move(mo);
- assert((m == M{{5,1},{4,2},{3,3}}));
+ M mo = M({{5, 1}, {4, 2}, {3, 3}}, A());
+ M m = M({{4, 4}, {3, 3}, {2, 2}, {1, 1}}, A());
+ m = std::move(mo);
+ assert((m == M{{5, 1}, {4, 2}, {3, 3}}));
auto [ks, vs] = std::move(m).extract();
assert(ks.get_allocator() == A());
assert(vs.get_allocator() == A());
@@ -73,35 +72,38 @@ int main(int, char**)
}
{
// A moved-from flat_map maintains its class invariant in the presence of moved-from elements.
- using M = std::flat_map<std::pmr::string, int, std::less<>, std::pmr::vector<std::pmr::string>, std::pmr::vector<int>>;
+ using M =
+ std::flat_map<std::pmr::string, int, std::less<>, std::pmr::vector<std::pmr::string>, std::pmr::vector<int>>;
std::pmr::monotonic_buffer_resource mr1;
std::pmr::monotonic_buffer_resource mr2;
- M mo = M({{"short", 1}, {"very long string that definitely won't fit in the SSO buffer and therefore becomes empty on move", 2}}, &mr1);
- M m = M({{"don't care", 3}}, &mr2);
- m = std::move(mo);
+ M mo = M({{"short", 1},
+ {"very long string that definitely won't fit in the SSO buffer and therefore becomes empty on move", 2}},
+ &mr1);
+ M m = M({{"don't care", 3}}, &mr2);
+ m = std::move(mo);
assert(m.size() == 2);
assert(std::is_sorted(m.begin(), m.end(), m.value_comp()));
assert(m.begin()->first.get_allocator().resource() == &mr2);
assert(std::is_sorted(mo.begin(), mo.end(), mo.value_comp()));
- mo.insert({"foo",1});
+ mo.insert({"foo", 1});
assert(mo.begin()->first.get_allocator().resource() == &mr1);
}
{
// A moved-from flat_map maintains its class invariant in the presence of moved-from comparators.
- using C = std::function<bool(int,int)>;
+ using C = std::function<bool(int, int)>;
using M = std::flat_map<int, int, C>;
- M mo = M({{1,3},{2,2},{3,1}}, std::less<int>());
- M m = M({{1,1},{2,2}}, std::greater<int>());
- m = std::move(mo);
+ M mo = M({{1, 3}, {2, 2}, {3, 1}}, std::less<int>());
+ M m = M({{1, 1}, {2, 2}}, std::greater<int>());
+ m = std::move(mo);
assert(m.size() == 3);
assert(std::is_sorted(m.begin(), m.end(), m.value_comp()));
- assert(m.key_comp()(1,2) == true);
+ assert(m.key_comp()(1, 2) == true);
assert(std::is_sorted(mo.begin(), mo.end(), mo.value_comp()));
- LIBCPP_ASSERT(m.key_comp()(1,2) == true);
+ LIBCPP_ASSERT(m.key_comp()(1, 2) == true);
LIBCPP_ASSERT(mo.empty());
- mo.insert({{1,3},{2,2},{3,1}}); // insert has no preconditions
+ mo.insert({{1, 3}, {2, 2}, {3, 1}}); // insert has no preconditions
LIBCPP_ASSERT(m == mo);
}
return 0;
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_clears.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_clears.pass.cpp
index 95fcb1e5e0..de15377d86 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_clears.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_clears.pass.cpp
@@ -24,59 +24,66 @@
#include "test_macros.h"
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) { value_ = rhs.value_; rhs.value_ = -rhs.value_; return *this; }
- ~MoveNegates() = default;
- auto operator<=>(const MoveNegates&) const = default;
+ int value_ = 0;
+ MoveNegates() = default;
+ MoveNegates(int v) : value_(v) {}
+ MoveNegates(MoveNegates&& rhs) : value_(rhs.value_) { rhs.value_ = -rhs.value_; }
+ MoveNegates& operator=(MoveNegates&& rhs) {
+ value_ = rhs.value_;
+ rhs.value_ = -rhs.value_;
+ return *this;
+ }
+ ~MoveNegates() = default;
+ auto operator<=>(const MoveNegates&) const = default;
};
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) { value_ = rhs.value_; rhs.value_ = 0; return *this; }
- ~MoveClears() = default;
- auto operator<=>(const MoveClears&) const = default;
+ int value_ = 0;
+ MoveClears() = default;
+ MoveClears(int v) : value_(v) {}
+ MoveClears(MoveClears&& rhs) : value_(rhs.value_) { rhs.value_ = 0; }
+ MoveClears& operator=(MoveClears&& rhs) {
+ value_ = rhs.value_;
+ rhs.value_ = 0;
+ return *this;
+ }
+ ~MoveClears() = default;
+ auto operator<=>(const MoveClears&) const = default;
};
-int main(int, char**)
-{
+int main(int, char**) {
auto value_eq = [](auto&& p, auto&& q) { return p.first == q.first; };
{
- const std::pair<int, int> expected[] = { {1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}, {7,7}, {8,8} };
+ const std::pair<int, int> expected[] = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}, {8, 8}};
using M = std::flat_map<MoveNegates, int, std::less<MoveNegates>, std::vector<MoveNegates>>;
- M m = M(expected, expected + 8);
- M m2 = M(expected, expected + 3);
+ M m = M(expected, expected + 8);
+ M m2 = M(expected, expected + 3);
m2 = std::move(m);
- assert(std::equal(m2.begin(), m2.end(), expected, expected+8));
+ assert(std::equal(m2.begin(), m2.end(), expected, expected + 8));
LIBCPP_ASSERT(m.empty());
- assert(std::is_sorted(m.begin(), m.end(), m.value_comp())); // still sorted
+ assert(std::is_sorted(m.begin(), m.end(), m.value_comp())); // still sorted
assert(std::adjacent_find(m.begin(), m.end(), value_eq) == m.end()); // still contains no duplicates
- m.insert({1,1});
- m.insert({2,2});
+ m.insert({1, 1});
+ m.insert({2, 2});
assert(m.contains(1));
assert(m.find(2) != m.end());
}
{
- const std::pair<int, int> expected[] = { {1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}, {7,7}, {8,8} };
+ const std::pair<int, int> expected[] = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}, {8, 8}};
using M = std::flat_map<MoveClears, int, std::less<MoveClears>, std::vector<MoveClears>>;
- M m = M(expected, expected + 8);
- M m2 = M(expected, expected + 3);
+ M m = M(expected, expected + 8);
+ M m2 = M(expected, expected + 3);
m2 = std::move(m);
- assert(std::equal(m2.begin(), m2.end(), expected, expected+8));
+ assert(std::equal(m2.begin(), m2.end(), expected, expected + 8));
LIBCPP_ASSERT(m.empty());
- assert(std::is_sorted(m.begin(), m.end(), m.value_comp())); // still sorted
+ assert(std::is_sorted(m.begin(), m.end(), m.value_comp())); // still sorted
assert(std::adjacent_find(m.begin(), m.end(), value_eq) == m.end()); // still contains no duplicates
- m.insert({1,1});
- m.insert({2,2});
+ m.insert({1, 1});
+ m.insert({2, 2});
assert(m.contains(1));
assert(m.find(2) != m.end());
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.pass.cpp
index 5c9514089c..763dcd051c 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_assign_noexcept.pass.cpp
@@ -29,40 +29,62 @@
#include "test_macros.h"
struct MoveSensitiveComp {
- MoveSensitiveComp() noexcept(false) = default;
+ MoveSensitiveComp() noexcept(false) = default;
MoveSensitiveComp(const MoveSensitiveComp&) noexcept(false) = default;
MoveSensitiveComp(MoveSensitiveComp&& rhs) { rhs.is_moved_from_ = true; }
MoveSensitiveComp& operator=(const MoveSensitiveComp&) noexcept = default;
- MoveSensitiveComp& operator=(MoveSensitiveComp&& rhs) { rhs.is_moved_from_ = true; return *this; }
+ 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;
};
-int main(int, char**)
-{
+int main(int, char**) {
{
using C = std::flat_map<int, int>;
LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v<C>);
}
{
- using C = std::flat_map<MoveOnly, int, std::less<MoveOnly>, std::vector<MoveOnly, test_allocator<MoveOnly>>, std::vector<int, test_allocator<int>>>;
+ using C =
+ std::flat_map<MoveOnly,
+ int,
+ std::less<MoveOnly>,
+ std::vector<MoveOnly, test_allocator<MoveOnly>>,
+ std::vector<int, test_allocator<int>>>;
static_assert(!std::is_nothrow_move_assignable_v<C>);
}
{
- using C = std::flat_map<int, MoveOnly, std::less<int>, std::vector<int, test_allocator<int>>, std::vector<MoveOnly, test_allocator<MoveOnly>>>;
+ using C =
+ std::flat_map<int,
+ MoveOnly,
+ std::less<int>,
+ std::vector<int, test_allocator<int>>,
+ std::vector<MoveOnly, test_allocator<MoveOnly>>>;
static_assert(!std::is_nothrow_move_assignable_v<C>);
}
{
- using C = std::flat_map<MoveOnly, int, std::less<MoveOnly>, std::vector<MoveOnly, other_allocator<MoveOnly>>, std::vector<int, other_allocator<int>>>;
+ using C =
+ std::flat_map<MoveOnly,
+ int,
+ std::less<MoveOnly>,
+ std::vector<MoveOnly, other_allocator<MoveOnly>>,
+ std::vector<int, other_allocator<int>>>;
LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v<C>);
}
{
- using C = std::flat_map<int, MoveOnly, std::less<int>, std::vector<int, other_allocator<int>>, std::vector<MoveOnly, other_allocator<MoveOnly>>>;
+ using C =
+ std::flat_map<int,
+ MoveOnly,
+ std::less<int>,
+ std::vector<int, other_allocator<int>>,
+ std::vector<MoveOnly, other_allocator<MoveOnly>>>;
LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable_v<C>);
}
{
// Test with a comparator that throws on copy-assignment.
- using C = std::flat_map<int, int, std::function<bool(int,int)>>;
+ using C = std::flat_map<int, int, std::function<bool(int, int)>>;
LIBCPP_STATIC_ASSERT(!std::is_nothrow_move_assignable_v<C>);
}
{
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_exceptions.pass.cpp
index 2e7d5c95a0..f052ba3ca7 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_exceptions.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_exceptions.pass.cpp
@@ -38,11 +38,10 @@ struct EvilContainer : std::vector<int> {
}
};
-int main(int, char**)
-{
+int main(int, char**) {
{
- using M = std::flat_map<int, int, std::less<int>, EvilContainer, std::vector<int>>;
- M mo = {{1,1}, {2,2}, {3,3}};
+ using M = std::flat_map<int, int, std::less<int>, EvilContainer, std::vector<int>>;
+ M mo = {{1, 1}, {2, 2}, {3, 3}};
countdown = 1;
try {
M m = std::move(mo);
@@ -57,8 +56,8 @@ int main(int, char**)
LIBCPP_ASSERT(mo.empty());
}
{
- using M = std::flat_map<int, int, std::less<int>, std::vector<int>, EvilContainer>;
- M mo = {{1,1}, {2,2}, {3,3}};
+ using M = std::flat_map<int, int, std::less<int>, std::vector<int>, EvilContainer>;
+ M mo = {{1, 1}, {2, 2}, {3, 3}};
countdown = 1;
try {
M m = std::move(mo);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_noexcept.pass.cpp
index ee7798b873..c170f0fd75 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/move_noexcept.pass.cpp
@@ -31,12 +31,12 @@
template <class T>
struct ThrowingMoveAllocator {
- using value_type = T;
- explicit ThrowingMoveAllocator() = default;
+ 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); }
+ 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); }
friend bool operator==(ThrowingMoveAllocator, ThrowingMoveAllocator) = default;
};
@@ -48,17 +48,19 @@ struct ThrowingCopyComp {
};
struct MoveSensitiveComp {
- MoveSensitiveComp() noexcept(false) = default;
+ 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; }
+ 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;
};
-int main(int, char**)
-{
+int main(int, char**) {
{
using C = std::flat_map<int, int>;
LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible_v<C>);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_container.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_container.pass.cpp
index 106885cdd3..eeb536f527 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_container.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_container.pass.cpp
@@ -25,53 +25,52 @@
#include "test_iterators.h"
#include "test_macros.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
- using M = std::flat_map<int, char>;
- std::vector<int> ks = {1,2,4,10};
- std::vector<char> vs = {4,3,2,1};
- auto m = M(std::sorted_unique, ks, vs);
- assert((m == M{{1,4}, {2,3}, {4,2}, {10,1}}));
+ using M = std::flat_map<int, char>;
+ std::vector<int> ks = {1, 2, 4, 10};
+ std::vector<char> vs = {4, 3, 2, 1};
+ auto m = M(std::sorted_unique, ks, vs);
+ assert((m == M{{1, 4}, {2, 3}, {4, 2}, {10, 1}}));
m = M(std::sorted_unique, std::move(ks), std::move(vs));
assert(ks.empty()); // it was moved-from
assert(vs.empty()); // it was moved-from
- assert((m == M{{1,4}, {2,3}, {4,2}, {10,1}}));
+ assert((m == M{{1, 4}, {2, 3}, {4, 2}, {10, 1}}));
}
{
using Ks = std::deque<int, min_allocator<int>>;
using Vs = std::deque<char, min_allocator<char>>;
- using M = std::flat_map<int, char, std::greater<int>, Ks, Vs>;
- Ks ks = {10,4,2,1};
- Vs vs = {1,2,3,4};
- auto m = M(std::sorted_unique, ks, vs);
- assert((m == M{{1,4}, {2,3}, {4,2}, {10,1}}));
+ using M = std::flat_map<int, char, std::greater<int>, Ks, Vs>;
+ Ks ks = {10, 4, 2, 1};
+ Vs vs = {1, 2, 3, 4};
+ auto m = M(std::sorted_unique, ks, vs);
+ assert((m == M{{1, 4}, {2, 3}, {4, 2}, {10, 1}}));
m = M(std::sorted_unique, std::move(ks), std::move(vs));
assert(ks.empty()); // it was moved-from
assert(vs.empty()); // it was moved-from
- assert((m == M{{1,4}, {2,3}, {4,2}, {10,1}}));
+ assert((m == M{{1, 4}, {2, 3}, {4, 2}, {10, 1}}));
}
{
using A = test_allocator<int>;
using M = std::flat_map<int, int, std::less<int>, std::vector<int, A>, std::deque<int, A>>;
- auto ks = std::vector<int, A>({1,2,4,10}, A(4));
- auto vs = std::deque<int, A>({4,3,2,1}, A(5));
- auto m = M(std::sorted_unique, std::move(ks), std::move(vs));
+ auto ks = std::vector<int, A>({1, 2, 4, 10}, A(4));
+ auto vs = std::deque<int, A>({4, 3, 2, 1}, A(5));
+ auto m = M(std::sorted_unique, std::move(ks), std::move(vs));
assert(ks.empty()); // it was moved-from
assert(vs.empty()); // it was moved-from
- assert((m == M{{1,4}, {2,3}, {4,2}, {10,1}}));
+ assert((m == M{{1, 4}, {2, 3}, {4, 2}, {10, 1}}));
assert(m.keys().get_allocator() == A(4));
assert(m.values().get_allocator() == A(5));
}
{
using A = test_allocator<int>;
using M = std::flat_map<int, int, std::less<int>, std::vector<int, A>, std::deque<int, A>>;
- auto ks = std::vector<int, A>({1,2,4,10}, A(4));
- auto vs = std::deque<int, A>({4,3,2,1}, A(5));
- auto m = M(std::sorted_unique, ks, vs, A(6)); // replaces the allocators
- assert(!ks.empty()); // it was an lvalue above
- assert(!vs.empty()); // it was an lvalue above
- assert((m == M{{1,4}, {2,3}, {4,2}, {10,1}}));
+ auto ks = std::vector<int, A>({1, 2, 4, 10}, A(4));
+ auto vs = std::deque<int, A>({4, 3, 2, 1}, A(5));
+ auto m = M(std::sorted_unique, ks, vs, A(6)); // replaces the allocators
+ assert(!ks.empty()); // it was an lvalue above
+ assert(!vs.empty()); // it was an lvalue above
+ assert((m == M{{1, 4}, {2, 3}, {4, 2}, {10, 1}}));
assert(m.keys().get_allocator() == A(6));
assert(m.values().get_allocator() == A(6));
}
@@ -79,12 +78,12 @@ int main(int, char**)
using M = std::flat_map<int, int, std::less<int>, std::pmr::vector<int>, std::pmr::vector<int>>;
std::pmr::monotonic_buffer_resource mr;
std::pmr::vector<M> vm(&mr);
- std::pmr::vector<int> ks = {1,2,4,10};
- std::pmr::vector<int> vs = {4,3,2,1};
+ std::pmr::vector<int> ks = {1, 2, 4, 10};
+ std::pmr::vector<int> vs = {4, 3, 2, 1};
vm.emplace_back(std::sorted_unique, ks, vs);
assert(!ks.empty()); // it was an lvalue above
assert(!vs.empty()); // it was an lvalue above
- assert((vm[0] == M{{1,4}, {2,3}, {4,2}, {10,1}}));
+ assert((vm[0] == M{{1, 4}, {2, 3}, {4, 2}, {10, 1}}));
assert(vm[0].keys().get_allocator().resource() == &mr);
assert(vm[0].values().get_allocator().resource() == &mr);
}
@@ -92,16 +91,16 @@ int main(int, char**)
using M = std::flat_map<int, int, std::less<int>, std::pmr::vector<int>, std::pmr::vector<int>>;
std::pmr::monotonic_buffer_resource mr;
std::pmr::vector<M> vm(&mr);
- std::pmr::vector<int> ks = {1,2,4,10};
- std::pmr::vector<int> vs = {4,3,2,1};
+ std::pmr::vector<int> ks = {1, 2, 4, 10};
+ std::pmr::vector<int> vs = {4, 3, 2, 1};
vm.emplace_back(std::sorted_unique, std::move(ks), std::move(vs));
LIBCPP_ASSERT(ks.size() == 4); // ks' size is unchanged, since it uses a different allocator
LIBCPP_ASSERT(vs.size() == 4); // vs' size is unchanged, since it uses a different allocator
- assert((vm[0] == M{{1,4}, {2,3}, {4,2}, {10,1}}));
+ assert((vm[0] == M{{1, 4}, {2, 3}, {4, 2}, {10, 1}}));
assert(vm[0].keys().get_allocator().resource() == &mr);
assert(vm[0].values().get_allocator().resource() == &mr);
}
- #if 0
+#if 0
{
using M = std::flat_map<int, int, std::less<int>, std::pmr::vector<int>, std::pmr::vector<int>>;
std::pmr::monotonic_buffer_resource mr;
@@ -124,6 +123,6 @@ int main(int, char**)
assert(vm.size() == 1);
assert(vm[0].empty());
}
- #endif
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_iter_iter_comp.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_iter_iter_comp.pass.cpp
index b5852d40ea..3eebfc2d09 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_iter_iter_comp.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/sorted_iter_iter_comp.pass.cpp
@@ -27,41 +27,46 @@
#include "test_macros.h"
#include "../../../test_compare.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
- using M = std::flat_map<int, int, std::function<bool(int,int)>>;
+ using M = std::flat_map<int, int, std::function<bool(int, int)>>;
using P = std::pair<int, int>;
- P ar[] = {{1,1}, {2,2}, {4,4}, {5,5}};
- auto m = M(std::sorted_unique, cpp17_input_iterator<const P*>(ar), cpp17_input_iterator<const P*>(ar + 4), std::less<int>());
- assert(m == M({{1,1}, {2,2}, {4,4}, {5,5}}, std::less<>()));
+ P ar[] = {{1, 1}, {2, 2}, {4, 4}, {5, 5}};
+ auto m = M(std::sorted_unique,
+ cpp17_input_iterator<const P*>(ar),
+ cpp17_input_iterator<const P*>(ar + 4),
+ std::less<int>());
+ assert(m == M({{1, 1}, {2, 2}, {4, 4}, {5, 5}}, std::less<>()));
assert(m.key_comp()(1, 2) == true);
}
{
using M = std::flat_map<int, int, std::greater<int>, std::deque<int, min_allocator<int>>, std::vector<int>>;
using P = std::pair<int, int>;
- P ar[] = {{5,5}, {4,4}, {2,2}, {1,1}};
- auto m = M(std::sorted_unique, cpp17_input_iterator<const P*>(ar), cpp17_input_iterator<const P*>(ar + 4), std::greater<int>());
- assert((m == M{{5,5}, {4,4}, {2,2}, {1,1}}));
+ P ar[] = {{5, 5}, {4, 4}, {2, 2}, {1, 1}};
+ auto m = M(std::sorted_unique,
+ cpp17_input_iterator<const P*>(ar),
+ cpp17_input_iterator<const P*>(ar + 4),
+ std::greater<int>());
+ assert((m == M{{5, 5}, {4, 4}, {2, 2}, {1, 1}}));
}
{
// Test when the operands are of array type (also contiguous iterator type)
using C = test_less<int>;
using M = std::flat_map<int, int, C, std::vector<int, min_allocator<int>>, std::vector<int, min_allocator<int>>>;
- std::pair<int, int> ar[1] = {{42,42}};
- auto m = M(std::sorted_unique, ar, ar, C(5));
+ std::pair<int, int> ar[1] = {{42, 42}};
+ auto m = M(std::sorted_unique, ar, ar, C(5));
assert(m.empty());
assert(m.key_comp() == C(5));
}
{
- using C = test_less<int>;
+ using C = test_less<int>;
using A1 = test_allocator<int>;
using A2 = test_allocator<short>;
- using M = std::flat_map<int, short, C, std::vector<int, A1>, std::deque<short, A2>>;
- using P = std::pair<int, int>;
- P ar[] = {{1,1}, {2,2}, {4,4}, {5,5}};
- auto m = M(std::sorted_unique, ar, ar + 4, C(3), A1(5));
- assert((m == M{{1,1}, {2,2}, {4,4}, {5,5}}));
+ using M = std::flat_map<int, short, C, std::vector<int, A1>, std::deque<short, A2>>;
+ using P = std::pair<int, int>;
+ P ar[] = {{1, 1}, {2, 2}, {4, 4}, {5, 5}};
+ auto m = M(std::sorted_unique, ar, ar + 4, C(3), A1(5));
+ assert((m == M{{1, 1}, {2, 2}, {4, 4}, {5, 5}}));
assert(m.key_comp() == C(3));
assert(m.keys().get_allocator() == A1(5));
assert(m.values().get_allocator() == A2(5));
@@ -69,11 +74,11 @@ int main(int, char**)
{
using A1 = test_allocator<short>;
using A2 = test_allocator<int>;
- using M = std::flat_map<short, int, std::less<int>, std::deque<short, A1>, std::vector<int, A2>>;
- using P = std::pair<int, int>;
- P ar[] = {{1,1}, {2,2}, {4,4}, {5,5}};
- M m = { std::sorted_unique, ar, ar + 4, {}, A1(5) }; // implicit ctor
- assert((m == M{{1,1}, {2,2}, {4,4}, {5,5}}));
+ using M = std::flat_map<short, int, std::less<int>, std::deque<short, A1>, std::vector<int, A2>>;
+ using P = std::pair<int, int>;
+ P ar[] = {{1, 1}, {2, 2}, {4, 4}, {5, 5}};
+ M m = {std::sorted_unique, ar, ar + 4, {}, A1(5)}; // implicit ctor
+ assert((m == M{{1, 1}, {2, 2}, {4, 4}, {5, 5}}));
assert(m.keys().get_allocator() == A1(5));
assert(m.values().get_allocator() == A2(5));
}
@@ -83,9 +88,10 @@ int main(int, char**)
std::pmr::monotonic_buffer_resource mr;
std::pmr::vector<M> vm(&mr);
using P = std::pair<int, int>;
- P ar[] = {{1,1}, {2,2}, {4,4}, {5,5}};
- vm.emplace_back(std::sorted_unique, cpp17_input_iterator<const P*>(ar), cpp17_input_iterator<const P*>(ar + 4), C(3));
- assert((vm[0] == M{{1,1}, {2,2}, {4,4}, {5,5}}));
+ P ar[] = {{1, 1}, {2, 2}, {4, 4}, {5, 5}};
+ vm.emplace_back(
+ std::sorted_unique, cpp17_input_iterator<const P*>(ar), cpp17_input_iterator<const P*>(ar + 4), C(3));
+ assert((vm[0] == M{{1, 1}, {2, 2}, {4, 4}, {5, 5}}));
assert(vm[0].key_comp() == C(3));
assert(vm[0].keys().get_allocator().resource() == &mr);
assert(vm[0].values().get_allocator().resource() == &mr);
@@ -95,7 +101,7 @@ int main(int, char**)
using M = std::flat_map<int, int, C, std::pmr::vector<int>, std::pmr::vector<int>>;
std::pmr::monotonic_buffer_resource mr;
std::pmr::vector<M> vm(&mr);
- std::pair<int, int> ar[1] = {{42,42}};
+ std::pair<int, int> ar[1] = {{42, 42}};
vm.emplace_back(std::sorted_unique, ar, ar, C(4));
assert(vm[0] == M{});
assert(vm[0].key_comp() == C(4));
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if.pass.cpp
index c11aea1364..e225285e8d 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if.pass.cpp
@@ -27,23 +27,21 @@
// Verify that `flat_map` (like `map`) does NOT support std::erase.
//
template <class S>
-concept HasStdErase = requires (S& s, typename S::value_type x) {
- std::erase(s, x);
-};
+concept HasStdErase = requires(S& s, typename S::value_type x) { std::erase(s, x); };
static_assert(HasStdErase<std::vector<int>>);
static_assert(!HasStdErase<std::flat_map<int, int>>);
template <class M>
-M make(std::initializer_list<int> vals)
-{
- M ret;
- for (int v : vals)
- ret[static_cast<typename M::key_type>(v)] = static_cast<typename M::mapped_type>(v + 10);
- return ret;
+M make(std::initializer_list<int> vals) {
+ M ret;
+ for (int v : vals)
+ ret[static_cast<typename M::key_type>(v)] = static_cast<typename M::mapped_type>(v + 10);
+ return ret;
}
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) {
+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));
@@ -51,48 +49,50 @@ void test0(std::initializer_list<int> vals, Pred p, std::initializer_list<int> e
}
template <class S>
-void test()
-{
- // Test all the plausible signatures for this predicate.
- auto is1 = [](typename S::const_reference v) { return v.first == 1;};
- auto is2 = [](typename S::value_type v) { return v.first == 2;};
- auto is3 = [](const typename S::value_type& v) { return v.first == 3;};
- auto is4 = [](auto v) { return v.first == 4;};
- auto True = [](const auto&) { return true; };
- auto False = [](auto&&) { return false; };
+void test() {
+ // Test all the plausible signatures for this predicate.
+ auto is1 = [](typename S::const_reference v) { return v.first == 1; };
+ auto is2 = [](typename S::value_type v) { return v.first == 2; };
+ auto is3 = [](const typename S::value_type& v) { return v.first == 3; };
+ auto is4 = [](auto v) { return v.first == 4; };
+ auto True = [](const auto&) { return true; };
+ auto False = [](auto&&) { return false; };
- test0<S>({}, is1, {}, 0);
+ test0<S>({}, is1, {}, 0);
- test0<S>({1}, is1, {}, 1);
- test0<S>({1}, is2, {1}, 0);
+ test0<S>({1}, is1, {}, 1);
+ test0<S>({1}, is2, {1}, 0);
- test0<S>({1, 2}, is1, {2}, 1);
- test0<S>({1, 2}, is2, {1}, 1);
- test0<S>({1, 2}, is3, {1, 2}, 0);
+ test0<S>({1, 2}, is1, {2}, 1);
+ test0<S>({1, 2}, is2, {1}, 1);
+ test0<S>({1, 2}, is3, {1, 2}, 0);
- test0<S>({1, 2, 3}, is1, {2, 3}, 1);
- test0<S>({1, 2, 3}, is2, {1, 3}, 1);
- test0<S>({1, 2, 3}, is3, {1, 2}, 1);
- test0<S>({1, 2, 3}, is4, {1, 2, 3}, 0);
+ test0<S>({1, 2, 3}, is1, {2, 3}, 1);
+ test0<S>({1, 2, 3}, is2, {1, 3}, 1);
+ test0<S>({1, 2, 3}, is3, {1, 2}, 1);
+ test0<S>({1, 2, 3}, is4, {1, 2, 3}, 0);
- test0<S>({1, 2, 3}, True, {}, 3);
- test0<S>({1, 2, 3}, False, {1, 2, 3}, 0);
+ test0<S>({1, 2, 3}, True, {}, 3);
+ test0<S>({1, 2, 3}, False, {1, 2, 3}, 0);
}
-int main(int, char**)
-{
+int main(int, char**) {
test<std::flat_map<int, char>>();
- test<std::flat_map<int, char, std::less<int>, std::vector<int, min_allocator<int>>, std::vector<char, min_allocator<char>>>>();
+ test<std::flat_map<int,
+ char,
+ std::less<int>,
+ std::vector<int, min_allocator<int>>,
+ std::vector<char, min_allocator<char>>>>();
test<std::flat_map<int, char, std::greater<int>, std::vector<int, test_allocator<int>>>>();
test<std::flat_map<int, char, std::less<int>, std::deque<int, min_allocator<int>>>>();
test<std::flat_map<int, char, std::greater<int>, std::deque<int, test_allocator<int>>>>();
test<std::flat_map<long, int>>();
test<std::flat_map<double, int>>();
{
- using M = std::flat_map<bool, bool>;
- std::flat_map<bool, bool> fs = {{true,false}, {false,true}};
- std::same_as<size_t> auto n = std::erase_if(fs, [](M::const_reference x) { return x.first; });
- assert((fs == M{{false,true}}));
+ using M = std::flat_map<bool, bool>;
+ std::flat_map<bool, bool> fs = {{true, false}, {false, true}};
+ std::same_as<size_t> auto n = std::erase_if(fs, [](M::const_reference x) { return x.first; });
+ assert((fs == M{{false, true}}));
assert(n == 1);
n = std::erase_if(fs, [](const M::value_type& x) { return !x.first; });
assert(fs.empty());
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp
index fcda037112..ef76e1c619 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.erasure/erase_if_exceptions.pass.cpp
@@ -38,7 +38,7 @@ struct Counter {
}
}
};
-Counter g_counter = {0,0,0};
+Counter g_counter = {0, 0, 0};
struct ThrowingAssignment {
ThrowingAssignment(int i) : i_(i) {}
@@ -61,35 +61,32 @@ struct ThrowingComparator {
};
struct ErasurePredicate {
- bool operator()(const auto& x) const {
- return (3 <= x.first && x.first <= 5);
- }
+ bool operator()(const auto& x) const { return (3 <= x.first && x.first <= 5); }
};
-int main(int, char**)
-{
- const std::pair<int, int> expected[] = {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}, {7,7}, {8,8}};
+int main(int, char**) {
+ const std::pair<int, int> expected[] = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}, {7, 7}, {8, 8}};
{
using M = std::flat_map<ThrowingAssignment, int, ThrowingComparator>;
for (int first_throw = 1; first_throw < 99; ++first_throw) {
for (int second_throw = 1; second_throw < 99; ++second_throw) {
- g_counter = {0,0,0};
- M m = M({1,2,3,4,5,6,7,8}, {1,2,3,4,5,6,7,8});
+ g_counter = {0, 0, 0};
+ M m = M({1, 2, 3, 4, 5, 6, 7, 8}, {1, 2, 3, 4, 5, 6, 7, 8});
try {
g_counter = {first_throw, second_throw, 0};
- auto n = std::erase_if(m, ErasurePredicate());
+ auto n = std::erase_if(m, ErasurePredicate());
assert(n == 3);
// If it didn't throw at all, we're done.
- g_counter = {0,0,0};
- assert((m == M{{1,1}, {2,2}, {6,6}, {7,7}, {8,8}}));
- first_throw = 99; // "done"
+ g_counter = {0, 0, 0};
+ assert((m == M{{1, 1}, {2, 2}, {6, 6}, {7, 7}, {8, 8}}));
+ first_throw = 99; // "done"
break;
} catch (int ex) {
assert(ex == 42);
- assert(m.keys().size() == m.values().size()); // still sized correctly
- assert(std::is_sorted(m.begin(), m.end())); // still sorted
+ assert(m.keys().size() == m.values().size()); // still sized correctly
+ assert(std::is_sorted(m.begin(), m.end())); // still sorted
assert(std::adjacent_find(m.begin(), m.end()) == m.end()); // still contains no duplicates
- LIBCPP_ASSERT(m.empty() || std::equal(m.begin(), m.end(), expected, expected+8));
+ LIBCPP_ASSERT(m.empty() || std::equal(m.begin(), m.end(), expected, expected + 8));
if (g_counter.throws == 1) {
// We reached the first throw but not the second throw.
break;
@@ -102,23 +99,23 @@ int main(int, char**)
using M = std::flat_map<int, ThrowingAssignment, ThrowingComparator>;
for (int first_throw = 1; first_throw < 99; ++first_throw) {
for (int second_throw = 1; second_throw < 99; ++second_throw) {
- g_counter = {0,0,0};
- M m = M({1,2,3,4,5,6,7,8}, {1,2,3,4,5,6,7,8});
+ g_counter = {0, 0, 0};
+ M m = M({1, 2, 3, 4, 5, 6, 7, 8}, {1, 2, 3, 4, 5, 6, 7, 8});
try {
g_counter = {first_throw, second_throw, 0};
- auto n = std::erase_if(m, ErasurePredicate());
+ auto n = std::erase_if(m, ErasurePredicate());
assert(n == 3);
// If it didn't throw at all, we're done.
- g_counter = {0,0,0};
- assert((m == M{{1,1}, {2,2}, {6,6}, {7,7}, {8,8}}));
- first_throw = 99; // "done"
+ g_counter = {0, 0, 0};
+ assert((m == M{{1, 1}, {2, 2}, {6, 6}, {7, 7}, {8, 8}}));
+ first_throw = 99; // "done"
break;
} catch (int ex) {
assert(ex == 42);
- assert(m.keys().size() == m.values().size()); // still sized correctly
- assert(std::is_sorted(m.begin(), m.end())); // still sorted
+ assert(m.keys().size() == m.values().size()); // still sized correctly
+ assert(std::is_sorted(m.begin(), m.end())); // still sorted
assert(std::adjacent_find(m.begin(), m.end()) == m.end()); // still contains no duplicates
- LIBCPP_ASSERT(m.empty() || std::equal(m.begin(), m.end(), expected, expected+8));
+ LIBCPP_ASSERT(m.empty() || std::equal(m.begin(), m.end(), expected, expected + 8));
if (g_counter.throws == 1) {
// We reached the first throw but not the second throw.
break;
@@ -128,28 +125,29 @@ int main(int, char**)
}
}
{
- using M = std::flat_map<ThrowingAssignment, int, ThrowingComparator, std::deque<ThrowingAssignment>, std::deque<int>>;
+ using M =
+ std::flat_map<ThrowingAssignment, int, ThrowingComparator, std::deque<ThrowingAssignment>, std::deque<int>>;
for (int first_throw = 1; first_throw < 99; ++first_throw) {
for (int second_throw = 1; second_throw < 99; ++second_throw) {
- g_counter = {0,0,0};
- std::deque<ThrowingAssignment> container = {5,6,7,8};
- container.insert(container.begin(), {1,2,3,4});
- M m = M(std::move(container), {1,2,3,4,5,6,7,8});
+ g_counter = {0, 0, 0};
+ std::deque<ThrowingAssignment> container = {5, 6, 7, 8};
+ container.insert(container.begin(), {1, 2, 3, 4});
+ M m = M(std::move(container), {1, 2, 3, 4, 5, 6, 7, 8});
try {
g_counter = {first_throw, second_throw, 0};
- auto n = std::erase_if(m, ErasurePredicate());
+ auto n = std::erase_if(m, ErasurePredicate());
assert(n == 3);
// If it didn't throw at all, we're done.
- g_counter = {0,0,0};
- assert((m == M{{1,1}, {2,2}, {6,6}, {7,7}, {8,8}}));
- first_throw = 99; // "done"
+ g_counter = {0, 0, 0};
+ assert((m == M{{1, 1}, {2, 2}, {6, 6}, {7, 7}, {8, 8}}));
+ first_throw = 99; // "done"
break;
} catch (int ex) {
assert(ex == 42);
- assert(m.keys().size() == m.values().size()); // still sized correctly
- assert(std::is_sorted(m.begin(), m.end())); // still sorted
+ assert(m.keys().size() == m.values().size()); // still sized correctly
+ assert(std::is_sorted(m.begin(), m.end())); // still sorted
assert(std::adjacent_find(m.begin(), m.end()) == m.end()); // still contains no duplicates
- LIBCPP_ASSERT(m.empty() || std::equal(m.begin(), m.end(), expected, expected+8));
+ LIBCPP_ASSERT(m.empty() || std::equal(m.begin(), m.end(), expected, expected + 8));
if (g_counter.throws == 1) {
// We reached the first throw but not the second throw.
break;
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/incomplete_type.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/incomplete_type.pass.cpp
index 68a40dd5b7..a96d0d8c1a 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/incomplete_type.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/incomplete_type.pass.cpp
@@ -26,7 +26,7 @@ struct A {
};
// Implement the operator< required in order to instantiate flat_map<A, X>
-bool operator<(A const& L, A const& R) { return L.data < R.data; }
+bool operator<(A const& L, A const& R) { return L.data < R.data; }
int main(int, char**) {
A a;
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/insert_range.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/insert_range.pass.cpp
index 513f72f11c..30843ee982 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/insert_range.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/insert_range.pass.cpp
@@ -25,29 +25,28 @@
#include "test_iterators.h"
#include "min_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
- using P = std::pair<int, int>;
- using M = std::flat_map<int, int>;
- using It = forward_iterator<const P*>;
- M m = {{10,1}, {8,2}, {5,3}, {2,4}, {1,5}};
- P ar[] = {{3,1}, {1,2}, {4,3}, {1,4}, {5,5}, {9,6}};
- std::ranges::subrange r = { It(ar), It(ar + 6) };
+ using P = std::pair<int, int>;
+ using M = std::flat_map<int, int>;
+ using It = forward_iterator<const P*>;
+ M m = {{10, 1}, {8, 2}, {5, 3}, {2, 4}, {1, 5}};
+ P ar[] = {{3, 1}, {1, 2}, {4, 3}, {1, 4}, {5, 5}, {9, 6}};
+ std::ranges::subrange r = {It(ar), It(ar + 6)};
static_assert(std::ranges::common_range<decltype(r)>);
m.insert_range(r);
- assert((m == M{{1,5}, {2,4}, {3,1}, {4,3}, {5,3}, {8,2}, {9,6}, {10,1}}));
+ assert((m == M{{1, 5}, {2, 4}, {3, 1}, {4, 3}, {5, 3}, {8, 2}, {9, 6}, {10, 1}}));
}
{
- using P = std::pair<int, int>;
- using M = std::flat_map<int, int, std::greater<>, std::deque<int, min_allocator<int>>>;
- using It = cpp20_input_iterator<const P*>;
- M m = {{8,1}, {5,2}, {3,3}, {2,4}};
- P ar[] = {{3,1}, {1,2}, {4,3}, {1,4}, {5,5}, {9,6}};
- std::ranges::subrange r = { It(ar), sentinel_wrapper<It>(It(ar + 6)) };
+ using P = std::pair<int, int>;
+ using M = std::flat_map<int, int, std::greater<>, std::deque<int, min_allocator<int>>>;
+ using It = cpp20_input_iterator<const P*>;
+ M m = {{8, 1}, {5, 2}, {3, 3}, {2, 4}};
+ P ar[] = {{3, 1}, {1, 2}, {4, 3}, {1, 4}, {5, 5}, {9, 6}};
+ std::ranges::subrange r = {It(ar), sentinel_wrapper<It>(It(ar + 6))};
static_assert(!std::ranges::common_range<decltype(r)>);
m.insert_range(r);
- assert((m == M{{1,2}, {2,4}, {3,3}, {4,3}, {5,2}, {8,1}, {9,6}}));
+ assert((m == M{{1, 2}, {2, 4}, {3, 3}, {4, 3}, {5, 2}, {8, 1}, {9, 6}}));
}
{
// The "uniquing" part uses the comparator, not operator==.
@@ -56,10 +55,10 @@ int main(int, char**)
};
using P = std::pair<int, int>;
using M = std::flat_map<int, int, ModTen>;
- M m = {{21,0}, {43,0}, {15,0}, {37,0}};
- P ar[] = {{33,1}, {18,1}, {55,1}, {18,1}, {42,1}};
+ M m = {{21, 0}, {43, 0}, {15, 0}, {37, 0}};
+ P ar[] = {{33, 1}, {18, 1}, {55, 1}, {18, 1}, {42, 1}};
m.insert_range(ar);
- assert((m == M{{21,0}, {42,1}, {43,0}, {15,0}, {37,0}, {18,1}}));
+ assert((m == M{{21, 0}, {42, 1}, {43, 0}, {15, 0}, {37, 0}, {18, 1}}));
}
{
// The "uniquing" part uses the comparator, not operator==.
@@ -68,26 +67,26 @@ int main(int, char**)
};
using P = std::pair<int, int>;
using M = std::flat_map<int, int, ModTen>;
- M m = {{21,0}, {43,0}, {15,0}, {37,0}};
- P ar[] = {{33,1}, {18,1}, {55,1}, {28,1}, {42,1}};
+ M m = {{21, 0}, {43, 0}, {15, 0}, {37, 0}};
+ P ar[] = {{33, 1}, {18, 1}, {55, 1}, {28, 1}, {42, 1}};
m.insert_range(ar);
- LIBCPP_ASSERT((m == M{{21,0}, {42,1}, {43,0}, {15,0}, {37,0}, {18,1}}));
+ LIBCPP_ASSERT((m == M{{21, 0}, {42, 1}, {43, 0}, {15, 0}, {37, 0}, {18, 1}}));
}
{
// Items are forwarded correctly from the input range (P2767).
- std::pair<MoveOnly, MoveOnly> a[] = {{3,3}, {1,1}, {4,4}, {1,1}, {5,5}};
+ std::pair<MoveOnly, MoveOnly> a[] = {{3, 3}, {1, 1}, {4, 4}, {1, 1}, {5, 5}};
std::flat_map<MoveOnly, MoveOnly> m;
m.insert_range(a | std::views::as_rvalue);
- std::pair<MoveOnly, MoveOnly> expected[] = {{1,1}, {3,3}, {4,4}, {5,5}};
+ std::pair<MoveOnly, MoveOnly> expected[] = {{1, 1}, {3, 3}, {4, 4}, {5, 5}};
assert(std::ranges::equal(m, expected));
}
{
// The element type of the range doesn't need to be std::pair (P2767).
- std::pair<int, int> pa[] = {{3,3}, {1,1}, {4,4}, {1,1}, {5,5}};
- std::deque<std::reference_wrapper<std::pair<int, int>>> a(pa, pa+5);
+ std::pair<int, int> pa[] = {{3, 3}, {1, 1}, {4, 4}, {1, 1}, {5, 5}};
+ std::deque<std::reference_wrapper<std::pair<int, int>>> a(pa, pa + 5);
std::flat_map<int, int> m;
m.insert_range(a);
- std::pair<int, int> expected[] = {{1,1}, {3,3}, {4,4}, {5,5}};
+ std::pair<int, int> expected[] = {{1, 1}, {3, 3}, {4, 4}, {5, 5}};
assert(std::ranges::equal(m, expected));
}
return 0;
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/insert_range_stability.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/insert_range_stability.pass.cpp
index 426067105b..f30d2761fc 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/insert_range_stability.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/insert_range_stability.pass.cpp
@@ -31,14 +31,13 @@ struct Mod256 {
bool operator()(int x, int y) const { return (x % 256) < (y % 256); }
};
-int main(int, char**)
-{
+int main(int, char**) {
{
std::mt19937 randomness;
std::pair<uint16_t, uint16_t> pairs[400];
for (int i = 0; i < 400; ++i) {
uint16_t r = randomness();
- pairs[i] = {r, r};
+ pairs[i] = {r, r};
}
std::map<uint16_t, uint16_t, Mod256> m(pairs, pairs + 200);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/insert_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/insert_transparent.pass.cpp
index 14fc0fab59..ebbb6dfd8b 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/insert_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/insert_transparent.pass.cpp
@@ -24,7 +24,7 @@
#include "min_allocator.h"
static int expensive_comparisons = 0;
-static int cheap_comparisons = 0;
+static int cheap_comparisons = 0;
struct CompareCounter {
int i_ = 0;
@@ -40,18 +40,17 @@ struct CompareCounter {
}
};
-int main(int, char**)
-{
- const std::pair<int, int> expected[] = {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}};
+int main(int, char**) {
+ const std::pair<int, int> expected[] = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}};
{
// insert(P&&)
// Unlike flat_set, here we can't use key_compare to compare value_type versus P,
// so we must eagerly convert to value_type.
- using M = std::flat_map<CompareCounter, int, std::less<>>;
- M m = {{1,1}, {2,2}, {4,4}, {5,5}};
- expensive_comparisons = 0;
- cheap_comparisons = 0;
- std::same_as<std::pair<M::iterator, bool>> auto p = m.insert(std::make_pair(3,3)); // conversion happens first
+ using M = std::flat_map<CompareCounter, int, std::less<>>;
+ M m = {{1, 1}, {2, 2}, {4, 4}, {5, 5}};
+ expensive_comparisons = 0;
+ cheap_comparisons = 0;
+ std::same_as<std::pair<M::iterator, bool>> auto p = m.insert(std::make_pair(3, 3)); // conversion happens first
assert(expensive_comparisons >= 2);
assert(cheap_comparisons == 0);
assert(p == std::make_pair(m.begin() + 2, true));
@@ -59,11 +58,11 @@ int main(int, char**)
}
{
// insert(const_iterator, P&&)
- using M = std::flat_map<CompareCounter, int, std::less<>>;
- M m = {{1,1}, {2,2}, {4,4}, {5,5}};
- expensive_comparisons = 0;
- cheap_comparisons = 0;
- std::same_as<M::iterator> auto it = m.insert(m.begin(), std::make_pair(3,3));
+ using M = std::flat_map<CompareCounter, int, std::less<>>;
+ M m = {{1, 1}, {2, 2}, {4, 4}, {5, 5}};
+ expensive_comparisons = 0;
+ cheap_comparisons = 0;
+ std::same_as<M::iterator> auto it = m.insert(m.begin(), std::make_pair(3, 3));
assert(expensive_comparisons >= 2);
assert(cheap_comparisons == 0);
assert(it == m.begin() + 2);
@@ -71,11 +70,11 @@ int main(int, char**)
}
{
// insert(value_type&&)
- using M = std::flat_map<CompareCounter, int>;
- M m = {{1,1}, {2,2}, {4,4}, {5,5}};
- expensive_comparisons = 0;
- cheap_comparisons = 0;
- std::same_as<std::pair<M::iterator, bool>> auto p = m.insert(std::make_pair(3,3)); // conversion happens last
+ using M = std::flat_map<CompareCounter, int>;
+ M m = {{1, 1}, {2, 2}, {4, 4}, {5, 5}};
+ expensive_comparisons = 0;
+ cheap_comparisons = 0;
+ std::same_as<std::pair<M::iterator, bool>> auto p = m.insert(std::make_pair(3, 3)); // conversion happens last
assert(expensive_comparisons >= 2);
assert(cheap_comparisons == 0);
assert(p == std::make_pair(m.begin() + 2, true));
@@ -83,11 +82,11 @@ int main(int, char**)
}
{
// insert(const_iterator, value_type&&)
- using M = std::flat_map<CompareCounter, int>;
- M m = {{1,1}, {2,2}, {4,4}, {5,5}};
- expensive_comparisons = 0;
- cheap_comparisons = 0;
- std::same_as<M::iterator> auto it = m.insert(m.begin(), std::make_pair(3,3));
+ using M = std::flat_map<CompareCounter, int>;
+ M m = {{1, 1}, {2, 2}, {4, 4}, {5, 5}};
+ expensive_comparisons = 0;
+ cheap_comparisons = 0;
+ std::same_as<M::iterator> auto it = m.insert(m.begin(), std::make_pair(3, 3));
assert(expensive_comparisons >= 2);
assert(cheap_comparisons == 0);
assert(it == m.begin() + 2);
@@ -95,11 +94,11 @@ int main(int, char**)
}
{
// emplace(Args&&...)
- using M = std::flat_map<CompareCounter, int>;
- M m = {{1,1}, {2,2}, {4,4}, {5,5}};
- expensive_comparisons = 0;
- cheap_comparisons = 0;
- std::same_as<std::pair<M::iterator, bool>> auto p = m.emplace(std::make_pair(3,3)); // conversion happens first
+ using M = std::flat_map<CompareCounter, int>;
+ M m = {{1, 1}, {2, 2}, {4, 4}, {5, 5}};
+ expensive_comparisons = 0;
+ cheap_comparisons = 0;
+ std::same_as<std::pair<M::iterator, bool>> auto p = m.emplace(std::make_pair(3, 3)); // conversion happens first
assert(expensive_comparisons >= 2);
assert(cheap_comparisons == 0);
assert(p == std::make_pair(m.begin() + 2, true));
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/iterator.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/iterator.pass.cpp
index 20e941cb64..4cd3991f82 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/iterator.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/iterator.pass.cpp
@@ -27,11 +27,10 @@
#include "test_macros.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
using M = std::flat_map<int, char, std::less<int>, std::deque<int>, std::deque<char>>;
- M m = {{1,'a'}, {2,'b'}, {3,'c'}, {4,'d'}};
+ M m = {{1, 'a'}, {2, 'b'}, {3, 'c'}, {4, 'd'}};
ASSERT_SAME_TYPE(decltype(m.begin()), M::iterator);
ASSERT_SAME_TYPE(decltype(m.cbegin()), M::const_iterator);
ASSERT_SAME_TYPE(decltype(m.end()), M::iterator);
@@ -39,25 +38,25 @@ int main(int, char**)
assert(m.size() == 4);
assert(std::distance(m.begin(), m.end()) == 4);
assert(std::distance(m.cbegin(), m.cend()) == 4);
- M::iterator i; // default-construct
- i = m.begin(); // move-assignment
- M::const_iterator k = i; // converting constructor
- assert(i == k); // comparison
- for (int j = 1; j <= 4; ++j, ++i) { // pre-increment
- assert(i->first == j); // operator->
+ M::iterator i; // default-construct
+ i = m.begin(); // move-assignment
+ M::const_iterator k = i; // converting constructor
+ assert(i == k); // comparison
+ for (int j = 1; j <= 4; ++j, ++i) { // pre-increment
+ assert(i->first == j); // operator->
assert(i->second == 'a' + j - 1);
}
assert(i == m.end());
for (int j = 4; j >= 1; --j) {
- --i; // pre-decrement
+ --i; // pre-decrement
assert((*i).first == j);
assert((*i).second == 'a' + j - 1);
}
assert(i == m.begin());
}
{
- using M = std::flat_map<short, char, std::less<>, std::deque<short>, std::string>;
- const M m = {{1,'a'}, {2,'b'}, {3,'c'}, {4,'d'}};
+ using M = std::flat_map<short, char, std::less<>, std::deque<short>, std::string>;
+ const M m = {{1, 'a'}, {2, 'b'}, {3, 'c'}, {4, 'd'}};
ASSERT_SAME_TYPE(decltype(m.begin()), M::const_iterator);
ASSERT_SAME_TYPE(decltype(m.cbegin()), M::const_iterator);
ASSERT_SAME_TYPE(decltype(m.end()), M::const_iterator);
@@ -65,15 +64,15 @@ int main(int, char**)
assert(m.size() == 4);
assert(std::distance(m.begin(), m.end()) == 4);
assert(std::distance(m.cbegin(), m.cend()) == 4);
- M::const_iterator i; // default-construct
- i = m.begin(); // move-assignment
- for (int j = 1; j <= 4; ++j, ++i) { // pre-increment
+ M::const_iterator i; // default-construct
+ i = m.begin(); // move-assignment
+ for (int j = 1; j <= 4; ++j, ++i) { // pre-increment
assert(i->first == j);
assert(i->second == 'a' + j - 1);
}
assert(i == m.end());
for (int j = 4; j >= 1; --j) {
- --i; // pre-decrement
+ --i; // pre-decrement
assert((*i).first == j);
assert((*i).second == 'a' + j - 1);
}
@@ -89,8 +88,8 @@ int main(int, char**)
assert(ii1 == ii4);
assert(!(ii1 != ii2));
- assert( (ii1 == cii));
- assert( (cii == ii1));
+ assert((ii1 == cii));
+ assert((cii == ii1));
assert(!(ii1 != cii));
assert(!(cii != ii1));
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/iterator_comparison.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/iterator_comparison.pass.cpp
index 22ebc599b3..cc7fa751f4 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/iterator_comparison.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/iterator_comparison.pass.cpp
@@ -22,16 +22,15 @@
#include "MinSequenceContainer.h"
#include "test_macros.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
- using V = MinSequenceContainer<int, random_access_iterator<int*>, random_access_iterator<const int*>>;
- using M = std::flat_map<int, int, std::less<int>, V, V>;
- using VI = V::iterator;
+ using V = MinSequenceContainer<int, random_access_iterator<int*>, random_access_iterator<const int*>>;
+ using M = std::flat_map<int, int, std::less<int>, V, V>;
+ using VI = V::iterator;
using VCI = V::const_iterator;
- using I = M::iterator;
- using CI = M::const_iterator;
- using RI = M::reverse_iterator;
+ using I = M::iterator;
+ using CI = M::const_iterator;
+ using RI = M::reverse_iterator;
using CRI = M::const_reverse_iterator;
static_assert(!std::three_way_comparable<VI>); // But, despite this...
static_assert(!std::three_way_comparable<VCI>);
@@ -47,13 +46,13 @@ int main(int, char**)
static_assert(std::same_as<decltype(CRI() <=> CRI()), std::strong_ordering>);
}
{
- using V = MinSequenceContainer<int, int*, const int*>;
- using M = std::flat_map<int, int, std::less<int>, V, V>;
- using VI = V::iterator;
+ using V = MinSequenceContainer<int, int*, const int*>;
+ using M = std::flat_map<int, int, std::less<int>, V, V>;
+ using VI = V::iterator;
using VCI = V::const_iterator;
- using I = M::iterator;
- using CI = M::const_iterator;
- using RI = M::reverse_iterator;
+ using I = M::iterator;
+ using CI = M::const_iterator;
+ using RI = M::reverse_iterator;
using CRI = M::const_reverse_iterator;
static_assert(std::three_way_comparable<VI>); // And when VI does support <=>...
static_assert(std::three_way_comparable<VCI>);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/iterator_concept_conformance.compile.pass.cpp
index ddb68b11b2..04117a690f 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/iterator_concept_conformance.compile.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/iterator_concept_conformance.compile.pass.cpp
@@ -23,10 +23,10 @@
void test() {
{
- using C = std::flat_map<int, char>;
- using I = C::iterator;
- using CI = C::const_iterator;
- using RI = C::reverse_iterator;
+ using C = std::flat_map<int, char>;
+ using I = C::iterator;
+ using CI = C::const_iterator;
+ using RI = C::reverse_iterator;
using CRI = C::const_reverse_iterator;
static_assert(std::random_access_iterator<I>);
static_assert(std::random_access_iterator<CI>);
@@ -40,32 +40,32 @@ void test() {
static_assert(!std::indirectly_writable<CI, std::pair<int, char>>);
static_assert(!std::indirectly_writable<RI, std::pair<int, char>>);
static_assert(!std::indirectly_writable<CRI, std::pair<int, char>>);
- static_assert( std::sentinel_for<I, I>);
- static_assert( std::sentinel_for<I, CI>);
+ static_assert(std::sentinel_for<I, I>);
+ static_assert(std::sentinel_for<I, CI>);
static_assert(!std::sentinel_for<I, RI>);
static_assert(!std::sentinel_for<I, CRI>);
- static_assert( std::sentinel_for<CI, I>);
- static_assert( std::sentinel_for<CI, CI>);
+ static_assert(std::sentinel_for<CI, I>);
+ static_assert(std::sentinel_for<CI, CI>);
static_assert(!std::sentinel_for<CI, RI>);
static_assert(!std::sentinel_for<CI, CRI>);
static_assert(!std::sentinel_for<RI, I>);
static_assert(!std::sentinel_for<RI, CI>);
- static_assert( std::sentinel_for<RI, RI>);
- static_assert( std::sentinel_for<RI, CRI>);
+ static_assert(std::sentinel_for<RI, RI>);
+ static_assert(std::sentinel_for<RI, CRI>);
static_assert(!std::sentinel_for<CRI, I>);
static_assert(!std::sentinel_for<CRI, CI>);
- static_assert( std::sentinel_for<CRI, RI>);
- static_assert( std::sentinel_for<CRI, CRI>);
+ static_assert(std::sentinel_for<CRI, RI>);
+ static_assert(std::sentinel_for<CRI, CRI>);
static_assert(std::indirectly_movable_storable<I, std::pair<int, char>*>);
static_assert(std::indirectly_movable_storable<CI, std::pair<int, char>*>);
static_assert(std::indirectly_movable_storable<RI, std::pair<int, char>*>);
static_assert(std::indirectly_movable_storable<CRI, std::pair<int, char>*>);
}
{
- using C = std::flat_map<char*, int, std::less<>, std::deque<char*>, std::vector<int>>;
- using I = C::iterator;
- using CI = C::const_iterator;
- using RI = C::reverse_iterator;
+ using C = std::flat_map<char*, int, std::less<>, std::deque<char*>, std::vector<int>>;
+ using I = C::iterator;
+ using CI = C::const_iterator;
+ using RI = C::reverse_iterator;
using CRI = C::const_reverse_iterator;
static_assert(std::random_access_iterator<I>);
static_assert(std::random_access_iterator<CI>);
@@ -79,32 +79,32 @@ void test() {
static_assert(!std::indirectly_writable<CI, std::pair<char*, int>>);
static_assert(!std::indirectly_writable<RI, std::pair<char*, int>>);
static_assert(!std::indirectly_writable<CRI, std::pair<char*, int>>);
- static_assert( std::sentinel_for<I, I>);
- static_assert( std::sentinel_for<I, CI>);
+ static_assert(std::sentinel_for<I, I>);
+ static_assert(std::sentinel_for<I, CI>);
static_assert(!std::sentinel_for<I, RI>);
static_assert(!std::sentinel_for<I, CRI>);
- static_assert( std::sentinel_for<CI, I>);
- static_assert( std::sentinel_for<CI, CI>);
+ static_assert(std::sentinel_for<CI, I>);
+ static_assert(std::sentinel_for<CI, CI>);
static_assert(!std::sentinel_for<CI, RI>);
static_assert(!std::sentinel_for<CI, CRI>);
static_assert(!std::sentinel_for<RI, I>);
static_assert(!std::sentinel_for<RI, CI>);
- static_assert( std::sentinel_for<RI, RI>);
- static_assert( std::sentinel_for<RI, CRI>);
+ static_assert(std::sentinel_for<RI, RI>);
+ static_assert(std::sentinel_for<RI, CRI>);
static_assert(!std::sentinel_for<CRI, I>);
static_assert(!std::sentinel_for<CRI, CI>);
- static_assert( std::sentinel_for<CRI, RI>);
- static_assert( std::sentinel_for<CRI, CRI>);
+ static_assert(std::sentinel_for<CRI, RI>);
+ static_assert(std::sentinel_for<CRI, CRI>);
static_assert(std::indirectly_movable_storable<I, std::pair<char*, int>*>);
static_assert(std::indirectly_movable_storable<CI, std::pair<char*, int>*>);
static_assert(std::indirectly_movable_storable<RI, std::pair<char*, int>*>);
static_assert(std::indirectly_movable_storable<CRI, std::pair<char*, int>*>);
}
{
- using C = std::flat_map<char, bool, std::less<>, std::string, std::vector<bool>>;
- using I = C::iterator;
- using CI = C::const_iterator;
- using RI = C::reverse_iterator;
+ using C = std::flat_map<char, bool, std::less<>, std::string, std::vector<bool>>;
+ using I = C::iterator;
+ using CI = C::const_iterator;
+ using RI = C::reverse_iterator;
using CRI = C::const_reverse_iterator;
static_assert(std::random_access_iterator<I>);
static_assert(std::random_access_iterator<CI>);
@@ -118,22 +118,22 @@ void test() {
static_assert(!std::indirectly_writable<CI, std::pair<char, bool>>);
static_assert(!std::indirectly_writable<RI, std::pair<char, bool>>);
static_assert(!std::indirectly_writable<CRI, std::pair<char, bool>>);
- static_assert( std::sentinel_for<I, I>);
- static_assert( std::sentinel_for<I, CI>);
+ static_assert(std::sentinel_for<I, I>);
+ static_assert(std::sentinel_for<I, CI>);
static_assert(!std::sentinel_for<I, RI>);
static_assert(!std::sentinel_for<I, CRI>);
- static_assert( std::sentinel_for<CI, I>);
- static_assert( std::sentinel_for<CI, CI>);
+ static_assert(std::sentinel_for<CI, I>);
+ static_assert(std::sentinel_for<CI, CI>);
static_assert(!std::sentinel_for<CI, RI>);
static_assert(!std::sentinel_for<CI, CRI>);
static_assert(!std::sentinel_for<RI, I>);
static_assert(!std::sentinel_for<RI, CI>);
- static_assert( std::sentinel_for<RI, RI>);
- static_assert( std::sentinel_for<RI, CRI>);
+ static_assert(std::sentinel_for<RI, RI>);
+ static_assert(std::sentinel_for<RI, CRI>);
static_assert(!std::sentinel_for<CRI, I>);
static_assert(!std::sentinel_for<CRI, CI>);
- static_assert( std::sentinel_for<CRI, RI>);
- static_assert( std::sentinel_for<CRI, CRI>);
+ static_assert(std::sentinel_for<CRI, RI>);
+ static_assert(std::sentinel_for<CRI, CRI>);
static_assert(std::indirectly_movable_storable<I, std::pair<char, bool>*>);
static_assert(std::indirectly_movable_storable<CI, std::pair<char, bool>*>);
static_assert(std::indirectly_movable_storable<RI, std::pair<char, bool>*>);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/lower_bound.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/lower_bound.pass.cpp
index 8094e7771f..1e697a1c02 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/lower_bound.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/lower_bound.pass.cpp
@@ -22,11 +22,10 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
using M = std::flat_map<int, char>;
- M m = {{1,'a'}, {2,'b'}, {4,'d'}, {5,'e'}, {8,'h'}};
+ M m = {{1, 'a'}, {2, 'b'}, {4, 'd'}, {5, 'e'}, {8, 'h'}};
ASSERT_SAME_TYPE(decltype(m.lower_bound(0)), M::iterator);
ASSERT_SAME_TYPE(decltype(std::as_const(m).lower_bound(0)), M::const_iterator);
assert(m.lower_bound(0) == m.begin());
@@ -41,8 +40,13 @@ int main(int, char**)
assert(std::as_const(m).lower_bound(9) == m.end());
}
{
- using M = std::flat_map<int, char, std::greater<int>, std::deque<int, min_allocator<int>>, std::deque<char, min_allocator<char>>>;
- M m = {{1,'a'}, {2,'b'}, {4,'d'}, {5,'e'}, {8,'h'}};
+ using M =
+ std::flat_map<int,
+ char,
+ std::greater<int>,
+ std::deque<int, min_allocator<int>>,
+ std::deque<char, min_allocator<char>>>;
+ M m = {{1, 'a'}, {2, 'b'}, {4, 'd'}, {5, 'e'}, {8, 'h'}};
ASSERT_SAME_TYPE(decltype(m.lower_bound(0)), M::iterator);
ASSERT_SAME_TYPE(decltype(std::as_const(m).lower_bound(0)), M::const_iterator);
assert(m.lower_bound(0) == m.end());
@@ -58,15 +62,15 @@ int main(int, char**)
}
{
using M = std::flat_map<bool, bool>;
- M m = {{true,false}, {false,true}};
+ M m = {{true, false}, {false, true}};
ASSERT_SAME_TYPE(decltype(m.lower_bound(0)), M::iterator);
ASSERT_SAME_TYPE(decltype(std::as_const(m).lower_bound(0)), M::const_iterator);
assert(m.lower_bound(true) == m.begin() + 1);
assert(m.lower_bound(false) == m.begin());
- m = {{true,true}};
+ m = {{true, true}};
assert(m.lower_bound(true) == m.begin());
assert(m.lower_bound(false) == m.begin());
- m = {{false,false}};
+ m = {{false, false}};
assert(std::as_const(m).lower_bound(true) == m.end());
assert(std::as_const(m).lower_bound(false) == m.begin());
m.clear();
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/lower_bound_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/lower_bound_transparent.pass.cpp
index a391d099f3..867ea8a557 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/lower_bound_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/lower_bound_transparent.pass.cpp
@@ -21,8 +21,8 @@
#include "test_macros.h"
struct StartsWith {
- explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch+1) {}
- StartsWith(const StartsWith&) = delete;
+ explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch + 1) {}
+ StartsWith(const StartsWith&) = delete;
void operator=(const StartsWith&) = delete;
struct Less {
using is_transparent = void;
@@ -30,16 +30,16 @@ struct StartsWith {
bool operator()(const StartsWith& a, const std::string& b) const { return a.upper_ <= b; }
bool operator()(const std::string& a, const StartsWith& b) const { return a < b.lower_; }
};
+
private:
std::string lower_;
std::string upper_;
};
-int main(int, char**)
-{
+int main(int, char**) {
{
using M = std::flat_map<std::string, int, StartsWith::Less>;
- M m = { {"alpha", 1}, {"beta", 2}, {"epsilon", 3}, {"eta", 4}, {"gamma", 5} };
+ M m = {{"alpha", 1}, {"beta", 2}, {"epsilon", 3}, {"eta", 4}, {"gamma", 5}};
ASSERT_SAME_TYPE(decltype(m.lower_bound(StartsWith('b'))), M::iterator);
ASSERT_SAME_TYPE(decltype(std::as_const(m).lower_bound(StartsWith('b'))), M::const_iterator);
assert(m.lower_bound("beta") == m.begin() + 1);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/max_size.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/max_size.pass.cpp
index 1c21704ebd..3f464c65d4 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/max_size.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/max_size.pass.cpp
@@ -22,12 +22,11 @@
#include "test_allocator.h"
#include "test_macros.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
using A1 = limited_allocator<int, 10>;
using A2 = limited_allocator<int, 20>;
- using C = std::flat_map<int, int, std::less<int>, std::vector<int, A1>, std::vector<int, A2>>;
+ using C = std::flat_map<int, int, std::less<int>, std::vector<int, A1>, std::vector<int, A2>>;
ASSERT_SAME_TYPE(C::difference_type, std::ptrdiff_t);
ASSERT_SAME_TYPE(C::size_type, std::size_t);
C c;
@@ -39,7 +38,7 @@ int main(int, char**)
{
using A1 = limited_allocator<int, 10>;
using A2 = limited_allocator<int, 20>;
- using C = std::flat_map<int, int, std::less<int>, std::vector<int, A2>, std::vector<int, A1>>;
+ using C = std::flat_map<int, int, std::less<int>, std::vector<int, A2>, std::vector<int, A1>>;
ASSERT_SAME_TYPE(C::difference_type, std::ptrdiff_t);
ASSERT_SAME_TYPE(C::size_type, std::size_t);
C c;
@@ -53,8 +52,7 @@ int main(int, char**)
using C = std::flat_map<int, int, std::less<int>, std::vector<int, A>, std::vector<int, A>>;
ASSERT_SAME_TYPE(C::difference_type, std::ptrdiff_t);
ASSERT_SAME_TYPE(C::size_type, std::size_t);
- const C::size_type max_dist =
- static_cast<C::size_type>(std::numeric_limits<C::difference_type>::max());
+ const C::size_type max_dist = static_cast<C::size_type>(std::numeric_limits<C::difference_type>::max());
C c;
ASSERT_NOEXCEPT(c.max_size());
ASSERT_SAME_TYPE(decltype(c.max_size()), C::size_type);
@@ -65,8 +63,7 @@ int main(int, char**)
typedef std::flat_map<char, char> C;
ASSERT_SAME_TYPE(C::difference_type, std::ptrdiff_t);
ASSERT_SAME_TYPE(C::size_type, std::size_t);
- const C::size_type max_dist =
- static_cast<C::size_type>(std::numeric_limits<C::difference_type>::max());
+ const C::size_type max_dist = static_cast<C::size_type>(std::numeric_limits<C::difference_type>::max());
C c;
ASSERT_NOEXCEPT(c.max_size());
ASSERT_SAME_TYPE(decltype(c.max_size()), C::size_type);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/op_compare.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/op_compare.pass.cpp
index 586933c640..4b29ad80a5 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/op_compare.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/op_compare.pass.cpp
@@ -27,53 +27,53 @@
int main(int, char**) {
{
using C = std::flat_map<int, int>;
- C s1 = {{1,1}};
- C s2 = {{2,0}}; // {{1,1}} versus {{2,0}}
+ C s1 = {{1, 1}};
+ C s2 = {{2, 0}}; // {{1,1}} versus {{2,0}}
ASSERT_SAME_TYPE(decltype(s1 <=> s2), std::strong_ordering);
AssertComparisonsReturnBool<C>();
assert(testComparisons(s1, s2, false, true));
- s2 = {{1,1}}; // {{1,1}} versus {{1,1}}
+ s2 = {{1, 1}}; // {{1,1}} versus {{1,1}}
assert(testComparisons(s1, s2, true, false));
- s2 = {{1,1},{2,0}}; // {{1,1}} versus {{1,1},{2,0}}
+ s2 = {{1, 1}, {2, 0}}; // {{1,1}} versus {{1,1},{2,0}}
assert(testComparisons(s1, s2, false, true));
- s1 = {{0,0},{1,1},{2,2}}; // {{0,0},{1,1},{2,2}} versus {{1,1},{2,0}}
+ s1 = {{0, 0}, {1, 1}, {2, 2}}; // {{0,0},{1,1},{2,2}} versus {{1,1},{2,0}}
assert(testComparisons(s1, s2, false, true));
- s2 = {{0,0},{1,1},{2,3}}; // {{0,0},{1,1},{2,2}} versus {{0,0},{1,1},{2,3}}
+ s2 = {{0, 0}, {1, 1}, {2, 3}}; // {{0,0},{1,1},{2,2}} versus {{0,0},{1,1},{2,3}}
assert(testComparisons(s1, s2, false, true));
}
{
// Comparisons use value_type's native operators, not the comparator
using C = std::flat_map<int, int, std::greater<int>>;
- C s1 = {{1,1}};
- C s2 = {{2,0}}; // {{1,1}} versus {{2,0}}
+ C s1 = {{1, 1}};
+ C s2 = {{2, 0}}; // {{1,1}} versus {{2,0}}
ASSERT_SAME_TYPE(decltype(s1 <=> s2), std::strong_ordering);
AssertComparisonsReturnBool<C>();
assert(testComparisons(s1, s2, false, true));
- s2 = {{1,1}}; // {{1,1}} versus {{1,1}}
+ s2 = {{1, 1}}; // {{1,1}} versus {{1,1}}
assert(testComparisons(s1, s2, true, false));
- s2 = {{1,1},{2,0}}; // {{1,1}} versus {{2,0},{1,1}}
+ s2 = {{1, 1}, {2, 0}}; // {{1,1}} versus {{2,0},{1,1}}
assert(testComparisons(s1, s2, false, true));
- s1 = {{0,0},{1,1},{2,2}}; // {{2,2},{1,1},{0,0}} versus {2,0},{1,1}}
+ s1 = {{0, 0}, {1, 1}, {2, 2}}; // {{2,2},{1,1},{0,0}} versus {2,0},{1,1}}
assert(testComparisons(s1, s2, false, false));
- s2 = {{0,0},{1,1},{2,3}}; // {{2,2},{1,1},{0,0}} versus {{2,3},{1,1},{0,0}}
+ s2 = {{0, 0}, {1, 1}, {2, 3}}; // {{2,2},{1,1},{0,0}} versus {{2,3},{1,1},{0,0}}
assert(testComparisons(s1, s2, false, true));
}
{
using C = std::flat_map<double, int>;
- C s1 = { {1, 1} };
- C s2 = C(std::sorted_unique, { {std::numeric_limits<double>::quiet_NaN(), 2} });
+ C s1 = {{1, 1}};
+ C s2 = C(std::sorted_unique, {{std::numeric_limits<double>::quiet_NaN(), 2}});
ASSERT_SAME_TYPE(decltype(s1 <=> s2), std::partial_ordering);
AssertComparisonsReturnBool<C>();
assert(testComparisonsComplete(s1, s2, false, false, false));
}
{
using C = std::flat_map<int, double>;
- C s1 = { {1, 1} };
- C s2 = C(std::sorted_unique, { {2, std::numeric_limits<double>::quiet_NaN()} });
+ C s1 = {{1, 1}};
+ C s2 = C(std::sorted_unique, {{2, std::numeric_limits<double>::quiet_NaN()}});
ASSERT_SAME_TYPE(decltype(s1 <=> s2), std::partial_ordering);
AssertComparisonsReturnBool<C>();
assert(testComparisonsComplete(s1, s2, false, true, false));
- s2 = C(std::sorted_unique, { {1, std::numeric_limits<double>::quiet_NaN()} });
+ s2 = C(std::sorted_unique, {{1, std::numeric_limits<double>::quiet_NaN()}});
assert(testComparisonsComplete(s1, s2, false, false, false));
}
{
@@ -82,14 +82,16 @@ int main(int, char**) {
bool operator()(double a, double b) const { return std::strong_order(a, b) < 0; }
};
using C = std::flat_map<double, double, StrongComp>;
- C s1 = {{1, 1}};
- C s2 = { {std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()} };
+ C s1 = {{1, 1}};
+ C s2 = {{std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()}};
ASSERT_SAME_TYPE(decltype(s1 <=> s2), std::partial_ordering);
AssertComparisonsReturnBool<C>();
assert(testComparisonsComplete(s1, s2, false, false, false));
- s1 = { { {1, 1}, {std::numeric_limits<double>::quiet_NaN(), 1} } };
- s2 = { { {std::numeric_limits<double>::quiet_NaN(), 1}, {1, 1} } };
- assert(std::lexicographical_compare_three_way(s1.keys().begin(), s1.keys().end(), s2.keys().begin(), s2.keys().end(), std::strong_order) == std::strong_ordering::equal);
+ s1 = {{{1, 1}, {std::numeric_limits<double>::quiet_NaN(), 1}}};
+ s2 = {{{std::numeric_limits<double>::quiet_NaN(), 1}, {1, 1}}};
+ assert(std::lexicographical_compare_three_way(
+ s1.keys().begin(), s1.keys().end(), s2.keys().begin(), s2.keys().end(), std::strong_order) ==
+ std::strong_ordering::equal);
assert(s1 != s2);
assert((s1 <=> s2) == std::partial_ordering::unordered);
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/reverse_iterator.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/reverse_iterator.pass.cpp
index 3afdb56d48..fc21a49d70 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/reverse_iterator.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/reverse_iterator.pass.cpp
@@ -27,11 +27,10 @@
#include "test_macros.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
using M = std::flat_map<int, char, std::less<int>, std::deque<int>, std::deque<char>>;
- M m = {{1,'a'}, {2,'b'}, {3,'c'}, {4,'d'}};
+ M m = {{1, 'a'}, {2, 'b'}, {3, 'c'}, {4, 'd'}};
ASSERT_SAME_TYPE(decltype(m.rbegin()), M::reverse_iterator);
ASSERT_SAME_TYPE(decltype(m.crbegin()), M::const_reverse_iterator);
ASSERT_SAME_TYPE(decltype(m.rend()), M::reverse_iterator);
@@ -39,27 +38,27 @@ int main(int, char**)
assert(m.size() == 4);
assert(std::distance(m.rbegin(), m.rend()) == 4);
assert(std::distance(m.crbegin(), m.crend()) == 4);
- M::reverse_iterator i; // default-construct
+ M::reverse_iterator i; // default-construct
ASSERT_SAME_TYPE(decltype(i->first), const int&);
ASSERT_SAME_TYPE(decltype(i->second), char&);
- 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
- assert(i->first == j); // operator->
+ 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
+ assert(i->first == j); // operator->
assert(i->second == 'a' + j - 1);
}
assert(i == m.rend());
for (int j = 1; j <= 4; ++j) {
- --i; // pre-decrement
+ --i; // pre-decrement
assert((*i).first == j);
assert((*i).second == 'a' + j - 1);
}
assert(i == m.rbegin());
}
{
- using M = std::flat_map<short, char, std::less<>, std::deque<short>, std::string>;
- const M m = {{1,'a'}, {2,'b'}, {3,'c'}, {4,'d'}};
+ using M = std::flat_map<short, char, std::less<>, std::deque<short>, std::string>;
+ const M m = {{1, 'a'}, {2, 'b'}, {3, 'c'}, {4, 'd'}};
ASSERT_SAME_TYPE(decltype(m.rbegin()), M::const_reverse_iterator);
ASSERT_SAME_TYPE(decltype(m.crbegin()), M::const_reverse_iterator);
ASSERT_SAME_TYPE(decltype(m.rend()), M::const_reverse_iterator);
@@ -67,17 +66,17 @@ int main(int, char**)
assert(m.size() == 4);
assert(std::distance(m.rbegin(), m.rend()) == 4);
assert(std::distance(m.crbegin(), m.crend()) == 4);
- M::const_reverse_iterator i; // default-construct
+ M::const_reverse_iterator i; // default-construct
ASSERT_SAME_TYPE(decltype(i->first), const short&);
ASSERT_SAME_TYPE(decltype(i->second), const char&);
- i = m.rbegin(); // move-assignment
- for (int j = 4; j >= 1; --j, ++i) { // pre-increment
+ i = m.rbegin(); // move-assignment
+ for (int j = 4; j >= 1; --j, ++i) { // pre-increment
assert(i->first == j);
assert(i->second == 'a' + j - 1);
}
assert(i == m.rend());
for (int j = 1; j <= 4; ++j) {
- --i; // pre-decrement
+ --i; // pre-decrement
assert((*i).first == j);
assert((*i).second == 'a' + j - 1);
}
@@ -93,8 +92,8 @@ int main(int, char**)
assert(ii1 == ii4);
assert(!(ii1 != ii2));
- assert( (ii1 == cii));
- assert( (cii == ii1));
+ assert((ii1 == cii));
+ assert((cii == ii1));
assert(!(ii1 != cii));
assert(!(cii != ii1));
}
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/types.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/types.pass.cpp
index d3aba8b141..02d2d799db 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/types.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/types.pass.cpp
@@ -39,8 +39,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
using C = std::flat_map<int, short>;
static_assert(std::is_same_v<C::key_type, int>);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/upper_bound.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/upper_bound.pass.cpp
index 76238c16b1..4058bdd4b6 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/upper_bound.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/upper_bound.pass.cpp
@@ -22,11 +22,10 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**)
-{
+int main(int, char**) {
{
using M = std::flat_map<int, char>;
- M m = {{1,'a'}, {2,'b'}, {4,'d'}, {5,'e'}, {8,'h'}};
+ M m = {{1, 'a'}, {2, 'b'}, {4, 'd'}, {5, 'e'}, {8, 'h'}};
ASSERT_SAME_TYPE(decltype(m.upper_bound(0)), M::iterator);
ASSERT_SAME_TYPE(decltype(std::as_const(m).upper_bound(0)), M::const_iterator);
assert(m.upper_bound(0) == m.begin());
@@ -41,8 +40,13 @@ int main(int, char**)
assert(std::as_const(m).upper_bound(9) == m.end());
}
{
- using M = std::flat_map<int, char, std::greater<int>, std::deque<int, min_allocator<int>>, std::deque<char, min_allocator<char>>>;
- M m = {{1,'a'}, {2,'b'}, {4,'d'}, {5,'e'}, {8,'h'}};
+ using M =
+ std::flat_map<int,
+ char,
+ std::greater<int>,
+ std::deque<int, min_allocator<int>>,
+ std::deque<char, min_allocator<char>>>;
+ M m = {{1, 'a'}, {2, 'b'}, {4, 'd'}, {5, 'e'}, {8, 'h'}};
ASSERT_SAME_TYPE(decltype(m.upper_bound(0)), M::iterator);
ASSERT_SAME_TYPE(decltype(std::as_const(m).upper_bound(0)), M::const_iterator);
assert(m.upper_bound(0) == m.end());
@@ -58,15 +62,15 @@ int main(int, char**)
}
{
using M = std::flat_map<bool, bool>;
- M m = {{true,false}, {false,true}};
+ M m = {{true, false}, {false, true}};
ASSERT_SAME_TYPE(decltype(m.upper_bound(0)), M::iterator);
ASSERT_SAME_TYPE(decltype(std::as_const(m).upper_bound(0)), M::const_iterator);
assert(m.upper_bound(true) == m.end());
assert(m.upper_bound(false) == m.begin() + 1);
- m = {{true,true}};
+ m = {{true, true}};
assert(m.upper_bound(true) == m.end());
assert(m.upper_bound(false) == m.begin());
- m = {{false,false}};
+ m = {{false, false}};
assert(std::as_const(m).upper_bound(true) == m.end());
assert(std::as_const(m).upper_bound(false) == m.end());
m.clear();
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/upper_bound_transparent.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/upper_bound_transparent.pass.cpp
index 745a250c06..3f5d3f5aa8 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/upper_bound_transparent.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/upper_bound_transparent.pass.cpp
@@ -21,8 +21,8 @@
#include "test_macros.h"
struct StartsWith {
- explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch+1) {}
- StartsWith(const StartsWith&) = delete;
+ explicit StartsWith(char ch) : lower_(1, ch), upper_(1, ch + 1) {}
+ StartsWith(const StartsWith&) = delete;
void operator=(const StartsWith&) = delete;
struct Less {
using is_transparent = void;
@@ -30,16 +30,16 @@ struct StartsWith {
bool operator()(const StartsWith& a, const std::string& b) const { return a.upper_ <= b; }
bool operator()(const std::string& a, const StartsWith& b) const { return a < b.lower_; }
};
+
private:
std::string lower_;
std::string upper_;
};
-int main(int, char**)
-{
+int main(int, char**) {
{
using M = std::flat_map<std::string, int, StartsWith::Less>;
- M m = { {"alpha", 1}, {"beta", 2}, {"epsilon", 3}, {"eta", 4}, {"gamma", 5} };
+ M m = {{"alpha", 1}, {"beta", 2}, {"epsilon", 3}, {"eta", 4}, {"gamma", 5}};
ASSERT_SAME_TYPE(decltype(m.upper_bound(StartsWith('b'))), M::iterator);
ASSERT_SAME_TYPE(decltype(std::as_const(m).upper_bound(StartsWith('b'))), M::const_iterator);
assert(m.upper_bound("beta") == m.begin() + 2);
``````````
</details>
https://github.com/llvm/llvm-project/pull/98643
More information about the libcxx-commits
mailing list