Boost::Lambda + Boost::Tuple + unresolved overloaded function type

Hello! I wrote two simple examples to demonstrate the problem. First one is: //////////////////////////////////////////////////////////////// #include <vector> #include <utility> #include <algorithm> #include <cassert> #include <boost/lambda/lambda.hpp> #include <boost/lambda/bind.hpp> int main() { std::vector<int> v1; v1.push_back(1); v1.push_back(2); v1.push_back(3); std::vector<std::pair<int*, bool> > v2; namespace bll = boost::lambda; std::transform(v1.begin(), v1.end(), std::back_inserter(v2), bll::bind(std::make_pair<int*, bool>, &bll::_1, true)); assert(v2.size() == 3); return 0; } //////////////////////////////////////////////////////////////// This program compiles and works fine. The second program is: //////////////////////////////////////////////////////////////// #include <vector> #include <utility> #include <algorithm> #include <cassert> #include <boost/tuple/tuple.hpp> #include <boost/lambda/lambda.hpp> #include <boost/lambda/bind.hpp> int main() { std::vector<int> v1; v1.push_back(1); v1.push_back(2); v1.push_back(3); namespace bll = boost::lambda; std::vector<boost::tuple<int*, bool> > v3; std::transform(v1.begin(), v1.end(), std::back_inserter(v3), bll::bind(boost::make_tuple<int*, bool>, &bll::_1, true)); assert(v3.size() == 3); return 0; } //////////////////////////////////////////////////////////////// It doesn't compile: $ g++-4.3.2 -I /usr/local/dev/boost-1.38.0/include/ main2.cpp main2.cpp: In function 'int main()': main2.cpp:22: error: no matching function for call to 'bind(<unresolved overloaded function type>, const boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::other_action<boost::lambda::addressof_action>, boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::placeholder<1>
, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >, bool)' $
What's wrong in the second program? Thank you beforehand! -- Sincerely yours, Dmitry V. Krivenok Orange System Co., Ltd. Saint-Petersburg, Russia work phone: +7 812 332-32-40 cellular phone: +7 921 576-70-91 e-mail: krivenok@orangesystem.ru web: http://www.orangesystem.ru skype: krivenok_dmitry jabber: krivenok_dmitry@jabber.ru icq: 242-526-443

AMDG Dmitry V. Krivenok wrote:
bll::bind(boost::make_tuple<int*, bool>, &bll::_1, true)); ////////////////////////////////////////////////////////////////
It doesn't compile:
$ g++-4.3.2 -I /usr/local/dev/boost-1.38.0/include/ main2.cpp main2.cpp: In function 'int main()': main2.cpp:22: error: no matching function for call to 'bind(<unresolved overloaded function type>, const boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::other_action<boost::lambda::addressof_action>, boost::tuples::tuple<boost::lambda::lambda_functor<boost::lambda::placeholder<1>
, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >, bool)' $
What's wrong in the second program?
* make_tuple is overloaded for more than 2 arguments. * When taking the address of a function template, the compiler can try to deduce template parameters based on the required signature. for example, static_cast<boost::tuple<int*, bool, char> >(*)(const int*&, const bool&, const char&)>(&boost::make_tuple<int*, bool>) is legal and will yield a different overload of make_tuple than the one that you intend. * bind is a function template so it doesn't provide enough information to resolve the ambiguity. In Christ, Steven Watanabe
participants (2)
-
Dmitry V. Krivenok
-
Steven Watanabe