title: public friend swap member function
body: <p>In the beautiful answer to the <a href="https://stackoverflow.com/questions/3279543/what-is-the-copy-and-swap-idiom#3279550">copy-and-swap-idiom</a> there is a piece of code I need a bit of help:</p>
  
  <pre><code>class dumb_array
  {
  public:
      // ...
      friend void swap(dumb_array&amp; first, dumb_array&amp; second) // nothrow
      {
          using std::swap; 
          swap(first.mSize, second.mSize); 
          swap(first.mArray, second.mArray);
      }
      // ...
  };
  </code></pre>
  
  <p>and he adds a note</p>
  
  <blockquote>
    <p>There are other claims that we should specialize std::swap for our type, provide an in-class swap along-side a free-function swap, etc. But this is all unnecessary: any proper use of swap will be through an unqualified call, and our function will be found through ADL. One function will do.</p>
  </blockquote>
  
  <p>With <code>friend</code> I am a bit on "unfriendly" terms, I must admit. So, my main questions are:</p>
  
  <ul>
  <li><strong>looks like a free function</strong>, but its inside the class body?</li>
  <li><strong>why isn't this <code>swap</code> static</strong>? It obviously doesn't use any member variables.</li>
  <li><strong>"Any proper use of swap will find out swap via ADL"</strong>? ADL will search the namespaces, right? But does it also look inside classes? Or is here where <code>friend</code> comes in?</li>
  </ul>
  
  <p>Side-questions:</p>
  
  <ul>
  <li>With C++11, should I mark my <code>swap</code>s with <strong><code>noexcept</code></strong>?</li>
  <li>With C++11 and its <strong>range-for</strong>, should I place <code>friend iter begin()</code> and <code>friend iter end()</code> the same way inside the class? I think the <code>friend</code> is not needed here, right?</li>
  </ul>