Boost logo

Boost :

From: Terence Wilson (tez_at_[hidden])
Date: 2002-03-22 10:09:41


Here's a more complete version. I just want to be able to pass 2
arguments by reference to an object method. The objects are in container
of boost::shared_ptr<MyClass>

Class MyClass
{
...

Public:
        void MyMethod1(long& thing1);
        void MyMethod2(long& thing1, long& thing2);
}

#include <boost/bind.hpp>
.
.
std::vector<boost::shared_ptr<MyClass> > Vec;
long something1, something2;
.
.

// this compiles and works ok
std::for_each(Vec.begin(), Vec.end(), boost::bind(&MyClass::MyMethod1,
_1, boost::ref(something1)));

// this gets me a shedload of compilation errors
std::for_each(Vec.begin(), Vec.end(), boost::bind(&MyClass::MyMethod2,
_1, _2, boost::ref(something1), boost::ref(something2)));

I'm using VC 7 & Boost_1_25_1

-----Original Message-----
From: boost-admin_at_[hidden] [mailto:boost-admin_at_[hidden]]
On Behalf Of Peter Dimov
Sent: Friday, March 22, 2002 6:12 AM
To: boost_at_[hidden]
Subject: Re: [boost] newbie- how to: bind with 2 reference arguments

From: "Terence Wilson" <tez_at_[hidden]>
> Thanks to PeterD I am using calls of this form in my code:
>
> std::vector<boost::shared_ptr<SomeClass> > Vec;
>
> std::for_each(Vec.begin(), Vec.end(), boost::bind(&myClass::myMethod,
> _1, boost::ref(DownloadListView), boost::ref(ParentTreeItem)));
>
> now I would like to use the same technique to call a method expecting
> 2 reference arguments, can someone help with the correct syntax? I'm
> out of permutations to try. If it matters, I'm using VC++ 7.0.

Could you please provide a more complete example? What is SomeClass? How
is myMethod defined? What are you trying to do? :-)

_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost


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