mercredi 27 mai 2015

using bind to reduce the number of arguments of a method inside another method of a class c++

I'm coding in C++. I have a project with so many files. I have a vector of pairs named list as follows:

std::vector< std::pair< strucure1, double> > list;

and I want to check if for a specific double value z , there exists an element: "el" in the list such that: el.second=z

I want to use

find_if

To do so , I've implemented a method : "Scheduled" that takes two arguments: the first one is an element like those stored in the list , the second one is the specific value to look for. here is the implementation :

1/:

 bool classA::Scheduled(std::pair< strucure1,double > const el, double const t )
{
return el.second==t;
}

2- Inside another method but still in the same class: classA

auto Scheduled1=std::bind(Scheduled, _1, z);



bool call=std::find_if(list.begin(),list.end(),std::bind1st(mem_fun(&classA::Scheduled1), this))==list.end();

call is just a boolean variable that contains the information about the existence of z in the list. The first part, is to reduce the number of arguments of the method Schedule

What I get from the compiler is this error: error:Scheduled1 does not name a type

Aucun commentaire:

Enregistrer un commentaire