|
Boost : |
From: Beman Dawes (beman_at_[hidden])
Date: 1999-11-12 18:28:28
Darin Adler wrote:
>Dave Abrahams mentioned his operators.h library.
>
>I believe that library provides a class template that implements
operator !=
>for a subclass based on the operator == in that subclass, using the
>"curiously-recurring" template pattern.
>
>This only works for member function versions of operator ==.
>
>But I haven't seen operators.h, I don't think.
Dave and I have been working on finishing touches for operators.hpp,
documentation, and a test+demonstration program. Should be ready for
posting sometime next week.
Here is the equality_comparable portion:
template <class T, class U = T>
class equality_comparable
{
friend bool operator==( const U& y, const T& x ) { return x ==
y; }
friend bool operator!=( const U& y, const T& x ) { return !(x ==
y); }
friend bool operator!=( const T& y, const U& x ) { return !(y ==
x); }
};
template <class T>
class equality_comparable<T, T>
{
friend bool operator!=( const T& x, const T& y ) { return !(x ==
y); }
};
--Beman
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk