473,513 Members | 2,275 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Comparison operators

Say I want to define all the operator==, operator!=, operator<=,
operator>, etc for a class.

I could've sworn there was a library (maybe in Boost) that helped me do
this (so I don't have to define all of them by hand).
Was I imagining it?

Thanks,
Joe
Aug 10 '06 #1
4 1569
Joe Van Dyk wrote:
Say I want to define all the operator==, operator!=, operator<=,
operator>, etc for a class.
So, define them. What's stopping you?
I could've sworn there was a library (maybe in Boost) that helped me
do this (so I don't have to define all of them by hand).
Was I imagining it?
Quite possible. What kind of "help" do you expect?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 10 '06 #2

Joe Van Dyk wrote:
Say I want to define all the operator==, operator!=, operator<=,
operator>, etc for a class.

I could've sworn there was a library (maybe in Boost)
Would you be surprised if I told you it was Boost::operators?

http://www.boost.org/libs/utility/operators.htm

Aug 10 '06 #3
On Thu, 10 Aug 2006 06:19:13 -0700, Michiel.Salters wrote:
>
Joe Van Dyk wrote:
>Say I want to define all the operator==, operator!=, operator<=,
operator>, etc for a class.

I could've sworn there was a library (maybe in Boost)

Would you be surprised if I told you it was Boost::operators?

http://www.boost.org/libs/utility/operators.htm
Ah, thanks. That looks like what I was looking for.

Joe

Aug 10 '06 #4
On Wed, 09 Aug 2006 23:24:10 -0400, Victor Bazarov wrote:
Joe Van Dyk wrote:
>Say I want to define all the operator==, operator!=, operator<=,
operator>, etc for a class.

So, define them. What's stopping you?
Because in most cases, defining all of them duplicates knowledge. Which I
try to avoid. And it's tedious and boring.
>I could've sworn there was a library (maybe in Boost) that helped me
do this (so I don't have to define all of them by hand).
Was I imagining it?

Quite possible. What kind of "help" do you expect?
A way for me to specify the results of a couple of the operators, and have
the others generated through some means.

Aug 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5390
by: Michael Klatt | last post by:
I've just encountered a strange situation (at least to me) regarding friend operators and member operators: #include <map> class Key { friend bool operator<(const Key& lhs, const Key& rhs)...
13
4582
by: jstanforth | last post by:
This is probably a very obvious question, but I'm not clear on what operators need to be implemented for std::map.find() to work. For example, I have a class MyString that wraps std::string, and...
29
2593
by: Steven D'Aprano | last post by:
Playing around with comparisons of functions (don't ask), I discovered an interesting bit of unintuitive behaviour: >>> (lambda y: y) < (lambda y: y) False Do the comparison again and things...
2
2038
by: PengYu.UT | last post by:
I'm wonder whether 1. stl directly defined the 6 comparison operators(== != < > <= >=) directly for iterator and const_iterator 2. or it only define == and < and using std::rel_ops to get the...
1
5087
by: Thats Me | last post by:
TMALSS: Task With maintenance of Access Database I did not develop, don't ask about non-commented code problems or where data dictionary is (LOL). Have table with Inventory data for all...
2
2592
by: Serve La | last post by:
Now that implementations are becoming available, I've started to learn more about C99. Now I was reading about the isgreater/isgreaterequal/isless/... macro's and I'm wondering about why they are...
37
2762
by: spam.noam | last post by:
Hello, Guido has decided, in python-dev, that in Py3K the id-based order comparisons will be dropped. This means that, for example, "{} < " will raise a TypeError instead of the current...
17
2013
by: Dinsdale | last post by:
I would like to compare a string value to a pre-determined list of other strings. Is there a simple way to do this in one statements like this: if(strMystring.ToUpper() == ("STRING1"| "STRING2"|...
2
2734
by: Mark Rae | last post by:
Hi, This isn't *specifically* an ASP.NET question, so I've also posted it in the ADO.NET group - however, it's not too far off-topic... Imagine a SQL Server 2005 database with a table with an...
2
3011
by: puzzlecracker | last post by:
Unlike C++, in Csharp you're only allowed to compare a generic type T with null, if the method it's passed in not implementing IComparable<Tor , IEquatable<T(still don't know why we need these...
0
7171
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7388
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7541
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5693
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5098
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4751
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1607
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
461
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.