8
具有以下代碼鐺,STD :: shared_ptr的和std ::更少/操作員<
#include <memory>
int main() {
std::shared_ptr<int> ptr0(new int);
std::shared_ptr<int> ptr1(new int);
bool result = ptr0 < ptr1;
}
正在與鐺編譯時產生以下錯誤(版本3.1,3.1 LLVM,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;
operator()(const _Tp& __x, const _Tp& __y) const
^
編譯與GCC(版本4.7.0)相同的代碼不會引發任何錯誤消息。有沒有理由爲什麼運算符<()在clang中不能用於共享指針?
哇,int * &&&'... – kennytm