-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[libcxx] Removal of narrowing conversions in flat_[multi]{set, map} tests for compatibility with MSVC
#170909
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?
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
|
@llvm/pr-subscribers-libcxx Author: Vojtěch Michal (vmichal) ChangesImpacts files in Replace Make test code robust against evil overloads of operator comma .(2 files) Patch is 101.74 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/170909.diff 34 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 c98803f6cce9d..56231b8ee05bf 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,8 +29,8 @@ constexpr void test() {
// test_allocator is not propagated
using C = test_less<int>;
KeyContainer<int, test_allocator<int>> ks({1, 3, 5}, test_allocator<int>(6));
- ValueContainer<char, test_allocator<char>> vs({2, 2, 1}, test_allocator<char>(7));
- using M = std::flat_map<int, char, C, decltype(ks), decltype(vs)>;
+ ValueContainer<long, test_allocator<long>> vs({2, 2, 1}, test_allocator<long>(7));
+ using M = std::flat_map<int, long, 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;
@@ -39,23 +39,23 @@ constexpr void test() {
assert(m.keys() == ks);
assert(m.values() == vs);
assert(m.keys().get_allocator() == test_allocator<int>(2));
- assert(m.values().get_allocator() == test_allocator<char>(2));
+ assert(m.values().get_allocator() == test_allocator<long>(2));
// mo is unchanged
assert(mo.key_comp() == C(5));
assert(mo.keys() == ks);
assert(mo.values() == vs);
assert(mo.keys().get_allocator() == test_allocator<int>(6));
- assert(mo.values().get_allocator() == test_allocator<char>(7));
+ assert(mo.values().get_allocator() == test_allocator<long>(7));
}
{
// other_allocator is propagated
using C = test_less<int>;
using Ks = KeyContainer<int, other_allocator<int>>;
- using Vs = ValueContainer<char, other_allocator<char>>;
+ using Vs = ValueContainer<long, other_allocator<long>>;
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 vs = Vs({2, 2, 1}, other_allocator<long>(7));
+ using M = std::flat_map<int, long, 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;
@@ -64,14 +64,14 @@ constexpr void test() {
assert(m.keys() == ks);
assert(m.values() == vs);
assert(m.keys().get_allocator() == other_allocator<int>(6));
- assert(m.values().get_allocator() == other_allocator<char>(7));
+ assert(m.values().get_allocator() == other_allocator<long>(7));
// mo is unchanged
assert(mo.key_comp() == C(5));
assert(mo.keys() == ks);
assert(mo.values() == vs);
assert(mo.keys().get_allocator() == other_allocator<int>(6));
- assert(mo.values().get_allocator() == other_allocator<char>(7));
+ assert(mo.values().get_allocator() == other_allocator<long>(7));
}
if (!TEST_IS_CONSTANT_EVALUATED) {
// comparator is copied and invariant is preserved
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 21166361b014b..7998bef2e87d8 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
@@ -33,19 +33,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, int> 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<long, int, 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, int, 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);
@@ -54,14 +54,14 @@ 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<long, test_allocator<long>> 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<long, test_allocator<long>> sorted_vs({1, 2, 5, 4}, test_allocator<int>(0, 43));
+ const std::pair<int, long> expected[] = {{1, 1}, {2, 2}, {3, 5}, {INT_MAX, 4}};
{
std::flat_map s(ks, vs);
- ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::less<int>, decltype(ks), decltype(vs)>);
+ ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::less<int>, decltype(ks), decltype(vs)>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().get_id() == 42);
assert(s.values().get_allocator().get_id() == 43);
@@ -69,7 +69,7 @@ void test_containers() {
{
std::flat_map s(std::sorted_unique, sorted_ks, sorted_vs);
- ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::less<int>, decltype(ks), decltype(vs)>);
+ ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::less<int>, decltype(ks), decltype(vs)>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().get_id() == 42);
assert(s.values().get_allocator().get_id() == 43);
@@ -77,7 +77,7 @@ void test_containers() {
{
std::flat_map s(ks, vs, test_allocator<long>(0, 44));
- ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::less<int>, decltype(ks), decltype(vs)>);
+ ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::less<int>, decltype(ks), decltype(vs)>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().get_id() == 44);
assert(s.values().get_allocator().get_id() == 44);
@@ -85,7 +85,7 @@ void test_containers() {
{
std::flat_map s(std::sorted_unique, sorted_ks, sorted_vs, test_allocator<long>(0, 44));
- ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::less<int>, decltype(ks), decltype(vs)>);
+ ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::less<int>, decltype(ks), decltype(vs)>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().get_id() == 44);
assert(s.values().get_allocator().get_id() == 44);
@@ -94,14 +94,14 @@ 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<long, test_allocator<long>> 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<long, test_allocator<long>> sorted_vs({4, 5, 2, 1}, test_allocator<int>(0, 43));
+ const std::pair<int, long> expected[] = {{INT_MAX, 4}, {3, 5}, {2, 2}, {1, 1}};
{
std::flat_map s(ks, vs, std::greater<int>());
- ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::greater<int>, decltype(ks), decltype(vs)>);
+ ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::greater<int>, decltype(ks), decltype(vs)>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().get_id() == 42);
assert(s.values().get_allocator().get_id() == 43);
@@ -109,7 +109,7 @@ void test_containers_compare() {
{
std::flat_map s(std::sorted_unique, sorted_ks, sorted_vs, std::greater<int>());
- ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::greater<int>, decltype(ks), decltype(vs)>);
+ ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::greater<int>, decltype(ks), decltype(vs)>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().get_id() == 42);
assert(s.values().get_allocator().get_id() == 43);
@@ -117,7 +117,7 @@ void test_containers_compare() {
{
std::flat_map s(ks, vs, std::greater<int>(), test_allocator<long>(0, 44));
- ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::greater<int>, decltype(ks), decltype(vs)>);
+ ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::greater<int>, decltype(ks), decltype(vs)>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().get_id() == 44);
assert(s.values().get_allocator().get_id() == 44);
@@ -125,7 +125,7 @@ void test_containers_compare() {
{
std::flat_map s(std::sorted_unique, sorted_ks, sorted_vs, std::greater<int>(), test_allocator<long>(0, 44));
- ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, short, std::greater<int>, decltype(ks), decltype(vs)>);
+ ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::greater<int>, decltype(ks), decltype(vs)>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().get_id() == 44);
assert(s.values().get_allocator().get_id() == 44);
@@ -280,11 +280,11 @@ 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, long>> r = {{1, 1}, {2, 2}, {1, 1}, {INT_MAX, 4}, {3, 5}};
+ const std::pair<int, long> 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>>);
+ ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::less<int>>);
assert(std::ranges::equal(s, expected));
}
{
@@ -292,10 +292,10 @@ void test_from_range() {
ASSERT_SAME_TYPE(
decltype(s),
std::flat_map<int,
- short,
+ long,
std::less<int>,
std::vector<int, test_allocator<int>>,
- std::vector<short, test_allocator<short>>>);
+ std::vector<long, test_allocator<long>>>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().get_id() == 42);
assert(s.values().get_allocator().get_id() == 42);
@@ -303,11 +303,11 @@ 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, long>> r = {{1, 1}, {2, 2}, {1, 1}, {INT_MAX, 4}, {3, 5}};
+ const std::pair<int, long> 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>>);
+ ASSERT_SAME_TYPE(decltype(s), std::flat_map<int, long, std::greater<int>>);
assert(std::ranges::equal(s, expected));
}
{
@@ -315,10 +315,10 @@ void test_from_range_compare() {
ASSERT_SAME_TYPE(
decltype(s),
std::flat_map<int,
- short,
+ long,
std::greater<int>,
std::vector<int, test_allocator<int>>,
- std::vector<short, test_allocator<short>>>);
+ std::vector<long, test_allocator<long>>>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().get_id() == 42);
assert(s.values().get_allocator().get_id() == 42);
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..97eeec44bae3b 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
@@ -32,19 +32,19 @@ using PC = std::pair<const int, long>;
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<long, test_allocator<long>> 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<long, test_allocator<long>> sorted_vs({1, 2, 5, 4}, test_allocator<int>(0, 43));
+ const std::pair<int, long> expected[] = {{1, 1}, {2, 2}, {3, 5}, {INT_MAX, 4}};
{
std::pmr::monotonic_buffer_resource mr;
std::pmr::monotonic_buffer_resource mr2;
std::pmr::deque<int> pks(ks.begin(), ks.end(), &mr);
- std::pmr::deque<short> pvs(vs.begin(), vs.end(), &mr);
+ std::pmr::deque<long> 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>>);
+ decltype(s), std::flat_map<int, long, std::less<int>, std::pmr::deque<int>, std::pmr::deque<long>>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().resource() == &mr2);
assert(s.values().get_allocator().resource() == &mr2);
@@ -53,11 +53,11 @@ void test_containers() {
std::pmr::monotonic_buffer_resource mr;
std::pmr::monotonic_buffer_resource mr2;
std::pmr::deque<int> pks(sorted_ks.begin(), sorted_ks.end(), &mr);
- std::pmr::deque<short> pvs(sorted_vs.begin(), sorted_vs.end(), &mr);
+ std::pmr::deque<long> 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>>);
+ decltype(s), std::flat_map<int, long, std::less<int>, std::pmr::deque<int>, std::pmr::deque<long>>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().resource() == &mr2);
assert(s.values().get_allocator().resource() == &mr2);
@@ -66,19 +66,19 @@ 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<long, test_allocator<long>> 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<long, test_allocator<long>> sorted_vs({4, 5, 2, 1}, test_allocator<int>(0, 43));
+ const std::pair<int, long> expected[] = {{INT_MAX, 4}, {3, 5}, {2, 2}, {1, 1}};
{
std::pmr::monotonic_buffer_resource mr;
std::pmr::monotonic_buffer_resource mr2;
std::pmr::deque<int> pks(ks.begin(), ks.end(), &mr);
- std::pmr::deque<short> pvs(vs.begin(), vs.end(), &mr);
+ std::pmr::deque<long> 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>>);
+ decltype(s), std::flat_map<int, long, std::greater<int>, std::pmr::deque<int>, std::pmr::deque<long>>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().resource() == &mr2);
assert(s.values().get_allocator().resource() == &mr2);
@@ -87,11 +87,11 @@ void test_containers_compare() {
std::pmr::monotonic_buffer_resource mr;
std::pmr::monotonic_buffer_resource mr2;
std::pmr::deque<int> pks(sorted_ks.begin(), sorted_ks.end(), &mr);
- std::pmr::deque<short> pvs(sorted_vs.begin(), sorted_vs.end(), &mr);
+ std::pmr::deque<long> 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>>);
+ decltype(s), std::flat_map<int, long, std::greater<int>, std::pmr::deque<int>, std::pmr::deque<long>>);
assert(std::ranges::equal(s, expected));
assert(s.keys().get_allocator().resource() == &mr2);
assert(s.values().get_allocator().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 aea2002ba8d9c..ef49a6ee9f986 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
@@ -37,24 +37,24 @@ struct DefaultCtableComp {
template <template <class...> class KeyContainer, template <class...> class ValueContainer>
constexpr void test() {
- std::pair<int, short> expected[] = {{1, 1}, {2, 2}, {3, 3}, {5, 2}};
+ std::pair<int, long> expected[] = {{1, 1}, {2, 2}, {3, 3}, {5, 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}};
+ using M = std::flat_map<int, long>;
+ std::initializer_list<std::pair<int, long>> 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));
}
{
// flat_map(initializer_list<value_type>);
// explicit(false)
- using M = std::flat_map<int, short>;
+ using M = std::flat_map<int, long>;
M m = {{5, 2}, {2, 2}, {2, 2}, {3, 3}, {1, 1}, {3, 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>, KeyContainer<int, min_allocator<int>>>;
+ using M = std::flat_map<int, long, std::greater<int>, KeyContainer<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));
}
@@ -79,7 +79,7 @@ constexpr void test() {
{
// flat_map(initializer_list<value_type>, const key_compare&);
using C = test_less<int>;
- using M = std::flat_map<int, short, C>;
+ using M = std::flat_map<int, long, 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));
assert(m.key_comp() == C(10));
@@ -92,7 +92,7 @@ constexpr void test() {
if (!TEST_IS_CONSTANT_EVALUATED) {
// flat_map(initializer_list<value_type>, const key_compare&);
// Sorting uses the comparator that was passed in
- usi...
[truncated]
|
huixie90
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.
LGTM with comments and green CI
| typename M::const_iterator k = i; // converting constructor | ||
| assert(i == k); // comparison | ||
| for (int j = 0; j < 9; ++j, ++i) { // pre-increment | ||
| for (int j = 0; j < 9; ++j, (void)++i) { // pre-increment |
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.
why is this needed?
| typename M::const_iterator k = i; // converting constructor | ||
| assert(i == k); // comparison | ||
| for (int j = 1; j <= 4; ++j, ++i) { // pre-increment | ||
| for (int j = 1; j <= 4; ++j, (void)++i) { // pre-increment |
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.
same question here
Impacts files in
test/std/containers/container.adaptors/flat.xxx. No meaning is changed; only appropriate types are spelled out to prevent compiler warnings.chars andshorts used in tests offlat_[multi]{set, map}withlongs to prevent warnings about narrowing conversions when running tests. Allow increased test coverage for MSVC STL.[[maybe_unused]]to some localtypedefs that are sometimes unused due to usage ofLIBCPP_STATIC_ASSERT.For discussion and suggested changes, see the LLVM Discord https://discord.com/channels/636084430946959380/636732894974312448/1445901676400742533
If possible, I'd like to ask @huixie90 to verify whether this matches the recommended modifications.