summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/algorithms/alg.sorting
diff options
context:
space:
mode:
authorStephan T. Lavavej <stl@exchange.microsoft.com>2016-11-23 22:01:58 +0000
committerStephan T. Lavavej <stl@exchange.microsoft.com>2016-11-23 22:01:58 +0000
commita11d322f0d5530a4da67aa77ad1137c63f874288 (patch)
treeecc89b49e310361b50f4ad9ad064c493d5db0bd7 /libcxx/test/std/algorithms/alg.sorting
parenteda119345699bcc90befc249388c295d6e611df9 (diff)
downloadbcm5719-llvm-a11d322f0d5530a4da67aa77ad1137c63f874288.tar.gz
bcm5719-llvm-a11d322f0d5530a4da67aa77ad1137c63f874288.zip
[libcxx] [test] D27014: Fix MSVC warning C4018 "signed/unsigned mismatch", part 2/12.
Add static_cast<std::size_t> when comparing int to std::size_t. Also, include <cstddef> when it wasn't already being included. llvm-svn: 287822
Diffstat (limited to 'libcxx/test/std/algorithms/alg.sorting')
-rw-r--r--libcxx/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp3
-rw-r--r--libcxx/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp5
-rw-r--r--libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp5
-rw-r--r--libcxx/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp3
4 files changed, 10 insertions, 6 deletions
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp
index cf8659038f1..49343ed41e3 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp
@@ -19,6 +19,7 @@
#include <functional>
#include <vector>
#include <cassert>
+#include <cstddef>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include <memory>
@@ -77,7 +78,7 @@ int main()
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::vector<std::unique_ptr<int> > v(1000);
- for (int i = 0; i < v.size(); ++i)
+ for (int i = 0; static_cast<std::size_t>(i) < v.size(); ++i)
v[i].reset(new int(i));
std::nth_element(v.begin(), v.begin() + v.size()/2, v.end(), indirect_less());
assert(*v[v.size()/2] == v.size()/2);
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp
index 0289cf8391f..d7981e664c6 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/partial.sort/partial_sort_comp.pass.cpp
@@ -19,6 +19,7 @@
#include <vector>
#include <functional>
#include <cassert>
+#include <cstddef>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include <memory>
@@ -83,10 +84,10 @@ int main()
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::vector<std::unique_ptr<int> > v(1000);
- for (int i = 0; i < v.size(); ++i)
+ for (int i = 0; static_cast<std::size_t>(i) < v.size(); ++i)
v[i].reset(new int(i));
std::partial_sort(v.begin(), v.begin() + v.size()/2, v.end(), indirect_less());
- for (int i = 0; i < v.size()/2; ++i)
+ for (int i = 0; static_cast<std::size_t>(i) < v.size()/2; ++i)
assert(*v[i] == i);
}
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp
index d6c4f046784..c77015993c8 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/sort/sort_comp.pass.cpp
@@ -19,6 +19,7 @@
#include <functional>
#include <vector>
#include <cassert>
+#include <cstddef>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include <memory>
@@ -35,7 +36,7 @@ int main()
{
{
std::vector<int> v(1000);
- for (int i = 0; i < v.size(); ++i)
+ for (int i = 0; static_cast<std::size_t>(i) < v.size(); ++i)
v[i] = i;
std::sort(v.begin(), v.end(), std::greater<int>());
std::reverse(v.begin(), v.end());
@@ -45,7 +46,7 @@ int main()
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::vector<std::unique_ptr<int> > v(1000);
- for (int i = 0; i < v.size(); ++i)
+ for (int i = 0; static_cast<std::size_t>(i) < v.size(); ++i)
v[i].reset(new int(i));
std::sort(v.begin(), v.end(), indirect_less());
assert(std::is_sorted(v.begin(), v.end(), indirect_less()));
diff --git a/libcxx/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp b/libcxx/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp
index 68e817ebeb3..49f7122cdb3 100644
--- a/libcxx/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort_comp.pass.cpp
@@ -19,6 +19,7 @@
#include <functional>
#include <vector>
#include <cassert>
+#include <cstddef>
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
#include <memory>
@@ -71,7 +72,7 @@ int main()
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::vector<std::unique_ptr<int> > v(1000);
- for (int i = 0; i < v.size(); ++i)
+ for (int i = 0; static_cast<std::size_t>(i) < v.size(); ++i)
v[i].reset(new int(i));
std::stable_sort(v.begin(), v.end(), indirect_less());
assert(std::is_sorted(v.begin(), v.end(), indirect_less()));
OpenPOWER on IntegriCloud