C++11 重载运算符==在std::shared\u ptr上

C++11 重载运算符==在std::shared\u ptr上,c++11,C++11,我正在考虑为特定类型重载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 instan

我正在考虑为特定类型重载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,我希望有更具启发性的东西。它看起来是有效的C++,那么它是以什么方式非法的呢?