Leon Mergen wrote:
On Mon, Dec 13, 2004 at 07:52:44PM +0000, Ben Hutchings wrote:
This calls the constructor you expected once, and then the copy constructor as well. If you don't want the BackupHandlerThread to be copied, I think you need to construct it other than as a temporary and pass a reference wrapper (boost::ref<BackupHandlerThread>) to the thread constructor.
Ahhh, this solution indeed works - thanks a lot for your quick response!
Remember that if you define a class that shouldn't be copiable you can easily prevent it and avoid such mishaps by deriving privately from boost::noncopiable. If you're in a situation where you can't use Boost then declare the copy constructor and copy assignment operator as private and don't define them. (See items 11 and 27 of Effective C++ or item 53 of C++ Coding Standards.) Ben.