_Args>
void callInMainContext(_Callable&& __f, _Args&&... __args) {
std::tuple<_Args...> _args = std::tuple<_Args...>(std::forward<_Args>(__args)...);
typedef std::pair<_Callable, std::tuple<_Args...>> cbParam_T;
cbParam_T* cbParam = new cbParam_T(std::forward<_Callable>(__f), _args);
// Args: ThreadFN, ThreadArg, ThreadFinishedFn
createThread([](void* argsp){
cbParam_T* arg = reinterpret_cast<cbParam_T*>(argsp);
// Вот тут все плохо arg->first=nullptr
call(arg->first, arg->second);
}, cbParam, [](void* argsp){
cbParam_T* arg = reinterpret_cast<cbParam_T*>(argsp);
delete arg;
});
}
tuple из ссылок (висячих)
Обсуждают сегодня