下面的代码在WINDOWS和LINUX下可以很好的运行,但是在MAC上就不行了:
template <typename T>
inline bool similar_fun(const std::vector<T> &a, const std::vector<T> &B, T threshold)
{
using namespace std::placeholders;
std::vector<T> differ;
std::transform(a.begin(), a.end(), b.begin(),
std::back_inserter(differ), std::bind(sub_fun<T>, _1, _2));
return (std::accumulate(differ.begin(), differ.end(), static_cast<T>(0), Norm2<T>()) <= threshold);
}
开发平台为Xcode 4,编译器为Clang LLVM 1.0。我还确保编译器使用新的 C++ 标准 c++0x。错误信息如下:
using namespace std::placeholders; *Expect namespace name
std::bind(sub_fun) *No member named "bind" in namespace std
最佳答案
Clang LLVM 1.0 看起来很老了,它是从 2003 年开始的,所以你安装的标准库可能是一个没有 placeholders
的 C++03 标准库。和 bind
.您可以尝试包含新的 C++11 header ,例如<array>
确认这一点。
如果我是对的,只需更新你的编译器:-)
关于c++ - 在 std 错误的命名空间中没有名为 'bind"的成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17089273/