0

What i need to do is have a function that takes in a list of arbitrary arguments, using the parameter pack operator, and put that whole list into a queue from which I can later pass those args into another function.

This kind of thing:

void x(...args) {
  queue.push(args...):
}

void y() {
  z(queue.pop());
}

How would I declare this queue and how would I do this in general?

  • What is `queue`? – walnut Feb 02 '20 at 21:17
  • queue is an std::queue, not sure what type i have to declare it with – Leo Riesenbach Feb 02 '20 at 21:20
  • And how is `z` defined? – walnut Feb 02 '20 at 21:25
  • it's another function, taking the same args as were passed into x – Leo Riesenbach Feb 02 '20 at 21:32
  • Then you can use `std::queue>` where `...` is the list of argument types for `z`. You can call `z` with the tuple using `std::apply`. But of course you can then only call `x` with the correct set of argument types, whether it is a template or not. – walnut Feb 02 '20 at 21:34
  • Arbitrary arguments with different types? Into the same queue? There is a way like boost::variant. But in general, this is impossible 'cause an argument may not have a proper constructor to store it somewhere else. You should reduce the scope of the question. – Askold Ilvento Feb 02 '20 at 21:39

0 Answers0