相关疑难解决方法(0)

Clang,std :: shared_ptr和std :: less/operator <

拥有以下代码

#include <memory>

int main() {
    std::shared_ptr<int> ptr0( new int );
    std::shared_ptr<int> ptr1( new int );

    bool result = ptr0 < ptr1;
}
Run Code Online (Sandbox Code Playgroud)

使用clang编译时产生以下错误(版本3.1,LLVM 3.1,Debian GNU/Linux Sid)

/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/shared_ptr.h:364:14: error: no matching function for call to object of type 'std::less<_CT>'
      return std::less<_CT>()(__a.get(), __b.get());
             ^~~~~~~~~~~~~~~~
foo.cpp:9:21: note: in instantiation of function template specialization 'std::operator<<int, int>' requested here
        bool result = ptr0 < ptr1;
                           ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_function.h:236:7: note: candidate function not viable: no known conversion from 'int *' to 'int *&&&' for
      1st argument; …
Run Code Online (Sandbox Code Playgroud)

c++ clang c++11

8
推荐指数
1
解决办法
1496
查看次数

标签 统计

c++ ×1

c++11 ×1

clang ×1