title: In Swift, how to generically limit function to types that understand T + T
body: <p>I would like to have a generic function that can use the plus operator on two values.</p>
  
  <pre><code>class funccalc {
      func doAdd&lt;T&gt;(x:T,y:T) -&gt; T {
          return x + y
      }
  }
  let a = funccalc()
  println(a.doAdd(1, y: 4))
  println(a.doAdd(23.54, y:200))
  </code></pre>
  
  <p>I get an error on <code>return x + y</code></p>
  
  <p>Is my only option to follow the suggestion in this answer: <a href="https://stackoverflow.com/a/24047239/67566">https://stackoverflow.com/a/24047239/67566</a>, and create my own protocol as <code>Int</code> and <code>String</code> would define the operator?</p>