I'm trying to make a class Threads to call for example 20 classes called Thread that will perform an action. Thread contains only function, this funtion is Compress and informations about the thread(if its busy etc.). I also have to add that Threads keeps Thread classes in std::vector called threads. Yeah i should have picked better names. haha
Whole program seems to work well, but when i use std::thread in Threads file to call Compress function from Thread class then I run into programs when i'm trying to compile this.
so first i will show code, but only parts that will be helpful, I think content of Thread.cpp will be useless, but I will post it here if you it will be needed
//Thread.h:
class Thread
{
public:
BOOL isBusy = FALSE;
Threads *threadParent;
Thread();
~Thread();
BOOL Compress() { return prvCompress(); }
private:
BOOL prvCompress();
};
//Threads.h
class Threads
{
public:
std::vector<Thread>threads;
File *myFile;
Threads(File *myFile_);
~Threads();
BOOL CallCompress() { return prvCallCompress(); }
private:
BOOL prvCallCompress();
};
Here from Threads.cpp i will just paste this calling function
//Threads.cpp
BOOL Threads::prvCallCompress()
{
//for (UIN8 i = 0; i < ThreadsNumber; i++)
// std::thread(threads[i].Compress()).detach();
std::thread(this->threads.at(0).Compress()).detach();
return FALSE;
}
Errors:
Error number 1:
Severity Code Description Project File Line Suppression State
Error C2893 Failed to specialize function template 'unknown-type std::invoke(_Callable &&) noexcept(<expr>)' FileSlapper ...\VisualStudio\VC\Tools\MSVC\14.32.31326\include\thread 51
Error number 2:
Severity Code Description Project File Line Suppression State
Error C2672 'invoke': no matching overloaded function found FileSlapper ...\VisualStudio\VC\Tools\MSVC\14.32.31326\include\thread 55
What have I tried:
So basically I tried doing this without std::thread and it works well.
I also tried to use this instead of calling that function:
std::thread([&] { std::cout << threads[0].wasntUsed << std::endl; }).detach();
and this returned FALSE as it should, no errors
I also tried to just make a std::thread without even calling it, but it also ends up with an error:
std::thread(this->threads.at(0).Compress());
if i forgot to add something I will definitely do it if you guys ask. But i'm sure here I posted everything that its needed.
Thank you guys in advance.