From 2f6f63b25c64e36047878fded9d14030b8c3b6d8 Mon Sep 17 00:00:00 2001 From: Nan Xiao Date: Tue, 24 Apr 2018 09:23:36 +0800 Subject: [PATCH] Use C++14 feature: decltype(auto) --- ThreadPool.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ThreadPool.h b/ThreadPool.h index 4183203..3a28c45 100644 --- a/ThreadPool.h +++ b/ThreadPool.h @@ -15,8 +15,7 @@ class ThreadPool { public: ThreadPool(size_t); template - auto enqueue(F&& f, Args&&... args) - -> std::future::type>; + decltype(auto) enqueue(F&& f, Args&&... args); ~ThreadPool(); private: // need to keep track of threads so we can join them @@ -60,8 +59,7 @@ inline ThreadPool::ThreadPool(size_t threads) // add new work item to the pool template -auto ThreadPool::enqueue(F&& f, Args&&... args) - -> std::future::type> +decltype(auto) ThreadPool::enqueue(F&& f, Args&&... args) { using return_type = typename std::result_of::type;