title: Swift protocol generic as function return type
body: <p>I want to use generic protocol type as a function return type like this:</p>
  
  <pre><code>protocol P {
    associatedtype T
    func get() -&gt; T?
    func set(v: T)
  }
  
  class C&lt;T&gt;: P {
    private var v: T?
    func get() -&gt; T? {
      return v
    }
    func set(v: T) {
      self.v = v
    }
  }
  
  class Factory {
    func createC&lt;T&gt;() -&gt; P&lt;T&gt; {
      return C&lt;T&gt;()
    }
  }
  </code></pre>
  
  <p>But this code compile with errors complained:</p>
  
  <ol>
  <li>Cannot specialize non-generic type 'P'</li>
  <li>Generic parameter 'T' is not used in function signature</li>
  </ol>
  
  <p>Is there any way to achieve similar function with Swift？</p>