|
Boost Users : |
From: Server Levent Yilmaz (leventyilmaz_at_[hidden])
Date: 2007-01-22 10:25:23
On 1/22/07, Paul Giaccone <paulg_at_[hidden]> wrote:
> I wondered if it was necessary to overload operator= for Obj3Type as,
> presumably, the compiler cannot generate it for the scoped arrays in
> that struct but can for everything in Obj4Type, including Vector, for
> which I have defined operator=. I wrote an operator= for Obj3Type, but
> it made no difference to the compiler error. This was to be expected
> really, as obj3 is passed by reference rather than by value.
>
> Does it have anything to do with using structs instead of classes? I
> can't see how that could be the case.
>
> So what am I missing here?
You are missing a copy constructor. Even though my_test() takes
arguments by reference, Boost.Bind binds them by value and since you
have scoped_array you need to provide a copy constructor (in addition
to operator=) yourself.
Or, you can bind by reference:
boost::bind( ... , ref(obj3), ... )
hth
-- Server Levent Yilmaz Mechanical Engineering @ PITT
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