Skip to content
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

MTLObjectCache: Correct signature of equality operator #11022

Merged

Conversation

merryhime
Copy link
Contributor

@merryhime merryhime commented Aug 29, 2022

In C++20, the expression DepthStencilSelector{} == DepthStencilSelector{} is non-conforming code without this change.

The underlying reason for this reversed operators in C++20 results in two candidates being produced:

bool operator==(DepthStencilSelector& /*this*/, DepthStencilSelector const& other);
bool operator==(DepthStencilSelector const& other, DepthStencilSelector& /*this*/);

This results in an ambiguity due to there being two viable candidates.

Making this a const reference solves this problem.

Not doing so produces a warning in clang:
    ISO C++20 considers use of overloaded operator '!=' (with operand types
    'Metal::DepthStencilSelector' and 'Metal::DepthStencilSelector') to be
    ambiguous despite there being a unique best viable function with
    non-reversed arguments

The underlying reason for this warning is an incorrect method signature.
@AdmiralCurtiss
Copy link
Contributor

Makes sense to me.

@AdmiralCurtiss AdmiralCurtiss merged commit fb88a4e into dolphin-emu:master Aug 30, 2022
11 checks passed
@merryhime merryhime deleted the ambiguous-reversed-operator branch August 30, 2022 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants