Is it possible to spell the type of an empty parameter pack?

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?

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

Related: What's the syntax to create a parameter packed generic type with zero type parameters?

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.


P< > worked for me, thank you!

1 Like