This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Question about operator!=() in stl_relops.h


I have a problem with the old standard C++ library (g++-3, not g++-v3).

from stl_relops.h:

template <class _Tp>
inline bool operator!=(const _Tp& __x, const _Tp& __y) {
  return !(__x == __y);
}

The problem with this is that it makes it extremely hard to overload != using
a template for one of one's own classes:

From my own header:

template <class T, class T2>
inline bool	operator!=(Ptr<T> a, Ptr<T2> b) throw ()
{
	return a.ptr() != b.ptr();
}

If both of these headers are included together, then compilation doesn't
work.  If I remove mine, I've gotta include stl_relops.h in my file.

Is it part of the standard to have operator!= defined this way?  If so, which
header file should I include in my header file to get it?  Will g++-v3 do
this?  Will I include the same header file?

Thanks.

--
George T. Talbot
<george at moberg dot com>

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]