-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Comparison operators for custom types #2036
Comments
Hi @MoonModules, Comparison with custom types is not supported. Best regards, |
Hi Benoit, Even better (as the function is a template):
but then != was not defined for Coordinate so I changed the struct:
And now it's perfect ! One question, is comparison with custom types not supported by design (as it should be done as shown above), or might it be a future enhancement? Thx again, Kind regards, Ewoud from MoonModules |
Only thing I am not sure of is if the Type is const char * then the != should be a strcmp ... could that also be overloaded (question to myself 🙂 ) In that case lot less strcmp in code which looks cleaner (but could confuse core char * people 🙂) |
JsonString ... 🙂 |
@MoonModules, I suppose we could make this a feature, but as a wise man once wrote:
It'll convert this issue to a feature request and see if more users are interested. |
Description
See reproduction code below. Using a custom defined struct works for assignments (using Converter<>) as described in https://arduinojson.org/news/2021/05/04/version-6-18-0/
But I cannot get it to work for comparison operators (like var["value"] != value in below example).
I get this error:
.pio/libdeps/esp32dev/ArduinoJson/src/ArduinoJson/Variant/VariantCompare.hpp:203:15: error: 'ArduinoJson::V6214PB2::detail::Comparer<Coordinate, void> comparer' has incomplete type
Comparer comparer(rhs);
Tried to add Comparer like functions but all resulted in compile errors.
Help / code example really appreciated.
Thx
Ewoud
Troubleshooter's report
Environment
Reproduction code
The text was updated successfully, but these errors were encountered: