簡體   English   中英

std錯誤名稱空間中沒有名為“ bind”的成員

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

以下代碼在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年,因此您安裝的標准庫可能是沒有placeholdersbind的C ++ 03標准庫。 您可以嘗試包括新的C ++ 11標頭,例如<array>來確認這一點。

如果我對,請更新您的編譯器:-)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM