Note that there are some explanatory texts on larger screens.

plurals
  1. PObind function parameters to thread
    primarykey
    data
    text
    <p>I tried calling a function with parameters, using boost, but it does not work. the code is this</p> <pre><code>void Simulate::cr_number_threaded(lint nodes) { for(lint i = 0; i &lt; trials_per_thread; i++) { // code } } void Simulate::run_cr_number() { vec_cr_number.clear(); boost::thread t[threads]; for(int i = 0; i &lt; n_s.size(); i++) { // n_s[i] is the current number of nodes for(int t_idx = 0; t_idx &lt; threads; t_idx++) t[t_idx] = boost::thread(cr_number_threaded, n_s[i]); // etc... } } </code></pre> <p>the error I get is the following:</p> <blockquote> <p>Simulate.cpp: In member function 'void Simulate::run_cr_number()': Simulate.cpp:27: error: no matching function for call to 'boost::thread::thread(, long int&amp;)'</p> </blockquote> <p>UPDATE: I followed the suggestions. Using the first solution I get</p> <blockquote> <p>Simulate.cpp: In member function 'void Simulate::run_cr_number()': Simulate.cpp:28: error: no matching function for call to 'bind(, long int&amp;)' ../../boost_1_44_0/boost/bind/bind.hpp:1472: note: candidates are: boost::_bi::bind_t::type> boost::bind(F, A1) [with F = void (Simulate::*)(lint), A1 = long int] ../../boost_1_44_0/boost/bind/bind.hpp:1728: note:<br> boost::_bi::bind_t::type, boost::_mfi::dm, typename boost::_bi::list_av_1::type> boost::bind(M T::*, A1) [with A1 = long int, M = void ()(lint), T = Simulate]</p> </blockquote> <p>using the second one I get this instead</p> <blockquote> <p>Simulate.cpp: In member function 'void Simulate::run_cr_number()': Simulate.cpp:28: error: no matching function for call to 'boost::thread::swap(boost::_bi::bind_t, boost::_bi::list2, boost::_bi::value > >)' ../../boost_1_44_0/boost/thread/detail/thread.hpp:310: note: candidates are: void boost::thread::swap(boost::thread&amp;)</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload