Can I create a constrained extension on Array so it only operates on [CGPoint]
<p>I am designing a function that will take an array of CGPoints, treat it as end points of a poly-line, and insert intermediate points using Catmull-Rom smoothing to create an approximation of a curve that passes through those points.</p>

<p>The function can be defined as a global function:</p>

<pre><code>func smoothPoints(array: [CGPoint], granularity: Int = 4) -&gt; [CGPoint] {
    return [CGPoint]() //Placeholder code for actual implementation
  }
</code></pre>

<p>But I'd like to be able to define it as a constrained extension on the <code>Array</code> type, so that it will only operate on arrays of <code>CGPoint</code>s. Is that possible?</p>

<p>The only examples of constrained extensions I've been able to find in Swift 3 constrain the array elements to objects that conform to a protocol, not a specific data (Struct) type.</p>

<p>It seems like I should be able to do something like this:</p>

<pre><code>extension Array where Element: CGPoint {
func smoothPoints(granularity: Int = 4) -&gt; [CGPoint] {
  }
}
</code></pre>

<p>But that gives me an error "type 'Element' constrained to non-protocol type 'CGPoint'". </p>

<p>The declaration </p>

<pre><code> extension Array&lt;CGPoint&gt;
</code></pre>

<p>...doesn't work either.</p>

<p>It seems like it should be possible to define an extension to the Array class that only operates on arrays of a specific type, but I can't figure out how to do so.</p>

<p>Is what I'm trying to do possible in Swift 3, or am I stuck with a global function?</p>