c++ - 在 std 错误的命名空间中没有名为 'bind"的成员

标签 c++ xcode xcode4

下面的代码在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/

相关文章:

xcode4 - 在 xcode 4 中编辑build设置

c++ - 如何使用点在 QPixmap 上画线

c++ - 在 C++ 中使用 2D vector 时出现明显的内存泄漏

iphone - 如何更新 NSMutableDictionary

ios - Spritebuilder、XCode 5.1 和设备构建错误

xcode - 作为 SKTexture 的物理体不旋转

objective-c - 所有对象都继承自 NSObject 吗?

c++ - C++ 中的二维 vector

c++11随机数生成: how to re-implement `uniform_int_distribution` with `mt19937` without templates

ios - NSDictionary中的值是有效的,内部为null