Guillermo Martony
Greetings, The following code taken from an example compiles without errors:
#include
#include #include <iostream> class thread_alarm { <snip> }; int main() { int secs = 5; std::cout << "setting alarm for 5 seconds..." << std::endl; thread_alarm alarm(secs); boost::thread thrd(alarm); thrd.join(); return 0; }
But adding a std::fstream varible to the thread_alarm class: <snip> Results in the following compilation error:
c:\opt\include\boost\function\function_template.hpp(289): error C2664: 'void boost::function0
::assign_to(Functor)' : cannot convert parameter 1 from 'const thread_alarm' to 'thread_alarm' with [ R=void, Allocator=int, Functor=thread_alarm ]
The boost::thread constructor copies its argument, so the thread_alarm class needs to be copiable, but std::fstream is not copiable. You might be better off using Boost.Bind to produce a lightweight functor.