Re: Swift Generics Error When Enforcing Protocol Conformance...
Re: Swift Generics Error When Enforcing Protocol Conformance...
- Subject: Re: Swift Generics Error When Enforcing Protocol Conformance...
- From: "Peters, Brandon" <email@hidden>
- Date: Thu, 24 Dec 2015 23:55:28 +0000
- Thread-topic: Swift Generics Error When Enforcing Protocol Conformance...
Quincey,
I will read more. Wow! Did not realize that difference was enough to cause this. Maybe they will “remedy” it in the forever.
On Dec 24, 2015, at 5:41 PM, Quincey Morris <email@hidden<mailto:email@hidden>> wrote:
On Dec 24, 2015, at 13:22 , Peters, Brandon <email@hidden<mailto: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