Boost logo

Boost Users :

From: David A. Greene (greened_at_[hidden])
Date: 2006-01-24 11:54:06


Stuart Dootson wrote:

>>I had to pass "&tester" to the first bind expression because g++
>>complained about passing "tester" as "const Test &." Is passing by
>>reference supposed to work?
>
> Only if you use a reference wrapper - i.e. you can use
> boost::ref(tester) or boost::lambda::var(tester) rather than &tester

The documentation is misleading, then:

   The object argument can be a reference or pointer to the object, the
   BLL supports both cases with a uniform interface:

     bool A::foo(int) const;
     A a;
     vector<int> ints;
       ...
     find_if(ints.begin(), ints.end(), bind(&A::foo, a, _1));
     find_if(ints.begin(), ints.end(), bind(&A::foo, &a, _1));

> If you're using a shared_ptr, you'll either need to use tester.get()
> directly to get a Test* to pass into the bind expression
>
> bind(&Test::foo, tester.get(), value)
>
> or something like
>
> bind(&Test::foo, bind(boost::shared_ptr<Test>::get, tester), value)
>
> to delay the call to tester.get() until invocation of printer.bar().

Yuck. Oh well, guess that's what I'll do. Are there any plans to
add direct support for smart pointers?

                                  -Dave


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