1

The following codes can run very well in WINDOWS and LINUX but fail in 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. I also make sure that the compiler is using the new C++ standard 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
David G
  • 94,763
  • 41
  • 167
  • 253
feelfree
  • 11,175
  • 20
  • 96
  • 167

1 Answers1

1

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. You could try to include new C++11 headers, e.g. <array> to confirm that.

If I am right, just update your compiler :-)

Arne Mertz
  • 24,171
  • 3
  • 51
  • 90
  • Thanks, and could you let me know how to update the compiler? You are right and I cannot compile if head file is included. – feelfree Jun 13 '13 at 15:14
  • Uhm, I honeslty have no experience with XCode, LLVM and MAC. But a quick googling told me the updating xcode should be possible from the app store: http://stackoverflow.com/questions/14823519/xcode-update-from-4-5-1-to-4-6 – Arne Mertz Jun 13 '13 at 15:43
  • There are also possibilities of getting more recent versions of Clang than the one included in the latest XCode: http://stackoverflow.com/questions/8674546/how-to-update-llvm-clang-on-mac-osx – Arne Mertz Jun 13 '13 at 15:46