0
我正在考虑重载std :: shared_ptr的相等和排序运算符以用于特定类型。所以,如果我有以下内容std :: shared_ptr上的重载运算符==
struct Foo { /* Stuff */ };
bool operator==(const std::shared_ptr<Foo>& lhs, const std::shared_ptr<Foo>& rhs)
{
// Do something reasonable for equality using the Foo instances
}
所以这将意味着平等将不再是指针平等。这样做有缺点或者一些丑陋的陷阱吗?
看起来很可能这确实是无效的,但是标准中的一句话或者是一个真正实现的中断可能会更有说服力。 – hvd
我同意hvd我希望有更多的启发点。它似乎是有效的C++,所以它是非法的? – goneskiing