Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Boost phoenix e.g. 1 no functor
//Boost phoenix. e.g 1: no functor #include <iostream> #include <string> #include <vector> #include <algorithm> // #include <boost/phoenix/phoenix.hpp> class Person { public: std::string getName() const { return _name; } std::string getAge() const { return _age; } void setName(std::string iName) { _name = iName; } void setAge(std::string iAge) { _age = iAge; } private: std::string _name; std::string _age; }; bool Is30(Person iPeron) { if(iPeron.getAge()=="30") { return true; } return false; } 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(), Is30); if(it != aVectorPerson.end()) { std::cout << it->getName() << std::endl; } }
run
|
edit
|
history
|
help
0
pyramid
doubly
Elevator 2
codechef
creating triangle using nested loop
1234
32bit
project
is_num_palindrom
Complex Number Class