void foo(string & str)
{
str = "foo";
}
int main(int argc, char * argv[])
{
string str1("Hello world");
string str2(str1);
thread trd1(bind(&foo, str1));
thread trd2(bind(&foo, str2));
trd1.join();
trd2.join();
return 0;
}
The following is the compile log:
Compiling...
testThread.cpp
d:\Programming\boost\boost\boost\thread\exceptions.hpp(29) : warning C4275:
non dll-interface class 'std::logic_error' used as base for dll-interface
class 'boost::lock_error'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\stdexcept(14) : see declaration of 'std::logic_error'
d:\Programming\boost\boost\boost\thread\exceptions.hpp(28) : see
declaration of 'boost::lock_error'
d:\Programming\boost\boost\boost\thread\exceptions.hpp(35) : warning C4275:
non dll-interface class 'std::runtime_error' used as base for dll-interface
class 'boost::thread_resource_error'
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\stdexcept(136) : see declaration of 'std::runtime_error'
d:\Programming\boost\boost\boost\thread\exceptions.hpp(34) : see
declaration of 'boost::thread_resource_error'
d:\Programming\boost\boost\boost\thread\mutex.hpp(37) : warning C4275: non
dll-interface class 'boost::noncopyable' used as base for dll-interface
class 'boost::mutex'
d:\Programming\boost\boost\boost\noncopyable.hpp(22) : see
declaration of 'boost::noncopyable'
d:\Programming\boost\boost\boost\thread\mutex.hpp(36) : see
declaration of 'boost::mutex'
d:\Programming\boost\boost\boost\thread\mutex.hpp(75) : warning C4275: non
dll-interface class 'boost::noncopyable' used as base for dll-interface
class 'boost::try_mutex'
d:\Programming\boost\boost\boost\noncopyable.hpp(22) : see
declaration of 'boost::noncopyable'
d:\Programming\boost\boost\boost\thread\mutex.hpp(74) : see
declaration of 'boost::try_mutex'
d:\Programming\boost\boost\boost\thread\mutex.hpp(115) : warning C4275: non
dll-interface class 'boost::noncopyable' used as base for dll-interface
class 'boost::timed_mutex'
d:\Programming\boost\boost\boost\noncopyable.hpp(22) : see
declaration of 'boost::noncopyable'
d:\Programming\boost\boost\boost\thread\mutex.hpp(114) : see
declaration of 'boost::timed_mutex'
d:\Programming\boost\boost\boost\thread\thread.hpp(39) : warning C4275: non
dll-interface class 'boost::noncopyable' used as base for dll-interface
class 'boost::thread'
d:\Programming\boost\boost\boost\noncopyable.hpp(22) : see
declaration of 'boost::noncopyable'
d:\Programming\boost\boost\boost\thread\thread.hpp(38) : see
declaration of 'boost::thread'
d:\Programming\boost\boost\boost\thread\thread.hpp(68) : warning C4275: non
dll-interface class 'boost::noncopyable' used as base for dll-interface
class 'boost::thread_group'
d:\Programming\boost\boost\boost\noncopyable.hpp(22) : see
declaration of 'boost::noncopyable'
d:\Programming\boost\boost\boost\thread\thread.hpp(67) : see
declaration of 'boost::thread_group'
d:\Programming\boost\boost\boost\thread\thread.hpp(79) : warning C4251:
'boost::thread_group::m_threads' : class 'std::list<_Ty>' needs to have
dll-interface to be used by clients of class 'boost::thread_group'
with
[
_Ty=boost::thread *
]
d:\Programming\boost\boost\boost\bind.hpp(186) : error C2664: 'void
(std::string &)' : cannot convert parameter 1 from 'const std::string' to
'std::string &'
Conversion loses qualifiers
d:\Programming\boost\boost\boost\bind\bind_template.hpp(21) : see
reference to function template instantiation 'R
boost::_bi::list1<A1>::operator
()