title: How to take address of an overloaded operator defined as a friend in class body in C++
body: <p>How can I take an address of an overloaded operator defined as a friend in a class body?</p>
  
  <p>I tried the following</p>
  
  <pre><code>struct S {
    friend bool operator==(S, S) { return true; }
  };
  
  int main() {
    bool (*f)(S, S) = &amp;operator==;
  }
  </code></pre>
  
  <p>But gcc gives an error</p>
  
  <pre><code>test.cc: In function ‘int main()’:
  test.cc:6:30: error: ‘operator==’ not defined
     bool (*f)(S, S) = &amp;operator==;
                                ^
  </code></pre>
  
  <p>which can be fixed by declaring the operator in the (global) namespace:</p>
  
  <pre><code>bool operator==(S, S);
  </code></pre>
  
  <p>Is there a way to take the address without redeclaring the operator?</p>