diff --git a/emp-tool/utils/ThreadPool.h b/emp-tool/utils/ThreadPool.h index 19c7bc1..83143a5 100644 --- a/emp-tool/utils/ThreadPool.h +++ b/emp-tool/utils/ThreadPool.h @@ -39,8 +39,13 @@ class ThreadPool { public: ThreadPool(size_t); template +#if __cplusplus >= 202002L + auto enqueue(F&& f, Args&&... args) + -> std::future::type>; +#else auto enqueue(F&& f, Args&&... args) -> std::future::type>; +#endif ~ThreadPool(); int size() const; private: @@ -87,11 +92,19 @@ inline ThreadPool::ThreadPool(size_t threads) } // add new work item to the pool +#if __cplusplus >= 202002L +template +auto ThreadPool::enqueue(F&& f, Args&&... args) + -> std::future::type> +{ + using return_type = typename std::invoke_result::type; +#else template auto ThreadPool::enqueue(F&& f, Args&&... args) -> std::future::type> { using return_type = typename std::result_of::type; +#endif auto task = std::make_shared< std::packaged_task >( std::bind(std::forward(f), std::forward(args)...)