boost::bind with template

Hi, I would like to create a thread group for my "worker objects" like: std::vector< worker<T,D> > l_worker; boost::thread_group l_threads; for(std::size_t i=0; i < p_threads; ++i) { l_worker.push_back( worker<T,D>(p_iteration, p_stepsize, m_derivation, m_optimize, m_static, p_batch) ); l_threads.create_thread( boost::bind( &worker<T,D>::optimize ), l_worker[i] ); (*) } I get a compiler error at (*) on boost/bind/bind.hpp: In instantiation of 'boost::_bi::result_traits<boost::_bi::unspecified, void (worker<double, 2ul>::*)()>': error: 'void (worker<double, 2ul>::*)()' is not a class, struct, or union type boost/bind/bind_template.hpp:15: instantiated from 'boost::_bi::bind_t<boost::_bi::unspecified, void (worker<double, 2ul>::*)(), boost::_bi::list0>' The variables T is a typename and D is std::size_t > 0 How can I bind my template object (<doube, 2>) to the create_thread methode? Thanks Phil

On 2010-08-15 10:39:35 +0200, Kraus Philipp said:
Hi,
I would like to create a thread group for my "worker objects" like:
std::vector< worker<T,D> > l_worker; boost::thread_group l_threads; for(std::size_t i=0; i < p_threads; ++i) { l_worker.push_back( worker<T,D>(p_iteration, p_stepsize, m_derivation, m_optimize, m_static, p_batch) ); l_threads.create_thread( boost::bind( &worker<T,D>::optimize ), l_worker[i] ); (*) }
Okay ich hatte die Klammer and die falsche Stelle gesetzt. Schande über mich, ich habe den ganzen Tag diesen Fehler nicht gesehen => boost::bind( &worker<T,D>::optimize, l_worker[i] )

On 2010-08-15 22:49:10 +0200, Philipp Kraus said:
On 2010-08-15 10:39:35 +0200, Kraus Philipp said:
Hi,
I would like to create a thread group for my "worker objects" like:
std::vector< worker<T,D> > l_worker; boost::thread_group l_threads; for(std::size_t i=0; i < p_threads; ++i) { l_worker.push_back( worker<T,D>(p_iteration, p_stepsize, m_derivation, m_optimize, m_static, p_batch) ); l_threads.create_thread( boost::bind( &worker<T,D>::optimize ), l_worker[i] ); (*) }
Okay ich hatte die Klammer and die falsche Stelle gesetzt. Schande über mich, ich habe den ganzen Tag diesen Fehler nicht gesehen => boost::bind( &worker<T,D>::optimize, l_worker[i] )
I had set the bracket on the wrong position and write in german.
participants (2)
-
Kraus Philipp
-
Philipp Kraus