sharplet
(Adam Sharp)
1
Say I define a type like this:
struct P<each T> {
init(_ t: repeat (each T).Type) {}
}
…and a function that accepts it:
func foo<each T>(p: P<each T>) {
// do something with `p`
}
Is there any way to spell the static type of an empty parameter pack? For example, if I write:
let a = P(Int.self) // P<Int>
let b = P(String.self, Double.self) // P<String, Double>
let c = P() // P<> ????
Can I write an explicit type annotation for c? What is its type? Is this something that can't be expressed until the Explicit type pack syntax future direction is explored?
allevato
(Tony Allevato)
2
Writing let c: P<> = P() in the last case works for me in Swift 5.10. Are you running into issues with that?
1 Like
AlexanderM
(Alexander Momchilov)
3
Keep in mind there's still a bug where in expression context you have to write P< > instead of P<>, eg if you need the metatype value P< >.self.
10 Likes
sharplet
(Adam Sharp)
5
P< > worked for me, thank you!
1 Like