Boost logo

Boost :

From: Roman Yakovenko (roman.yakovenko_at_[hidden])
Date: 2004-05-13 05:23:34


>best2=bind(&Node::value2,
> bind( &std::vector<Node>::at, //Ask for an element
> bind(&Node::children,_1), //Get the vector object
> 0 ) //Ask for element zero
> );
>
> [3]:
> function.cpp: In function `int main(int, char**)':
> function.cpp:69: no matching function for call to
> `bind(<unknown type>, const
>
> boost::lambda::lambda_functor<boost::lambda::lambda_functor_ba
> se<boost::lambda::action<2,
> boost::lambda::function_action<2,
> boost::lambda::detail::unspecified> >,
> boost::tuples::tuple<std::vector<Node,
> std::allocator<Node> > Node::*, const
> 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> > >, int)'
>

It's simple, compiler can't guess which function "at" you try to bind.

See overloading section of lambda documentation.
Hint:

typedef std::vector<int> ints;
typedef ints::const_reference ( ints::*ConstAtFunc ) (ints::size_type) const;
Now call bind with ConstAtFunc( at ) as function

Roman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk