So, my task is to pass both vectors char & int in the template with two threads.
Why it cannot thread to reading the two containers ? Some push will be helpful.
#include <iostream>
#include <thread>
#include <vector>
template<typename T>
void check(std::vector<T> values){
for(T& it : values){
std::cout<< it <<std::endl;
}
}
int main()
{
std::vector<int> int_values = {1,2,3,4,5};
std::vector<char> char_values = {'a','b','c','d','e'};
std::thread th1(check, int_values);
std::thread th2(check, char_values);
th1.join();
th2.join();
return 0;
}
The Error is:
error: no matching function for call to std::thread::thread(<unresolved overloaded function type>,std::vector<int>&)