dimanche 4 octobre 2015

Overload operator== on std::shared_ptr

I was considering overloading the equality and ordering operators of std::shared_ptr for a particular type. So if I have the following

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
}

So this would mean equality would no longer be just pointer equality. Is there a downside or some ugly pitfall to doing this?

Aucun commentaire:

Enregistrer un commentaire