При передачи строки получаю ошибку "error C2672: "std::invoke" ". Подскажите как правильно передать стрингу в потоку?
#include <iostream>
#include <thread>
#include <atomic>
#include <fstream>
#include <string>
std::atomic_bool f = true;
std::atomic_int number_thread = 0;
int n{0};
void func_1(int n, std::string & mess)
{
while (mess[n] != *mess.end())
{
if (f == false)
{
break;
}
if (number_thread == n)
{
std::cout << mess[n++] << " " << number_thread << std::endl;
number_thread++;
if (number_thread == 4)
{
number_thread = 0;
}
}
else
{
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
}
}
int main()
{
int count_thread = std::thread::hardware_concurrency();
std::cout << count_thread << std::endl;
std::ifstream f1("test.obj");
std::string mes{};
f1 >> mes;
for (int i = 0; i < 4; i++)
{
std::thread thr(func_1, i, mes);
thr.detach();
}
std::this_thread::sleep_for(std::chrono::seconds(5));
f = false;
system("pause");
return 0;
}
void func_1(int n, std::string mess)
илиvoid func_1(int n, const std::string & mess)
.