Skip to content

Why does the function with arguments have errors? #26

@mirro187

Description

@mirro187

error C2660 “std::packaged_task<int (int)>::operator ()”: The function does not take zero arguments

#include "thread_pool.hpp"
#include  "thread"
#include "future"
#include "functional"
#include "memory"
#include "iostream"
using namespace std;

int f(int j)
{
	return j;
}

int main(int argc, char **argv)
{
	tp::ThreadPool pool;
	//
	std::packaged_task<int(int)> t(f);
	std::future<int> r = t.get_future();
	pool.post(t);
	r.get();
	//while (1);
	getchar();
	return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions