title: Concept definition requiring a constrained template member function
body: <p><em>Note: everything that follows uses the Concepts TS implementation in GCC 6.1</em></p>
  
  <p>Let's say I have a concept <code>Surface</code>, like the following:</p>
  
  <pre><code>template &lt;typename T&gt;
  concept bool Surface() {
      return requires(T&amp; t, point2f p, float radius) {
          { t.move_to(p) };
          { t.line_to(p) };
          { t.arc(p, radius) };
          // etc...
      };
  }
  </code></pre>
  
  <p>Now I want to define another concept, <code>Drawable</code>, which matches any type with a member function:</p>
  
  <pre><code>template &lt;typename S&gt;
      requires Surface&lt;S&gt;()
  void draw(S&amp; surface) const;
  </code></pre>
  
  <p>i.e.</p>
  
  <pre><code>struct triangle {
      void draw(Surface&amp; surface) const;
  };
  
  static_assert(Drawable&lt;triangle&gt;(), ""); // Should pass
  </code></pre>
  
  <p>That is, a <code>Drawable</code> is something which has a templated const member function <code>draw()</code> taking an lvalue reference to something which satisfies the <code>Surface</code> requirements. This is reasonably easy to specify in words, but I can't quite work out how to do it in C++ with the Concepts TS. The "obvious" syntax doesn't work:</p>
  
  <pre><code>template &lt;typename T&gt;
  concept bool Drawable() {
      return requires(const T&amp; t, Surface&amp; surface) {
          { t.draw(surface) } -&gt; void;
      };
  }
  </code></pre>
  
  <blockquote>
    <p>error: 'auto' parameter not permitted in this context</p>
  </blockquote>
  
  <p>Adding a second template parameter allows the concept definition to compile, but: </p>
  
  <pre><code>template &lt;typename T, Surface S&gt;
  concept bool Drawable() {
      return requires(const T&amp; t, S&amp; s) {
          { t.draw(s) };
      };
  }
  
  static_assert(Drawable&lt;triangle&gt;(), "");
  </code></pre>
  
  <blockquote>
    <p>template argument deduction/substitution failed:
    couldn't deduce template parameter 'S'</p>
  </blockquote>
  
  <p>now we can only check whether a particular &lt;<code>Drawable</code>, <code>Surface</code>> <em>pair</em> matches the <code>Drawable</code> concept, which isn't quite right. (A type <code>D</code> either has the required member function or it does not: that doesn't depend on which particular <code>Surface</code> we check.)</p>
  
  <p>I'm sure it's possible to do what I'm after, but I can't work out the syntax and there aren't too many examples online yet. Does anybody know how to write a concept definition which requires type to have a constrained template member function?</p>