Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Boost phoenix. e.g 3 phoenix: functor
//Boost phoenix. e.g 3 phoenix #include <iostream> #include <string> #include <vector> #include <algorithm> #include <boost/phoenix/phoenix.hpp> class Person { public: std::string getName() const { return _name; } int getAge() { return _age; } void setName(std::string iName) { _name = iName; } void setAge(int iAge) { _age = iAge; } private: std::string _name; int _age; }; int main() { Person aChema; aChema.setAge(30); aChema.setName("Chema"); Person aJavi; aJavi.setAge(31); aJavi.setName("Javi"); std::vector<Person> aVectorPerson; aVectorPerson.push_back(aChema); aVectorPerson.push_back(aJavi); std::vector<Person>::iterator it = std::find_if(aVectorPerson.begin(), aVectorPerson.end(), boost::phoenix::bind(&Person::getAge, boost::phoenix::placeholders::arg1) == 30); if(it != aVectorPerson.end()) { std::cout << it->getName() << std::endl; } }
run
|
edit
|
history
|
help
0
BinSearch
QuadRootPoint
Eratosfen final
Test 4(2020)
CPP - Arrays - Ex.4
cppPyFoodVatTip
Bit count in number
amma2
Connected components in complement graph
Peg Grammar AST Parser Computer Language Interpreter