lzpong / threadpool

based on C++11 , a mini threadpool , accept variable number of parameters 基于C++11的线程池,简洁且可以带任意多的参数

Home Page:http://www.cnblogs.com/lzpong/p/6397997.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

‘bind’ was not declared in this scope

ductina opened this issue · comments

大佬,我在本地CLION编译运行没有问题,在服务器上编译出现下面这个错误,我在网上找不到解决方法,你知道是什么愿意吗?
In file included from test.cpp:7:0:
util/threadpool.h: In instantiation of ‘std::future<decltype (f(std::threadpool::commit::args ...))> std::threadpool::commit(F&&, Args&& ...) [with F = void (&)(int); Args = {int}; decltype (f(std::threadpool::commit::args ...)) = void]’:
test.cpp:21:50: required from here
util/threadpool.h:59:17: error: ‘bind’ was not declared in this scope
bind(forward(f), forward(args)...)
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util/threadpool.h:59:17: note: suggested alternative: ‘rand’
bind(forward(f), forward(args)...)
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rand
In file included from test.cpp:7:0:
util/threadpool.h: In instantiation of ‘struct std::threadpool::commit(F&&, Args&& ...) [with F = void (&)(int); Args = {int}; decltype (f(std::threadpool::commit::args ...)) = void]::<lambda()>’:
util/threadpool.h:64:13: required from ‘std::future<decltype (f(std::threadpool::commit::args ...))> std::threadpool::commit(F&&, Args&& ...) [with F = void (&)(int); Args = {int}; decltype (f(std::threadpool::commit::args ...)) = void]’
test.cpp:21:50: required from here
util/threadpool.h:64:29: error: using invalid field ‘std::threadpool::commit(F&&, Args&& ...)::<lambda()>::’
_tasks.emplace(task{ // push(Task{...}) 放到队列后面

我解决了,编译的时候要带上-lpthread