On Monday 16 September 2002 16:50, Marcio Del'Valle wrote:
Hi there,
When I use boost::thread for creating multiple threads I notice
destructor of object I pass as an argument ( boost::thread (*pObjetc) ) is called twice. Why does it happen?
because boost makes a copy (acutally several!!) of the object, and
destroys them. boost calls the copy constructor to get a copy of
--- In Boost-Users@y..., Luis De la Parra
you pass as a function object, and then makes another copy (don't know why) and then destroyes the "temporary" objects.
This is documented. The number of copies made is left to the implementation, but generally should be kept to a minimum. If you don't want "pass by value" semantics use a wrapper/adapter such as boost::ref. Bill Kempf