Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Easy way to write comparison functions?

Reply
Thread Tools

Easy way to write comparison functions?

 
 
Jayden
Guest
Posts: n/a
 
      12-17-2012
I have a class with an attribute of type std::string. I'd like to provide some comparison operator functions like <, >, ==, <=, and >= for the class by comparing the attribute.

My questions is that: any easy way or tool to

(1) just write one or two functions, such as the one for operator < (and ==), others can be automatically generated.

(2) or even simpler since the class comparison is depending on its attribute of type std::string whose comparison functions are already provided.

Thank you so much!

Jayden
 
Reply With Quote
 
 
 
 
Marc
Guest
Posts: n/a
 
      12-22-2012
Jayden wrote:

> I have a class with an attribute of type std::string. I'd like to provide some comparison operator functions like <, >, ==, <=, and >= for the class by comparing the attribute.
>
> My questions is that: any easy way or tool to
>
> (1) just write one or two functions, such as the one for operator < (and ==), others can be automatically generated.


Look at Boost.Operators, which does exactly this.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparison of 2 files and generating the output based on comparison Deepu Perl Misc 1 02-07-2011 03:09 PM
Price Comparison Service. Best Deal. Special Coupon atBest-Price-Comparison.com rapee Digital Photography 0 03-14-2008 06:46 AM
Easy Way To Read / Write Files on Website? Nonee HTML 3 09-02-2005 03:15 AM
Easy Way To Read / Write Files on Website? Nonee HTML 1 09-01-2005 04:59 PM
any easy way to write out a XML DOM object to file? Kaidi Java 2 11-26-2004 01:28 AM



Advertisments