
Alberto Ganesh Barbati schrieb:
Christopher Eltschka ha scritto:
Doing some brainstorming, I get the following candidate list for useful automatic operators:
* comparison operators from operator< and operator== * operator @ from operator @= * posfix operator++/-- from prefix one * unary operator+ (returning just the object) * maybe also binary - from + and unary -?
Any other good candidates?
That's good, so good that we already have a header in Boost that does precisely all that and more. It's <boost/operators.hpp>, documented at <http://www.boost.org/libs/utility/operators.htm>.
Ah, sorry, although I looked into boost before writing the mail, I somehow missed that, despite its obvious name. However I see that the boost version forces you to explicitly repeat the class name, i.e. you have to write class X: boost::operators<X> { ... }; instead of just class X: boost::operators { ... }; Is there any specific reason to do so? After all, it seems to work well without that extra burden. Any specific example where I could get problems with my version? Thanks, Christopher Eltschka