Here's an example usage of a parameter pack:
template <typename... T>
bool foo(A x) {
return (baz<T>(x) || ...);
}
I'd like to do something similar, but with pairs of types. Here's an example (note that this isn't real C++ syntax):
template <typename... [T, Z]>
bool foo(A x) {
return (baz<T, Z>(x) || ...);
}
How is it possible to do something like this (i.e, a parameter pack over pairs)?
Here is a larger fleshed example of what I intend to do:
// caller
foo<{A1, A2}, {B1, B2}, C, D>(x);
// callee should expand to...
int foo(void* x) {
if (baz<A1,A2>(x) || baz<B1, B2>(x)) return 0;
if (bar<C>(x) || bar<D>(x)) return 1;
return 2
}
std::pair
or just informal term pair. For the latter you'll just have to introduce another parameter pack afterT
. Liketemplate <typename... T, typename... Z>
Note that though the latter syntax is not allowed in c++.std::pair
? If yes, you could use it to show the calling code. Just to give an idea of how you intend on using it. Just like you gave an example pseudocode for the modifiedfoo
.