M
Maitre Bart
In test.cpp, I have a class CRunner that holds the runner's name (string)
and the runner's order (int).
To get the name, the method to use is GetName().
To get the order, the method to use is GetOrder().
I made a vector<CRunner> (RunnerVec). I initialized both name and order to
all entries. I set all order to 3 except the one before the last which has
order = 5.
My goal is to formulate a statement using find_if, binders and any std
predicate (such as not_equal_to). I coded the following in order to get the
iterator on the runner that has an order different than 3:
vector<CRunner>::iterator it = find_if(RunnerVec.begin(), RunnerVec.end(),
....
where the "..." stand for the following attempts:
1: bind2nd(mem_fun_ref(&CRunner::GetOrder),
bind2nd(not_equal_to<int>(),3)));
Despite my understanding, it does not compile:
....\functional(175): error C2039: 'first_argument_type': is not a member of
'mem_fun_ref_t<int,CRunner>'
....\test.cpp(228): see reference to class template instantiation
'binder2nd<mem_fun_ref_t<int,CRunner>>' being compiled
....\functional(175): error C2065: 'first_argument_type': undeclared
identifier
....\test.cpp(228): see reference to class template instantiation
'binder2nd<mem_fun_ref_t<int,CRunner>>' being compiled
....\functional(176): fatal error C1903: unable to recover from previous
error(s); stopping compilation
Command line warning D4028 : minimal rebuild failure, reverting to normal
build
2: mem_fun_ref(&CRunner::GetOrder));
3: bind2nd(not_equal_to<CRunner>(),RunnerVec[0]));
Individually, they compile, although it does not give what I am expecting
(of course!).
4 and up:
Back to 1, I tried different argument positions and interchanging
bind1st/bind2nd without success (gives the similar errors).
Is it possible to combine both binders i.e. get the right code so 1)
GetOrder() is called upon each CRunner of the vector and 2) be compared to
3, without using home-made predicate?
Thanks for you help.
and the runner's order (int).
To get the name, the method to use is GetName().
To get the order, the method to use is GetOrder().
I made a vector<CRunner> (RunnerVec). I initialized both name and order to
all entries. I set all order to 3 except the one before the last which has
order = 5.
My goal is to formulate a statement using find_if, binders and any std
predicate (such as not_equal_to). I coded the following in order to get the
iterator on the runner that has an order different than 3:
vector<CRunner>::iterator it = find_if(RunnerVec.begin(), RunnerVec.end(),
....
where the "..." stand for the following attempts:
1: bind2nd(mem_fun_ref(&CRunner::GetOrder),
bind2nd(not_equal_to<int>(),3)));
Despite my understanding, it does not compile:
....\functional(175): error C2039: 'first_argument_type': is not a member of
'mem_fun_ref_t<int,CRunner>'
....\test.cpp(228): see reference to class template instantiation
'binder2nd<mem_fun_ref_t<int,CRunner>>' being compiled
....\functional(175): error C2065: 'first_argument_type': undeclared
identifier
....\test.cpp(228): see reference to class template instantiation
'binder2nd<mem_fun_ref_t<int,CRunner>>' being compiled
....\functional(176): fatal error C1903: unable to recover from previous
error(s); stopping compilation
Command line warning D4028 : minimal rebuild failure, reverting to normal
build
2: mem_fun_ref(&CRunner::GetOrder));
3: bind2nd(not_equal_to<CRunner>(),RunnerVec[0]));
Individually, they compile, although it does not give what I am expecting
(of course!).
4 and up:
Back to 1, I tried different argument positions and interchanging
bind1st/bind2nd without success (gives the similar errors).
Is it possible to combine both binders i.e. get the right code so 1)
GetOrder() is called upon each CRunner of the vector and 2) be compared to
3, without using home-made predicate?
Thanks for you help.