2009/11/8 tiredashell <tiredashell@gmail.com>
I am successfully using Boost.Thread on Windows without a hitch, but when porting my program to OSX I get the following compile error, followed by an enormous chain of errors that probably are a derivative of it:
./boost/thread/detail/thread.hpp:108: error: ‘boost::thread::thread(boost::thread&)’ is private
When checking the class that it mentioned, it appears that it is in fact declared as private for some reason. Is there a reason I'm only receiving this error on OSX, and how can it be fixed?
Do you by any chance have code like this?
void Foo() {}
int main() {
boost::thread t = Foo;
}
Standard conforming compiler must reject this code, because boost::thread is not copyable (even though all modern compilers know how to elide this copy). As far as I remember, MS compiler will compile this code happily. The solution is to change the last line to this:
boost::thread t(Foo);
Here's another case where you might see the same problem:
void Foo() {}
void Bar(const boost::thread&) {}
int main() {
Bar(boost::thread(Foo));
}
Again, MS compiler compiles it, but it should not, because C++03 requires boost::thread to be copyable in this case.
HTH,
Roman Perepelitsa.