• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Swift Generics Error When Enforcing Protocol Conformance...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Swift Generics Error When Enforcing Protocol Conformance...


  • Subject: Re: Swift Generics Error When Enforcing Protocol Conformance...
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 24 Dec 2015 14:41:29 -0800
  • Feedback-id: 167118m:167118agrif8a:167118sR49F_ORPD:SMTPCORP

On Dec 24, 2015, at 13:22 , Peters, Brandon <email@hidden> wrote:
>
> I do not see this one being any different from the integer type version.

What’s different is that FloatingPointType doesn’t have any arithmetic operators defined on it.

The solution is to add a protocol that requires that behavior:

> protocol ArithmeticFloatingPointType: FloatingPointType
> {
> 	func * (lhs: Self, rhs: Self) -> Self
> 	func += (inout lhs: Self, rhs: Self)
> }
>
> extension Double: ArithmeticFloatingPointType {} // These already have the operator that conforms, so nothing to do here
> extension Float: ArithmeticFloatingPointType {}
>
> func linconv<T: ArithmeticFloatingPointType>(signal_A signal_A: [T], signal_B: [T]) -> [T]? {
> …
> }

You’ll have to expand the new protocol for any other operators you happen to use.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Swift Generics Error When Enforcing Protocol Conformance...
      • From: "Peters, Brandon" <email@hidden>
References: 
 >Swift Generics Error When Enforcing Protocol Conformance... (From: "Peters, Brandon" <email@hidden>)
 >Re: Swift Generics Error When Enforcing Protocol Conformance... (From: Quincey Morris <email@hidden>)
 >Re: Swift Generics Error When Enforcing Protocol Conformance... (From: "Peters, Brandon" <email@hidden>)
 >Re: Swift Generics Error When Enforcing Protocol Conformance... (From: Quincey Morris <email@hidden>)
 >Re: Swift Generics Error When Enforcing Protocol Conformance... (From: "Peters, Brandon" <email@hidden>)
 >Re: Swift Generics Error When Enforcing Protocol Conformance... (From: "Peters, Brandon" <email@hidden>)

  • Prev by Date: Re: Swift Generics Error When Enforcing Protocol Conformance...
  • Next by Date: Re: Swift Generics Error When Enforcing Protocol Conformance...
  • Previous by thread: Re: Swift Generics Error When Enforcing Protocol Conformance...
  • Next by thread: Re: Swift Generics Error When Enforcing Protocol Conformance...
  • Index(es):
    • Date
    • Thread