title: What is a proper way to implement is_swappable to test for the Swappable concept?
body: <p>I would consider "proper" implementation for <code>is_swappable</code> to be the following:</p>
  
  <pre><code>template&lt;class T, class U = T&gt; struct is_swappable&lt;T, U&gt; : /* see below */ { }
  </code></pre>
  
  <p><code>is_swappable</code> inherits from <a href="http://en.cppreference.com/w/cpp/types/integral_constant"><code>std::true_type</code></a> if T and U are <a href="http://en.cppreference.com/w/cpp/concept/Swappable"><strong><code>Swappable</code></strong></a>, otherwise from <a href="http://en.cppreference.com/w/cpp/types/integral_constant"><code>std::false_type</code></a>.</p>
  
  <hr>
  
  <p>I have tried many things, but SFINAE just doesn't seem to work. This is a particularly nasty counterexample:</p>
  
  <pre><code>struct A {
      A() {}
      ~A() {}
      A(const A&amp;) = delete;
      A(A&amp;&amp;) = delete;
  };
  </code></pre>
  
  <p>Clearly <code>A</code> is not <a href="http://en.cppreference.com/w/cpp/concept/Swappable"><strong><code>Swappable</code></strong></a>. Yet any generic solution I can come up with does not properly handle the above example.</p>
  
  <p>A SFINAE implementation I have tried, but did not work looked like this:</p>
  
  <pre><code>namespace with_std_swap {
      using std::swap;
  
      template&lt;class T, class U, class =
          decltype(swap(std::declval&lt;T&amp;&gt;(), std::declval&lt;U&amp;&gt;()))&gt;
      std::true_type swappable_test(int);
  
      template&lt;class, class&gt; std::false_type swappable_test(...);
  }
  
  template&lt;class T, class U = T&gt;
  struct is_swappable
  : decltype(with_std_swap::using_std_swap::swappable_test&lt;T, U&gt;(0)) { };
  </code></pre>
  
  <p>Is there any way to code <code>is_swappable</code> without compiler help?</p>