Skip to content

CWG2797 Meaning of "corresponds" for rewritten operator candidates #1645

@jensmaurer

Description

@jensmaurer

There are special rules around rewritten operator candidates that make the following example well-formed, because the example appears in existing code bases:

  struct B {
    bool operator==(const B&);
  };
  struct C : B {
    C();
    C(B);
    bool operator!=(const B&);
  };
  bool c1 = B() == C();    // should be OK

Due to unrelated changes, the current wording makes this example ill-formed (because the two member operators have different object parameter types). This was not intended.

While fixing this, should the special rules be extended to also cover member operators with explicit object parameters? It seems unlikely that a new feature such as explicit object parameters would appear in a code base that also uses rather baroque combinations of comparison operators.

See CWG2797 for more details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Awaiting updated wording

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions