-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added equality operator #5
Conversation
Tried to use googlemock for tests and it appears that the comparison operator is necessary.
Could you post your compiler error that lead you to this PR? Also, what's your compiler? Tests shouldn't be using |
Here's the test code: TEST_F(KafkaBrokerConfig, Flatten) {
std::vector<cppkafka::ConfigurationOption> options;
options = broker->flatten_options(broker->getConfig(), options, {"topic", "topics"});
std::vector<cppkafka::ConfigurationOption> expected = {
{"consumer.metadata.broker.list", "localhost"},
{"producer.metadata.broker.list", "localhost"}
};
ASSERT_THAT(expected, ::testing::ElementsAreArray(options));
} And here's the compiler:
And it's output:
|
So you added new code that relies on using |
No, this a use case where the |
the operator should be a free function regardless, to support type conversions on both left and right side. |
It will support both sides, because it's comparison against the |
You normally define free functions so that if your type is implicitly convertible from something else, it also works when using that other type as the left hand side of the operator. e.g. if ConfigurationOption config("some_config");
if ("some_config" == config) { // < fails to build
} If you turn this to a free function and also provide |
There's a guideline about it, but it doesn't include the rationale as well as @mfontanini just did. |
Actually the
|
also ConfigurationOption could have easily been implemented as |
in my mind the rationale for adding the comparison operators is still a bit weak. "google mock requires it" is all I see so far. It's not a given that supporting more operators is better. The question that needs to be answered is: "does it make sense to compare configuration options?", and then specifically which kinds of comparisons make sense. (at just a brief look, it seems reasonable that |
I agree with @arvidn. Does it really make sense for @accelerated using |
@mfontanini and @arvidn Yes my comment was not contending whether or not it's useful to have (I can't think of a use case for comparing options) but IF you have to add
And we have to wait till c++20 for |
Closing this as it's partially implemented at this point and it's stalled. If we're adding |
Tried to use googlemock for tests and it appears that the comparison operator is necessary.