Odp
overloads operator*
to return m_p
. You can invoke the operator on *this
and rhs
:
struct Ftw : public Odp<int>
{
bool operator==(const Ftw& rhs) const
{
return **this == *rhs;
}
};
The operator*
overload is a bit unusual, however: it should probably return *m_p
instead, since operator->
returns m_p
(this would result in your class having consistent pointer-like semantics). If you did this, you would then have to do the following to do the comparison:
return &**this == &*rhs; // or explicitly as:
return &this->operator*() == &rhs.operator*();
This is getting a bit messy, and it won't necessarily work if the unary &
is overloaded for T
(but, you really, really shouldn't do that...). You can also obtain the pointer by explicitly calling operator->
, which might be preferable:
return this->operator->() == rhs.operator->();
The real question is, "what is this Odp
, why are you using it, and why can you not modify it?"
On an unrelated note, your operator==
should either be implemented as a const member function or, preferably, as a friend function:
bool operator==(const Ftw& rhs) const { /* ... */ }
friend bool operator==(const Ftw& lhs, const Ftw& rhs) { /* ... */ }
On another unrelated note, overloading the unary &
is almost certainly a bad idea.