c++ - 使用 Solaris CC 的 std::BinaryPredicate 问题

标签 c++ solaris sunstudio

我在 Solaris 上使用 Sun Studio 编译器时遇到问题。它似乎与 libCstd 有关。

考虑以下代码:

#include <list>
static bool f(double fFreq1, double fFreq2) { return false; }
int main()
{
    std::list< double > l;
    l.unique(f);
}

我得到的错误信息是:

"uniq.cpp", line 6: Error: Could not find a match for std::list<double>::unique(bool(double,double)) needed in main().

但是当我使用引用而不是值时,它编译得很好:

#include <list>
static bool f(const double& fFreq1, const double& fFreq2) { return false; }
int main()
{
    std::list< double > l;
    l.unique(f);
}

使用 g++ 都可以编译。有谁知道发生了什么事?谢谢!

最佳答案

尝试使用 -library=STLport4 构建,因为标准 C++ 库不符合标准。参见 http://www.oracle.com/technetwork/server-storage/solarisstudio/documentation/cplusplus-faq-355066.html#LibComp5了解更多信息。

关于c++ - 使用 Solaris CC 的 std::BinaryPredicate 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7518022/

相关文章:

c++ - 具有代理设计模式的预处理器

c++ - Sun Studio 10 有奇怪的 `sun` 常量?

c++ - 乌部错误 : _mm_aeskeygenassist_si128 intrinsic requires at least -xarch=aes

c - UDP套接字池会不会提高数据报传递的成功率和效率?

linux - 使用 shell 脚本向电子邮件组发送电子邮件

c++ - 使用 std::fstream 对象销毁对象时出现 SIGBUS

c++ - 使用调试符号编译需要额外的库?

c++ - (x==0) 可以比 (0==x) 更有效吗?

c++ - 在 vs2005 中,有没有什么方法可以轻松地将一些源代码从一个文件夹移动到另一个文件夹?

c++ - 错误 : SetLayeredWindowAttributes was not declared in scope when including windows. h