This is a little hard to explain, In my class i have a create function that takes a pointer and arguments I want to be able to check if the function im passing to that function has the ClassPointer as its 1st argument if so automaticly add this to the function inside "create" if not just add the normal functions arguments if any,like im doing
template <typename Function, typename... Arguments>
void SomeClass::create(HWND hWnd, Function func, Arguments&&... args)
{
// check if function's 1st argument = class pointer
std::function<void()> function = std::function<void()>(std::bind(std::forward<Function>(func), this, std::forward<Arguments>(args)...));
// else
std::function<void()> function = std::function<void()>(std::bind(std::forward<Function>(func), std::forward<Arguments>(args)...));
}
void ThreadProc1(SomeClass* pThis, HWND hwnd)
{
// do some stuff in here
}
void ThreadProc2(HWND hwnd)
{
// do some stuff in here
}
test.Create(hwnd, ThreadProc1, hwnd);
test.Create(hwnd, ThreadProc2, hwnd);
Aucun commentaire:
Enregistrer un commentaire