
On Tue, Jan 20, 2009 at 3:52 PM, Maxim Koshelev <chuchelo@gmail.com> wrote:
This one IS tested! ... yes, this worked, but next, more simple example not work:
std::map <int, std::string> m; std::vector <int> v;
std::transform( m.begin(), m.end(), std::backinserter(v), bind(&std::pair<const int, std::string>::second, _1) );
even replacing 'bind' by _1 ->* &std::pair<const int,std::string>::second doesn't work. GCC 4.1.2 reports: error: reference to '_1' is ambiguous /usr/include/boost/lambda/core.hpp:69: error: candidates are: const boost::lambda::placeholder1_type& boost::lambda::<unnamed>::_1 /usr/include/boost/bind/placeholders.hpp:30: error: boost::arg<1><unnamed>::_1() services.cc:56: error: reference to '_1' is ambiguous _______________________________________________
This works for me... #include "boost/lambda/lambda.hpp" #include "boost/lambda/bind.hpp" #include <vector> #include <map> #include <algorithm> #include <iterator> #include <iostream> int main( ) { using namespace boost::lambda; std::map<int,std::string> v; std::vector<int> i; for ( unsigned i=1; i != 6; ++i) v.insert( std::pair<const int,std::string>(i,"") ); std::transform( v.begin(), v.end(), std::back_inserter(i), bind(&std::pair<const int,std::string>::first, _1) ); } Rob.