Accessing the "tail" of a parameter pack

I may be missing something obvious, but I haven’t been able to make the following code work:




struct Foo<each T> {
  
  let values: (repeat each T)
  
}

struct Bar<each U> {
  
  let foo: Foo<Void, repeat each U>
  
  func callBar() {
    /// Not sure how to call either of these
    bar1(repeat each foo.values.1) // ERROR: Could not infer pack element #1 from context
    bar2(repeat each foo.values) // ERROR: Cannot pass value pack expansion to non-pack parameter of type 'Void'
  }
  
  func bar1(_ values: repeat each U) {
    
  }
  
  
  func bar2(_ void: Void, _ values: repeat each U) {
    
  }
  
  
}

Any suggestions on how to make something like this work?

1 Like
1 Like

Are you blocked from just explicitly breaking apart the head and tail in Foo?

struct Foo<T, each U> {
  
  let head: T
  let tail: (repeat each U)
}

struct Bar<each U> {
  
  let foo: Foo<Never, repeat each U>
  
  func callBar() {
    bar(repeat each foo.tail)
  }
  
  func bar(_ values: repeat each U) {
    
  }
}

Yeah, I’ve found some workarounds, but they just make the code more complex than it would be otherwise.