SafePointer requires another == and != operator

        bool operator== (const SafePointer<ComponentType>& component) const noexcept   { return weakRef == component; }
        bool operator!= (const SafePointer<ComponentType>& component) const noexcept   { return weakRef != component; }

Otherwise you get warnings if you try and make an Array of SafePointers.

warning: ISO C++20 considers use of overloaded operator '==' (with operand types 'A' and 'A') to be ambiguous despite there being a unique best viable function [-Wambiguous-reversed-operator]

Comparison operators require both the function to be const and the parameter to be const, which isn’t the case for the other == operator. And adding const to it breaks a bunch of other stuff. I’m not a C++ template master, maybe it can be fixed.

2 Likes

Same problem in combination with juce::WeakReference. Triggered in this case by tracktion.

ISO C++20 considers use of overloaded operator '==' (with operand types 'const juce::WeakReference<tracktion_engine::Selectable>' and 'const juce::WeakReference<tracktion_engine::Selectable>') to be ambiguous despite there being a unique best viable function

Is this the same reported here: Obscure Xcode warning in JUCE code with C++20 enabled - #6 by yfede ?

If so, I believe a solution has been already committed, and recently merged into master with release of 7.0.4. Are you using an earlier version?

Is this still a problem? As far as I can tell, this seems to be resolved now. If not, please provide a minimal example that demonstrates the problem.

1 Like

I can no longer reproduce

1 Like

Thanks for checking!