简体   繁体   English

std错误名称空间中没有名为“ bind”的成员

[英]No member named 'bind" in the namespace of std error

The following codes can run very well in WINDOWS and LINUX but fail in MAC: 以下代码在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);
}

The development platform is Xcode 4, and the compiler is Clang LLVM 1.0. 开发平台是Xcode 4,编译器是Clang LLVM 1.0。 I also make sure that the compiler is using the new C++ standard c++0x. 我还要确保编译器正在使用新的C ++标准c ++ 0x。 The error messages are as follows: 错误消息如下:

   using namespace std::placeholders; *Expect namespace name
std::bind(sub_fun) *No member named "bind" in namespace std

Clang LLVM 1.0 seems pretty old, it's from 2003, so the standard library you have installed probably is a C++03 standard library that does not have placeholders and bind . Clang LLVM 1.0似乎很老,它来自2003年,因此您安装的标准库可能是没有placeholdersbind的C ++ 03标准库。 You could try to include new C++11 headers, eg <array> to confirm that. 您可以尝试包括新的C ++ 11标头,例如<array>来确认这一点。

If I am right, just update your compiler :-) 如果我对,请更新您的编译器:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM