Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion exercises/7/7.1/thread_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifndef THREAD_POOL_H
#define THREAD_POOL_H

#include <type_traits>
#include <vector> // std::vector
#include <queue> // std::queue
#include <memory> // std::make_shared
Expand Down Expand Up @@ -96,7 +97,7 @@ inline ThreadPool::ThreadPool(size_t threads): stop(false) {
template<class F, class... Args>
decltype(auto) ThreadPool::enqueue(F&& f, Args&&... args) {
// deduce return type
using return_type = typename std::result_of<F(Args...)>::type;
using return_type = typename std::invoke_result<F,Args...>::type;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using return_type = typename std::invoke_result<F,Args...>::type;
using return_type = std::invoke_result_t<F,Args...>;


// fetch task
auto task = std::make_shared<std::packaged_task<return_type()>>(
Expand Down