Skip to content

Commit

Permalink
Use C++14 feature: decltype(auto)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhasse committed Jan 18, 2019
1 parent 467d2f4 commit ce41656
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions ThreadPool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class ThreadPool {
public:
explicit ThreadPool(size_t);
template<class F, class... Args>
auto enqueue(F&& f, Args&&... args)
-> std::future<std::invoke_result_t<F, Args...>>;
decltype(auto) enqueue(F&& f, Args&&... args);
~ThreadPool();
private:
// need to keep track of threads so we can join them
Expand Down Expand Up @@ -54,8 +53,7 @@ inline ThreadPool::ThreadPool(size_t threads)

// add new work item to the pool
template<class F, class... Args>
auto ThreadPool::enqueue(F&& f, Args&&... args)
-> std::future<std::invoke_result_t<F, Args...>>
decltype(auto) ThreadPool::enqueue(F&& f, Args&&... args)
{
using return_type = std::invoke_result_t<F, Args...>;

Expand Down

0 comments on commit ce41656

Please sign in to comment.