Boost logo

Boost Users :

From: Mark Loew (mloew_at_[hidden])
Date: 2003-09-26 17:38:00


Alright I am now functioning in my code.

Now the hard part. Can you explain to me what I am missing.
The _1 states to use the first paramter in the first position.

Doug mentioned that there is an implicit 'this' argument.

So the bind is creating a function object
template<class S, class T, class A>
With the constructor of
        somefunc( S (T::*p)(A) ); // declaring the pointer to the
function

        then the operator is
                operator( T *p, A x )
                        and calls the func

So in the bind I was thinking that
Boost::bind( Base::CheckFunc, x )

I wrongly assumed that the T value was the variable passed in by the
find_if and the second parameter was the x my second variable on my
func.

What am I missing. I just don't want my code to work I want to know
why. Makes reusing the thing much easier.

Mark Loew, MCSD, MCSE
Application Development Consultant
Sagestone Consulting
www.sagestone.com
Grand Rapids, MI
616-954-9556 x149
Microsoft Gold Certified Partner
mloew_at_[hidden]

-----Original Message-----
From: Peter Dimov [mailto:pdimov_at_[hidden]]
Sent: Friday, September 26, 2003 6:11 PM
To: Boost Users mailing list
Subject: Re: [Boost-users] Base Pointer member functions failure

Mark Loew wrote:
> Okay,
>
> Call me stupid but I can't get this to work
>
> class Base
> {
> virtual const bool CheckFunc(const value& val ) const { return
> true; } }

[...]

> std::find_if( vecBase.begin(), vecBase.end(),
> boost::bind(Base::CheckFunc, aVal ) );

Try

    boost::bind(&Base::CheckFunc, _1, aVal)

instead. Remember that a member function has an implicit 'this'
argument. _______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


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