Boost logo

Boost Users :

From: Daniel James (daniel_at_[hidden])
Date: 2005-02-09 06:40:13


Surya Kiran Gullapalli wrote:
> Well,
> I was able to fix the previous problem, but i'm running into another
> problem similar to this.
> I'm using the same bind call, but this time i'm getting error like this.

Hi,

You might want to consider using stlfilt (google for it) to make the
errors more readable. Also, it's quite hard to tell what's wrong without
any example code. And it'd be more helpful if you put the name of the
library you're using in the subject line - you're using the lambda
library not the bind library (there is a difference).

> =========================
> cxtreeview.cpp:55: error: call of overloaded `bind(bool
> (CXTreeView::*&)(Gtk::TreeIter&), CXTreeView* const, const
> boost::lambda::lambda_functor<boost::lambda::placeholder<1> >&)' is
> ambiguous
> /nfs/skglnx/home/skg/.packages/boost-1.32.0/include/boost-1_32/boost/lambda/detail/bind_functions.hpp:415:
> note: candidates are: const
> boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::action<3,
> boost::lambda::function_action<3, boost::lambda::detail::unspecified> >,
> typename boost::lambda::detail::bind_tuple_mapper<typename
> boost::lambda::detail::constify_non_funcs<T>::type, const Arg2, const
> Arg3, 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>::type> > boost::lambda::bind(const Arg1&,
> const Arg2&, const Arg3&) [with Arg1 = bool
> (CXTreeView::*)(Gtk::TreeIter&), Arg2 = CXTreeView*, Arg3 =
> boost::lambda::lambda_functor<boost::lambda::placeholde r<1> >]
> /nfs/skglnx/home/skg/.packages/gnome-2.8/include/sigc++-2.0/sigc++/adaptors/bind.h:2104:
> note: sigc::bind_functor<-0x000000001, T_functor,
> typename sigc::unwrap_reference<T_type>::type, typename
> sigc::unwrap_reference<T_bound1>::type, sigc::nil, sigc::nil, sigc::nil,
> sigc::nil, sigc::nil> sigc::bind(const T_functor&, T_type1, T_type2)
> [with T_type1 = CXTreeView*, T_type2 =
> boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, T_functor
> = bool (CXTreeView::*)(Gtk::TreeIter&)]
> ========================
>
> I was not able to figure out how the const keyword is coming into
> picture for the second argument of bind function.

The const is not the problem, in 'CXTreeView* const' the *pointer* is
const, not the CXTreeView, you have to read these declarations are read
from right to left. Looking at the first function, the argument is
'const Arg2&' with 'Arg2 = CXTreeView*' - ie. CXTreeView* const&. So it
matches. Yes, this is pretty hard to read.

A better way to look at it, is to examine the original error:

     cxtreeview.cpp:55: error: call of overloaded bind(....) is ambiguous

This shows you that there are more than one valid functions that can be
called, and they are: 'boost::lambda::bind' and 'sigc::bind'. Stlfilt
would make this a lot more obvious.

I expect that 'sigc::bind' comes from libsigc++ (are you using gtkmm?)
and that you're writing:

    using namespace boost::lambda;
    using namespace sigc;

Which is leading to the name clashes since bind is declared in both
namespaces. You should try making less use of 'using' declarations, used
to heavily they can cause problems. With libraries like Boost.Lambda I
often only put the using declaration inside the function where it's
used. Namespace aliases also help a lot.

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