#pragma once #ifdef _WIN32 #include #elif __linux__ #else #error "이 플랫폼은 지원되지 않습니다." #endif #include namespace Chattr { class Thread { public: #ifdef _WIN32 static DWORD WINAPI __thread(LPVOID param) { std::unique_ptr> func(reinterpret_cast*>(param)); (*func)(); return 0; } #endif template Thread(Callable&& f, Args&&... args); }; template Thread::Thread(Callable&& f, Args&&... args) { auto boundFunc = std::bind(std::forward(f), std::forward(args)...); auto funcPtr = new std::function(boundFunc); #ifdef _WIN32 CreateThread(nullptr, 0, __thread, funcPtr, 0, nullptr); #endif } } // namespace Chattr