std::vector<int> v1;
std::function<void(const int&)> funct =
static_cast<std::function<void(const int&)>>(std::bind(
&std::vector<int>::push_back,
&v1,
std::placeholders::_1));
This gives me no matching function for call to bind.
I am able to do this though:
threadPool.push_back(std::thread(runThread<lazyFunct>,
std::bind(&LazySkipList<int>::add,
&lsl, std::placeholders::_1), 0, 1000000, 1000000));
I am using Xcode 4.4 with llvm C++11 support.
The problem is
std::vector::push_back()is overloaded with the two possible type signatures:As such, the template parameter to
std::bind()cannot be inferred. However, you can declare the template parameter explicitly:This resolves correctly.
Of course, at this point it might be simpler just to use a lambda: