Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(exercise): replace std::result_of with std::invoke_result since the old one is deprecated in C++20; #273

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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