Boost logo

Boost Users :

From: Daniel James (daniel_james_at_[hidden])
Date: 2007-02-12 17:09:46


On Sun, 11 Feb 2007 21:24:42 -0000, Bob Quampen <0377521021_at_[hidden]> wrote:
> (boost::lambda::bind(&std::string::find, boost::lambda::_1, _ignore),

[snip]

boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::action<3,boost::lambda::function_action<3,T>>,detail::bind_tuple_mapper<const
> Arg1,const Arg2,const Arg3>::type>> boost::lambda::bind(const Arg1
> &,const
> Arg2 &,const Arg3 &)' : could not deduce template argument for
> 'overloaded
> function type' from 'overloaded function type'
>
> am i not supplying the correct amount of parameters to the find method?

Sort of, there are actually two problems here. The first is that
std::string::find has 2 overloads with one parameter and the compiler
doesn't know which one to use. The solution is to cast it to the correct
type, ie.

    static_cast<std::string::size_type (std::string::*)(const
std::string&)>(&std::string::find)

Which is pretty ugly. The second problem is that this won't work if find
is defined as a two argument method, with a default value for the second
argument (as it seems to be for gcc). In which case you do need to use a
second argument. This is pretty messy and hard to do portably (unless
anyone knows better?).

I wouldn't use Boost.Lambda for anything this complicated. I think some
work has gone into making this kind of thing easier in phoenix. But
Boost.ForEach is probably the best solution here. Or you could put the
loop body in a separate function.

Hope that helps.

Daniel


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net