First, create a class packto hold several types:
template <typename... Ts> struct pack { };
Then write a function to check if the two packages match:
template <typename P0, typename P1>
struct are_packs_same;
template <typename... T0s, typename... T1s>
struct are_packs_same<pack<T0s...>, pack<T1s...>>
: std::bool_constant<(sizeof...(T0s) == sizeof...(T1s))
&& (std::is_same_v<T0s, T1s> && ...)>
{
};
Finally, you need a function to combine the two packages:
template <typename P0, typename P1>
struct concat_packs;
template <typename... T0s, typename... T1s>
struct concat_packs<pack<T0s...>, pack<T1s...>>
{
using type = pack<T0s..., T1s...>;
};
Usage example:
int main()
{
using p0 = pack<int, char>;
using p1 = pack<float>;
using p2 = pack<int, char, float>;
static_assert(are_packs_same<
typename concat_packs<p0, p1>::type,
p2>::value);
}
live wandbox