Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Easy way to write comparison functions? (http://www.velocityreviews.com/forums/t955593-easy-way-to-write-comparison-functions.html)

Jayden 12-17-2012 04:18 PM

Easy way to write comparison functions?
 
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

Marc 12-22-2012 12:07 PM

Re: Easy way to write comparison functions?
 
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.


All times are GMT. The time now is 08:51 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.