I'm curious why base::Version has an "Equals" method, rather than an overload for operator==. Is anyone aware of the design rationale? Similarly, the "IsOlderThan" method could have been implemented as operator<. I've just noticed their absence when writing tests involving base::Version and GTest complaining that it can't test them for equality. The style guide says "Don't go out of your way to avoid defining operator overloads. For example, prefer to define ==, =, and <<, rather than Equals(), CopyFrom(), and PrintTo()."
I'm curious why base::Version has an "Equals" method, rather than an overload for operator==. Is anyone aware of the design rationale?
Ah ok. Would it be a welcome change to add an operator== overload to base::Version? Also, should I follow the style guide and implement operator== for new classes (where appropriate), or prioritise consistency and implement Equals methods?
Ah ok. Would it be a welcome change to add an operator== overload to base::Version?
I'm just trying to get a feeling for what the preferred approach is in this sort of situation (I'm new to Chromium dev). Replacing the Equals method is cleaner, but obviously a far bigger change, whereas just adding the operator would allow a more gradual transition. The latter does result in there being two ways of testing equality though, as Brett points out and wishes to avoid.
Personally, I'm tempted to just leave it as it is. I can still test equality of Versions, just not with EXPECT_EQ (so the failure message won't be as useful, but that's not a big deal). I was most interested in whether there'd be strong opinions one way or another. Am I right in concluding that updating code simply for the sake of making it compliant with updates to the style guide is discouraged, but new code should be written as such?
Thanks for your input everyone.
I'm just trying to get a feeling for what the preferred approach is in this sort of situation (I'm new to Chromium dev). Replacing the Equals method is cleaner, but obviously a far bigger change, whereas just adding the operator would allow a more gradual transition. The latter does result in there being two ways of testing equality though, as Brett points out and wishes to avoid.
Personally, I'm tempted to just leave it as it is. I can still test equality of Versions, just not with EXPECT_EQ (so the failure message won't be as useful, but that's not a big deal). I was most interested in whether there'd be strong opinions one way or another. Am I right in concluding that updating code simply for the sake of making it compliant with updates to the style guide is discouraged, but new code should be written as such?
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
I'm just trying to get a feeling for what the preferred approach is in this sort of situation (I'm new to Chromium dev). Replacing the Equals method is cleaner, but obviously a far bigger change, whereas just adding the operator would allow a more gradual transition. The latter does result in there being two ways of testing equality though, as Brett points out and wishes to avoid.
Personally, I'm tempted to just leave it as it is. I can still test equality of Versions, just not with EXPECT_EQ (so the failure message won't be as useful, but that's not a big deal). I was most interested in whether there'd be strong opinions one way or another. Am I right in concluding that updating code simply for the sake of making it compliant with updates to the style guide is discouraged, but new code should be written as such?
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
With enable_if, that's certainly possible, though I'm not sure ADL would always find it. Brett wasn't in favour of having two ways of doing the same thing though.
I wonder if it's possible to create global template operator== which only enables itself if type has Equals method.