Please can someone help explain why I get an error when compiling the following code using Xcode 5.1 on OS X. Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn).
#include <vector>
#include <functional>
void func1(const std::string& value)
{
// ...
}
void func2(const std::string& value, int min, int max)
{
// ...
}
class X
{
public:
void x1(const std::string& value)
{
// ...
}
void x2(const std::string& value, int min, int max)
{
// ...
}
};
const std::vector<std::function<void(std::string)>> functions
{
func1,
std::bind(func2, std::placeholders::_1, 5, 6),
std::mem_fn(&X::x1), // compiler error
};
The error reported is:
no matching constructor for initialization of 'const std::vector<std::function<void (std::string)> >'
const std::vector<std::function<void(std::string)>> functions
Furthermore, I would like to add X::x2 to the vector. How would I do that?
Thanks.