In the following there is a code snippet written in C++ which does not compile. The reason is trying to reverse the result of a lambda function using not1(). I'll appreciate very much if someone could fix this code
#include <iostream> // std::cout
using namespace std;
#include <functional> // std::not1
#include <algorithm> // std::count_if
#include <vector>
int main () {
vector<int> sv = {3, 5, 10,12 };
vector<int> v = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };
auto validSelection = [&](auto& e) {
auto isSelected = [&] (auto& sve) {
return e == sve;
};
return find_if(sv.begin(), sv.end(), isSelected) != sv.end();
};
stable_partition(v.begin(), next(v.begin(),8) , not1(validSelection));
for (int n : v) {
std::cout << n << ' ';
}
std::cout << '\n';
return 0;
}
Aucun commentaire:
Enregistrer un commentaire