U++ framework
Do not panic. Ask here before giving up.

Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » overloading operators rules
Re: overloading operators rules [message #21284 is a reply to message #19431] Mon, 11 May 2009 16:47 Go to previous message
piotr5 is currently offline  piotr5
Messages: 107
Registered: November 2005
Experienced Member
I think a third rule would be to watch out for operator-priority-list. it wouldn't make much sense to define an operator which in combination with other operators needs to be put into brackets all the time. for example in boolean logic "*" is used for and, "+" is used for or, even though the two could be used the other way around, simply because it is more convenient to have a tighter binding between 2 things which live in an and-condition. (for example (a&b)|(c&d) is more natural for us to understand than (a|b)&(c|d)...)

another interesting rule which stl seems to obey is that some operators must have symmetric parameters-types. some algoritms of stl are only defined when both parameters of the operator are of the same type. I don't remember where I had this problem though, but I think it had something to do with the "<" operator...
 
Read Message icon5.gif
Read Message
Read Message
Read Message
Previous Topic: I don't get some aspects of STL ... [pointless rant]
Next Topic: Basic library interface and separation problem
Goto Forum:
  


Current Time: Tue Jun 23 09:23:23 GMT+2 2026

Total time taken to generate the page: 0.00482 seconds