From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2007-11-20 02:43:46
I'm CC'ing Mark Rogers who, upon looking at the Author of
Boost.Functional (and I assume is the maintainer) may be able to help
out with this regard.
Recently, I've implemented a simple utility which allows users to
select the nth element of an STL pair / Boost.Tuple in conjunction
with STL algorithms. This allows precisely the following usage
std::map<int, int> int_map;
int_map = 1;
int_map = 2;
std::ostream_iterator<int>(std::cout, " "),
boost::select<1>()); // output: "1 2 "
This is a generalization of the SGI select1st and select2nd function objects.
It also works with a container of Boost.Tuple's:
std::list<boost::tuple<double, double, double> > coord_list;
coord_list.push_back(boost::make_tuple(1.0, 2.0, 3.0));
coord_list.push_back(boost::make_tuple(4.0, 5.0, 6.0));
std::ostream_iterator<double>(std::cout, " "),
boost::select<0>()); // output "1.0 4.0 "
I've re-attached the implementation, for comments and review for
inclusion in Boost.Functional.
Thanks very much, and I hope to hear from you guys soon.
-- Dean Michael C. Berris Software Engineer, Friendster, Inc. [http://cplusplus-soup.blogspot.com/] [mikhailberis_at_[hidden]] [+63 928 7291459] [+1 408 4049523]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk