I would greatly appreciate any help here. I am trying to call a function asynchronously with Boost::Thread, but I am getting some errors. This is my real code.
In main:
vector<std::string> a = ...;
vector<std::string> b = ...;
vector<boost::thread> threads;
threads.push_back(boost::thread(do_work, an_integer, a[i], b.begin(), b.end()));
// Later I will join()...
Elsewhere:
void do_work(int i, std::string a_string, vector<string>::iterator begin, vector<string>::iterator end)
{
// Some stuff
}
I am quite new to this stuff, being much more used to C#. Anyway, these are the errors I am getting:
error C2664: 'void (int,std::string,std::_Vector_iterator<_Myvec>,std::_Vector_iterator<_Myvec>)' : cannot convert parameter 1 from 'std::_Vector_iterator<_Myvec>' to 'int'
error C2664: 'void (int,std::string,std::_Vector_iterator<_Myvec>,std::_Vector_iterator<_Myvec>)' : cannot convert parameter 3 from 'std::basic_string<_Elem,_Traits,_Ax>' to 'std::_Vector_iterator<_Myvec>'
error C2664: 'void (int,std::string,std::_Vector_iterator<_Myvec>,std::_Vector_iterator<_Myvec>)' : cannot convert parameter 4 from 'std::_Vector_iterator<_Myvec>' to 'std::_Vector_iterator<_Myvec>'
I would greatly appreciate any help you could offer. I am almost certainly doing something extremely inane! Thanks a lot.
That compiler error says that
b.begin()andb.end()are different types, which clearly can’t be in the code you’ve listed. Recheck your code to make sure you haven’t definedbto be something else. (Also checkan_integersince the compiler believes it’s an iterator.)