[libcxx] r298618 - Update the algorithm tests to not use the (deprecated) function binders. No functional change.
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 23 09:13:50 PDT 2017
Author: marshall
Date: Thu Mar 23 11:13:50 2017
New Revision: 298618
URL: http://llvm.org/viewvc/llvm-project?rev=298618&view=rev
Log:
Update the algorithm tests to not use the (deprecated) function binders. No functional change.
Modified:
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp
libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp
libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp
libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp
Modified: libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp?rev=298618&r1=298617&r2=298618&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.remove/remove_copy_if.pass.cpp Thu Mar 23 11:13:50 2017
@@ -21,6 +21,8 @@
#include "test_iterators.h"
+bool equalToTwo(int v) { return v == 2; }
+
template <class InIter, class OutIter>
void
test()
@@ -28,8 +30,8 @@ test()
int ia[] = {0, 1, 2, 3, 4, 2, 3, 4, 2};
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
int ib[sa];
- OutIter r = std::remove_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib),
- std::bind2nd(std::equal_to<int>(), 2));
+ OutIter r = std::remove_copy_if(InIter(ia), InIter(ia+sa),
+ OutIter(ib), equalToTwo);
assert(base(r) == ib + sa-3);
assert(ib[0] == 0);
assert(ib[1] == 1);
Modified: libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp?rev=298618&r1=298617&r2=298618&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_copy_if.pass.cpp Thu Mar 23 11:13:50 2017
@@ -23,6 +23,8 @@
#include "test_iterators.h"
+bool equalToTwo(int v) { return v == 2; }
+
template <class InIter, class OutIter>
void
test()
@@ -30,8 +32,8 @@ test()
int ia[] = {0, 1, 2, 3, 4};
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
int ib[sa] = {0};
- OutIter r = std::replace_copy_if(InIter(ia), InIter(ia+sa), OutIter(ib),
- std::bind2nd(std::equal_to<int>(), 2), 5);
+ OutIter r = std::replace_copy_if(InIter(ia), InIter(ia+sa),
+ OutIter(ib), equalToTwo, 5);
assert(base(r) == ib + sa);
assert(ib[0] == 0);
assert(ib[1] == 1);
Modified: libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp?rev=298618&r1=298617&r2=298618&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.replace/replace_if.pass.cpp Thu Mar 23 11:13:50 2017
@@ -22,13 +22,15 @@
#include "test_iterators.h"
+bool equalToTwo(int v) { return v == 2; }
+
template <class Iter>
void
test()
{
int ia[] = {0, 1, 2, 3, 4};
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
- std::replace_if(Iter(ia), Iter(ia+sa), std::bind2nd(std::equal_to<int>(), 2), 5);
+ std::replace_if(Iter(ia), Iter(ia+sa), equalToTwo, 5);
assert(ia[0] == 0);
assert(ia[1] == 1);
assert(ia[2] == 5);
Modified: libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp?rev=298618&r1=298617&r2=298618&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.transform/unary_transform.pass.cpp Thu Mar 23 11:13:50 2017
@@ -21,6 +21,8 @@
#include "test_iterators.h"
+int plusOne(int v) { return v + 1; }
+
template <class InIter, class OutIter>
void
test()
@@ -28,8 +30,8 @@ test()
int ia[] = {0, 1, 2, 3, 4};
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
int ib[sa] = {0};
- OutIter r = std::transform(InIter(ia), InIter(ia+sa), OutIter(ib),
- std::bind2nd(std::plus<int>(), 1));
+ OutIter r = std::transform(InIter(ia), InIter(ia+sa),
+ OutIter(ib), plusOne);
assert(base(r) == ib + sa);
assert(ib[0] == 1);
assert(ib[1] == 2);
Modified: libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp?rev=298618&r1=298617&r2=298618&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.count/count_if.pass.cpp Thu Mar 23 11:13:50 2017
@@ -20,17 +20,24 @@
#include "test_iterators.h"
+struct eq {
+ eq (int val) : v(val) {}
+ bool operator () (int v2) const { return v == v2; }
+ int v;
+ };
+
+
int main()
{
int ia[] = {0, 1, 2, 2, 0, 1, 2, 3};
const unsigned sa = sizeof(ia)/sizeof(ia[0]);
assert(std::count_if(input_iterator<const int*>(ia),
input_iterator<const int*>(ia + sa),
- std::bind2nd(std::equal_to<int>(),2)) == 3);
+ eq(2)) == 3);
assert(std::count_if(input_iterator<const int*>(ia),
input_iterator<const int*>(ia + sa),
- std::bind2nd(std::equal_to<int>(),7)) == 0);
+ eq(7)) == 0);
assert(std::count_if(input_iterator<const int*>(ia),
input_iterator<const int*>(ia),
- std::bind2nd(std::equal_to<int>(),2)) == 0);
+ eq(2)) == 0);
}
Modified: libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp?rev=298618&r1=298617&r2=298618&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.find/find_if.pass.cpp Thu Mar 23 11:13:50 2017
@@ -20,16 +20,22 @@
#include "test_iterators.h"
+struct eq {
+ eq (int val) : v(val) {}
+ bool operator () (int v2) const { return v == v2; }
+ int v;
+ };
+
int main()
{
int ia[] = {0, 1, 2, 3, 4, 5};
const unsigned s = sizeof(ia)/sizeof(ia[0]);
input_iterator<const int*> r = std::find_if(input_iterator<const int*>(ia),
input_iterator<const int*>(ia+s),
- std::bind2nd(std::equal_to<int>(), 3));
+ eq(3));
assert(*r == 3);
r = std::find_if(input_iterator<const int*>(ia),
input_iterator<const int*>(ia+s),
- std::bind2nd(std::equal_to<int>(), 10));
+ eq(10));
assert(r == input_iterator<const int*>(ia+s));
}
Modified: libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp?rev=298618&r1=298617&r2=298618&view=diff
==============================================================================
--- libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp (original)
+++ libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.find/find_if_not.pass.cpp Thu Mar 23 11:13:50 2017
@@ -20,16 +20,23 @@
#include "test_iterators.h"
+struct ne {
+ ne (int val) : v(val) {}
+ bool operator () (int v2) const { return v != v2; }
+ int v;
+ };
+
+
int main()
{
int ia[] = {0, 1, 2, 3, 4, 5};
const unsigned s = sizeof(ia)/sizeof(ia[0]);
input_iterator<const int*> r = std::find_if_not(input_iterator<const int*>(ia),
input_iterator<const int*>(ia+s),
- std::bind2nd(std::not_equal_to<int>(), 3));
+ ne(3));
assert(*r == 3);
r = std::find_if_not(input_iterator<const int*>(ia),
input_iterator<const int*>(ia+s),
- std::bind2nd(std::not_equal_to<int>(), 10));
+ ne(10));
assert(r == input_iterator<const int*>(ia+s));
}
More information about the cfe-commits
mailing list