Boost logo

Boost Users :

From: Chris Goller (goller_at_[hidden])
Date: 2005-11-30 16:03:53


On 11/30/05, Peter Dimov <pdimov_at_[hidden]> wrote:
> Chris Goller wrote:
>
> > Sadly, the same problem: works with msvc 7.1 put not intel 9.0:
> >
> > error: more than one instance of overloaded function "mem_fn" matches
> > the argument list:
> > function template "boost::mem_fn(R (T::*)() const)"
> > function template "boost::mem_fn(R (T::*)())"
> > argument types are: (<unknown-type>)
> >
> >
> > This problem initially came up when I was using boost::bind in this
> > way:
> >
> > make_transform_iterator(v.begin(), bind(&array_type::at, _1, 0))
>
> This is a bug in MSVC 7.1, I guess. You need to disambiguate:
>
> array_type::reference (array_type::* pmf) (array_type::size_type) =
> &array_type::at;
>
> make_transform_iterator( v.begin(), bind(pmf, _1, 0) );
>
> Unfortunately, there is no way to tell from bind(&array_type::at, _1, 0)
> whether you need the const or non-const overload, and it is not possible to
> somehow store both overloads for later use.

Peter, thanks, you rock. I finally understand what is going on here.

Is this a more elegant way?

boost::make_transform_iterator(v.end(),
bind(static_cast<array_type::reference (array_type::*)
(array_type::size_type)>(&array_type::at), _1, 0));

Chris


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