-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[libc++][test] Avoid narrowing operations in pair's constructors for tests for flat_(multi)map whenever feasible
#131284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[libc++][test] Avoid narrowing operations in pair's constructors for tests for flat_(multi)map whenever feasible
#131284
Conversation
|
@llvm/pr-subscribers-libcxx Author: A. Jiang (frederick-vs-ja) ChangesDrive-by: Add When testing MSVC STL, MSVC warns about such narrowing in Patch is 60.66 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/131284.diff 27 Files Affected:
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 4f9797d5bf810..cc80de8950738 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
@@ -29,7 +29,9 @@ 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));
+ auto m = M({{3, static_cast<char>(3)}, {4, static_cast<char>(4)}, {5, static_cast<char>(5)}},
+ C(3),
+ test_allocator<int>(2));
m = mo;
assert(m.key_comp() == C(5));
@@ -54,7 +56,9 @@ int main(int, char**) {
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));
+ auto m = M({{3, static_cast<char>(3)}, {4, static_cast<char>(4)}, {5, static_cast<char>(5)}},
+ C(3),
+ other_allocator<int>(2));
m = mo;
assert(m.key_comp() == C(5));
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 009392feb3862..3ca7aa1363856 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
@@ -31,19 +31,19 @@ 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, static_cast<short>(2)}, {2, static_cast<short>(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<long, short, std::greater<long>> source = {{1, static_cast<short>(2)}, {2, static_cast<short>(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, static_cast<short>(2)}, {2, static_cast<short>(3)}};
std::flat_map s(source, std::allocator<int>());
ASSERT_SAME_TYPE(decltype(s), decltype(source));
assert(s == source);
@@ -55,7 +55,11 @@ void test_containers() {
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}};
+ const std::pair<int, short> expected[] = {
+ {1, static_cast<short>(1)},
+ {2, static_cast<short>(2)},
+ {3, static_cast<short>(5)},
+ {INT_MAX, static_cast<short>(4)}};
{
std::flat_map s(ks, vs);
@@ -95,7 +99,11 @@ void test_containers_compare() {
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}};
+ const std::pair<int, short> expected[] = {
+ {INT_MAX, static_cast<short>(4)},
+ {3, static_cast<short>(5)},
+ {2, static_cast<short>(2)},
+ {1, static_cast<short>(1)}};
{
std::flat_map s(ks, vs, std::greater<int>());
@@ -278,8 +286,17 @@ void test_initializer_list_compare() {
}
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, static_cast<short>(1)},
+ {2, static_cast<short>(2)},
+ {1, static_cast<short>(1)},
+ {INT_MAX, static_cast<short>(4)},
+ {3, static_cast<short>(5)}};
+ const std::pair<int, short> expected[] = {
+ {1, static_cast<short>(1)},
+ {2, static_cast<short>(2)},
+ {3, static_cast<short>(5)},
+ {INT_MAX, static_cast<short>(4)}};
{
std::flat_map s(std::from_range, r);
ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::less<int>>);
@@ -301,8 +318,17 @@ 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, static_cast<short>(1)},
+ {2, static_cast<short>(2)},
+ {1, static_cast<short>(1)},
+ {INT_MAX, static_cast<short>(4)},
+ {3, static_cast<short>(5)}};
+ const std::pair<int, short> expected[] = {
+ {INT_MAX, static_cast<short>(4)},
+ {3, static_cast<short>(5)},
+ {2, static_cast<short>(2)},
+ {1, static_cast<short>(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>>);
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct_pmr.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct_pmr.pass.cpp
index 11c18ac13c76a..e62b9049859aa 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct_pmr.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/deduct_pmr.pass.cpp
@@ -35,7 +35,11 @@ void test_containers() {
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}};
+ const std::pair<int, short> expected[] = {
+ {1, static_cast<short>(1)},
+ {2, static_cast<short>(2)},
+ {3, static_cast<short>(5)},
+ {INT_MAX, static_cast<short>(4)}};
{
std::pmr::monotonic_buffer_resource mr;
std::pmr::monotonic_buffer_resource mr2;
@@ -69,7 +73,11 @@ void test_containers_compare() {
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}};
+ const std::pair<int, short> expected[] = {
+ {INT_MAX, static_cast<short>(4)},
+ {3, static_cast<short>(5)},
+ {2, static_cast<short>(2)},
+ {1, static_cast<short>(1)}};
{
std::pmr::monotonic_buffer_resource mr;
std::pmr::monotonic_buffer_resource mr2;
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 7a22746845d00..5fa8b040a31e8 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
@@ -82,11 +82,18 @@ int main(int, char**) {
!std::is_constructible_v<M, std::initializer_list<std::pair<const int, const short>>, std::allocator<int>>);
}
- std::pair<int, short> expected[] = {{1, 1}, {2, 2}, {3, 3}, {5, 2}};
+ std::pair<int, short> expected[] = {
+ {1, static_cast<short>(1)}, {2, static_cast<short>(2)}, {3, static_cast<short>(3)}, {5, static_cast<short>(2)}};
{
// flat_map(initializer_list<value_type>);
using M = std::flat_map<int, short>;
- std::initializer_list<std::pair<int, short>> il = {{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}};
+ std::initializer_list<std::pair<int, short>> il = {
+ {5, static_cast<short>(2)},
+ {2, static_cast<short>(2)},
+ {2, static_cast<short>(2)},
+ {3, static_cast<short>(3)},
+ {1, static_cast<short>(1)},
+ {3, static_cast<short>(3)}};
M m(il);
assert(std::equal(m.begin(), m.end(), expected, expected + 4));
}
@@ -94,13 +101,23 @@ int main(int, char**) {
// flat_map(initializer_list<value_type>);
// explicit(false)
using M = std::flat_map<int, short>;
- M m = {{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}};
+ M m = {{5, static_cast<short>(2)},
+ {2, static_cast<short>(2)},
+ {2, static_cast<short>(2)},
+ {3, static_cast<short>(3)},
+ {1, static_cast<short>(1)},
+ {3, static_cast<short>(3)}};
assert(std::equal(m.begin(), m.end(), expected, expected + 4));
}
{
// flat_map(initializer_list<value_type>);
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}};
+ M m = {{5, static_cast<short>(2)},
+ {2, static_cast<short>(2)},
+ {2, static_cast<short>(2)},
+ {3, static_cast<short>(3)},
+ {1, static_cast<short>(1)},
+ {3, static_cast<short>(3)}};
assert(std::equal(m.rbegin(), m.rend(), expected, expected + 4));
}
{
@@ -127,12 +144,25 @@ int main(int, char**) {
// flat_map(initializer_list<value_type>, const key_compare&);
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));
+ auto m =
+ M({{5, static_cast<short>(2)},
+ {2, static_cast<short>(2)},
+ {2, static_cast<short>(2)},
+ {3, static_cast<short>(3)},
+ {1, static_cast<short>(1)},
+ {3, static_cast<short>(3)}},
+ C(10));
assert(std::equal(m.begin(), m.end(), expected, expected + 4));
assert(m.key_comp() == C(10));
// explicit(false)
- M m2 = {{{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 3}}, C(10)};
+ M m2 = {{{5, static_cast<short>(2)},
+ {2, static_cast<short>(2)},
+ {2, static_cast<short>(2)},
+ {3, static_cast<short>(3)},
+ {1, static_cast<short>(1)},
+ {3, static_cast<short>(3)}},
+ C(10)};
assert(m2 == m);
assert(m2.key_comp() == C(10));
}
@@ -140,7 +170,14 @@ int main(int, char**) {
// flat_map(initializer_list<value_type>, const key_compare&);
// 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>());
+ auto m =
+ M({{5, static_cast<short>(2)},
+ {2, static_cast<short>(2)},
+ {2, static_cast<short>(2)},
+ {3, static_cast<short>(3)},
+ {1, static_cast<short>(1)},
+ {3, static_cast<short>(3)}},
+ std::greater<int>());
assert(std::equal(m.rbegin(), m.rend(), expected, expected + 4));
assert(m.key_comp()(2, 1) == true);
}
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 7c0c487969943..6fb6eef67bb03 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
@@ -57,9 +57,18 @@ int main(int, char**) {
static_assert(!std::is_constructible_v<M3, Iter3, Iter3, const C&, const A2&>);
}
- 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 P = std::pair<int, short>;
+ P ar[] = {
+ {1, static_cast<short>(1)},
+ {1, static_cast<short>(2)},
+ {1, static_cast<short>(3)},
+ {2, static_cast<short>(4)},
+ {2, static_cast<short>(5)},
+ {3, static_cast<short>(6)},
+ {2, static_cast<short>(7)},
+ {3, static_cast<short>(8)},
+ {3, static_cast<short>(9)}};
+ P expected[] = {{1, static_cast<short>(1)}, {2, static_cast<short>(4)}, {3, static_cast<short>(6)}};
{
// flat_map(InputIterator , InputIterator)
// cpp17_input_iterator
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 a94c442c695dd..ad305ae41cdf2 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
@@ -32,10 +32,10 @@ int main(int, char**) {
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 mo = M({{1, static_cast<char>(1)}, {2, static_cast<char>(3)}, {3, static_cast<char>(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 == M{{1, static_cast<char>(1)}, {2, static_cast<char>(3)}, {3, static_cast<char>(2)}}));
assert(m.key_comp() == C(5));
auto [ks, vs] = std::move(m).extract();
assert(ks.get_allocator() == A1(7));
@@ -47,10 +47,15 @@ int main(int, char**) {
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 mo = M({{4, static_cast<char>(5)}, {5, static_cast<char>(4)}}, C(5), A1(7));
+ M m = M({{1, static_cast<char>(1)}, //
+ {2, static_cast<char>(2)},
+ {3, static_cast<char>(3)},
+ {4, static_cast<char>(4)}},
+ C(3),
+ A1(7));
m = std::move(mo);
- assert((m == M{{4, 5}, {5, 4}}));
+ assert((m == M{{4, static_cast<char>(5)}, {5, static_cast<char>(4)}}));
assert(m.key_comp() == C(5));
auto [ks, vs] = std::move(m).extract();
assert(ks.get_allocator() == A1(7));
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/pmr.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/pmr.pass.cpp
index 154af11bb9b4d..d1c86bb077ed5 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/pmr.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/pmr.pass.cpp
@@ -166,9 +166,18 @@ int main(int, char**) {
}
{
// flat_map(InputIterator first, InputIterator last, const Allocator& a);
- 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 P = std::pair<int, short>;
+ P ar[] = {
+ {1, static_cast<short>(1)},
+ {1, static_cast<short>(2)},
+ {1, static_cast<short>(3)},
+ {2, static_cast<short>(4)},
+ {2, static_cast<short>(5)},
+ {3, static_cast<short>(6)},
+ {2, static_cast<short>(7)},
+ {3, static_cast<short>(8)},
+ {3, static_cast<short>(9)}};
+ P expected[] = {{1, static_cast<short>(1)}, {2, static_cast<short>(4)}, {3, static_cast<short>(6)}};
{
// cpp17 iterator
using M = std::flat_map<int, short, std::less<int>, std::pmr::vector<int>, std::pmr::vector<short>>;
@@ -242,9 +251,18 @@ int main(int, char**) {
}
{
// flat_map(from_range_t, R&&, const Alloc&);
- 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 P = std::pair<int, short>;
+ P ar[] = {
+ {1, static_cast<short>(1)},
+ {1, static_cast<short>(2)},
+ {1, static_cast<short>(3)},
+ {2, static_cast<short>(4)},
+ {2, static_cast<short>(5)},
+ {3, static_cast<short>(6)},
+ {2, static_cast<short>(7)},
+ {3, static_cast<short>(8)},
+ {3, static_cast<short>(9)}};
+ P expected[] = {{1, static_cast<short>(1)}, {2, static_cast<short>(4)}, {3, static_cast<short>(6)}};
{
// input_range
using M = std::flat_map<int, short, std::less<int>, std::pmr::vector<int>, std::pmr::vector<short>>;
diff --git a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/range.pass.cpp b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/range.pass.cpp
index 282cc71f31994..c34109a1801ba 100644
--- a/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/range.pass.cpp
+++ b/libcxx/test/std/containers/container.adaptors/flat.map/flat.map.cons/range.pass.cpp
@@ -117,9 +117,18 @@ int main(int, char**) {
static_assert(!std::is_constructible_v<M, std::from_range_t, std::vector<NonPairLike>&, const C&, const A1&>);
}
- 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 P = std::pair<int, short>;
+ P ar[] = {
+ {1, static_cast<short>(1)},
+ {1, static_cast<short>(2)},
+ {1, static_cast<short>(3)},
+ {2, static_cast<short>(4)},
+ {2, static_cast<short>(5)},
+ {3, static_cast<short>(6)},
+ {2, static_cast<short>(7)},
+ {3, static_cast<short>(8)},
+ {3, static_cast<short>(9)}};
+ P expected[] = {{1, static_cast<short>(1)}, {2, static_cast<short>(4)}, {3, static_cast<short>(6)}};
{
// flat_map(from_range_t, R&&)
// input_range && !common
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 3c8868f2ff424..bde86ea2ddbe4 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
@@ -66,11 +66,17 @@ int main(int, char**) {
auto vs2 = vs;
auto m = M(std::sorted_unique, ks, vs);
- assert((m == M{{1, 4}, {2, 3}, {4, 2}, {10, 1}}));
+ assert((m == M{{1, static_cast<char>(4)},
+ {2, static_cast<char>(3)},
+ {4, static_cast<char>(2)},
+ {10, static_cast<char>(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, static_cast<char>(4)},
+ {2, static_cast<char>(3)},
+ {4, static_cast<char>(2)},
+ {10, static_cast<char>(1)}}));
// explicit(false)
M m2 = {std::sorted_unique, std::move(ks2), std::move(vs2)};
@@ -85,11 +91,17 @@ int main(int, char**) {
Ks ks = {10, 4,...
[truncated]
|
pair' constructors for test files for flat_(multi)map whenever feasible.pair's constructors for tests for flat_(multi)map whenever feasible
6b8160a to
1553c22
Compare
... for test files for `flat_(multi)map` whenever feasible. Drive-by: Add `[[maybe_unused]]` to variables that are only used in `LIBCPP_ASSERT`. When testing MSVC STL, MSVC warns about such narrowing in `pair`'s constructors, even though the narrowing happens within direct-non-list-initialization.
1553c22 to
a29e302
Compare
mordante
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like to get a better feeling about these changes, the short changes IMO decrease the readability of the code.
Drive-by: Add
[[maybe_unused]]to variables that are only used inLIBCPP_ASSERT.When testing MSVC STL, MSVC warns about such narrowing in
pair's constructors, even though the narrowing happens within direct-non-list-initialization.