Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <map>
- #include <algorithm>
- #include <iostream>
- #include <string>
- #include <iterator>
- #include <boost/iterator/transform_iterator.hpp>
- #include <boost/bind.hpp>
- #include <boost/function.hpp>
- int main() {
- typedef std::map<std::string, int>::value_type value_type;
- std::map<std::string, int> a;
- a["one"] = 1;
- a["two"] = 2;
- // returns the second element
- boost::function<int(value_type&)> f = boost::bind(&value_type::second, _1);
- std::copy(boost::make_transform_iterator(a.begin(), f),
- boost::make_transform_iterator(a.end(), f),
- std::ostream_iterator<int>(std::cout, " "));
- }
Add Comment
Please, Sign In to add comment