I'm currently trying to bind a function to an algorithm I'm intending to use.
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
vector<int> coll{1, 2, 3, 4, 5, 6};
vector<int>::iterator pos;
pos = find_if (coll.begin(), coll.end(),
bind(greater<int>(),_1,3));
return 0;
}
and get this error feedback:
AlgoTesting.cpp: In function ‘int main()’:
AlgoTesting.cpp:184:41: error: ‘_1’ was not declared in this scope
bind(greater<int>(),_1,3)); // criterion
^~
AlgoTesting.cpp:184:41: note: suggested alternative:
In file included from algostuff.hpp:15:0,
from AlgoTesting.cpp:5:
/usr/include/c++/7/functional:275:34: note: ‘std::placeholders::_1’
extern const _Placeholder<1> _1;
^~
I'm struggling to understand what the error log means. Does anyone know what I'm missing here?
Aucun commentaire:
Enregistrer un commentaire