
On 5/22/08, Anthony Williams
Chris Ross
writes: Hi there. This is an introductory question as I've just started to play with boost libraries. If this would be better on the threads-devel list, let me know, but I thought starting here would be good.
Here is fine.
I was playing with the threads library in 1.35, and I noticed that I can't (with gcc 4.3 on Linux) put boost::thread objects into an STL container. I think I was trying with a std::vector, in case that matters.
No, you can't do that. You need a container that can handle movable-but-not-copyable objects. Not only that, but it needs to handle the thread move emulation.
As a dirty alternative, it is possible to have the thread object wrapped in a structure. You allocate the structure on the heap and put that into the container. Since copying of pointers is cheap, you do not incurr the overhead of copying in STL containers. However, you need to free up the memory during clearing the container. Or, even use the BOOST shared pointer, I have not used this though. -dhruva -- Contents reflect my personal views only!