brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 72f6ad5 Raw
28 lines · cpp
1// RUN: %clang_cc1 -std=c++2a -verify %s2 3struct Good1 {4  bool operator==(const Good1&) const = default;5  bool operator!=(const Good1&) const = default;6};7struct Good2 {8  friend bool operator==(const Good2&, const Good2&) = default;9  friend bool operator!=(const Good2&, const Good2&) = default;10};11 12enum Bool : bool {};13struct Bad {14  bool &operator==(const Bad&) const = default; // expected-error {{return type for defaulted equality comparison operator must be 'bool', not 'bool &'}}15  const bool operator!=(const Bad&) const = default; // expected-error {{return type for defaulted equality comparison operator must be 'bool', not 'const bool'}}16  friend Bool operator==(const Bad&, const Bad&) = default; // expected-error {{return type for defaulted equality comparison operator must be 'bool', not 'Bool'}}17  friend int operator!=(const Bad&, const Bad&) = default; // expected-error {{return type for defaulted equality comparison operator must be 'bool', not 'int'}}18};19 20template<typename T> struct Ugly {21  T operator==(const Ugly&) const = default; // expected-error {{return type}}22  T operator!=(const Ugly&) const = default; // expected-error {{return type}}23  friend T operator==(const Ugly&, const Ugly&) = default; // expected-error {{return type}}24  friend T operator!=(const Ugly&, const Ugly&) = default; // expected-error {{return type}}25};26template struct Ugly<bool>;27template struct Ugly<int>; // expected-note {{in instantiation of}}28