Topic: std::rel_ops
Author: kingd@cis.ohio-state.edu (Davis King)
Date: Tue, 1 Jul 2003 23:46:01 +0000 (UTC) Raw View
Why aren't the templates in std::rel_ops implemented like
template <typename A, typename B> bool operator> (const A& a, const B&
b) { return b < a; }
?
Let me also explain why I'm asking:)
I'm making a bigint object and I have operator<(const bigint&) and then
two global friends called operator<(int,const bigint&) and
operator<(const bigint&,int).
I also have similar operator== functions.
Anyways.
my problem is that the std::rel_ops operators only work when the types
being compared are the same. So if I create the above templated compare
then everything SEEMS to work just fine and I can compare my bigints to
ints all I please. However, since the rel::ops aren't implemented
this way it makes me worried that there is some bizarre behavior caused
by doing this that I don't know about.
So am I worried over nothing?
-Davis
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]