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
Hello World
Fungsi dan for
Income calculator
PointPattern
simple use of templete
Microsoft Question - MaxEmployeeAttendence (any repititions are allowed)
c++_array_size
remove_copy_if-30-Seconds-of-C++
frequsency
Shuffle algorithm