M
Marcel Müller
I found the following code fragment:
template <class T>
class ptr
{private:
T* Ptr;
public:
// ...
friend bool operator==(const ptr<T>& l, const ptr<T>& r)
{ return l.Ptr == r.Ptr; }
friend bool operator==(const ptr<T>& sco, const T* ptr)
{ return sco.Ptr == ptr; }
friend bool operator==(const T* ptr, const ptr<T>& sco)
{ return sco.Ptr == ptr; }
friend bool operator!=(const ptr<T>& l, const ptr<T>& r)
{ return l.Ptr != r.Ptr; }
friend bool operator!=(const ptr<T>& sco, const T* ptr)
{ return sco.Ptr != ptr; }
friend bool operator!=(const T* ptr, const ptr<T>& sco)
{ return sco.Ptr != ptr; }
};
Obviously free functions are implemented within the class body.
Is this valid? And if it is valid are these functions implicitly inline
like other function implementations in the class body?
Marcel
template <class T>
class ptr
{private:
T* Ptr;
public:
// ...
friend bool operator==(const ptr<T>& l, const ptr<T>& r)
{ return l.Ptr == r.Ptr; }
friend bool operator==(const ptr<T>& sco, const T* ptr)
{ return sco.Ptr == ptr; }
friend bool operator==(const T* ptr, const ptr<T>& sco)
{ return sco.Ptr == ptr; }
friend bool operator!=(const ptr<T>& l, const ptr<T>& r)
{ return l.Ptr != r.Ptr; }
friend bool operator!=(const ptr<T>& sco, const T* ptr)
{ return sco.Ptr != ptr; }
friend bool operator!=(const T* ptr, const ptr<T>& sco)
{ return sco.Ptr != ptr; }
};
Obviously free functions are implemented within the class body.
Is this valid? And if it is valid are these functions implicitly inline
like other function implementations in the class body?
Marcel