• 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: "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


  • Follow-Ups:
    • Re: Swift Generics Error When Enforcing Protocol Conformance...
      • From: Quincey Morris <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>)
 >Re: Swift Generics Error When Enforcing Protocol Conformance... (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Swift Generics Error When Enforcing Protocol Conformance...
  • Next by Date: Re: Hurdles in converting to Swift
  • 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