How can one check if one parameter pack (interpreted as a set) is a subset of another one?
So far I only have the frame (using std::tuple), but no functionality.
If you can use C++17 features, I highly recommend using Piotr Skotnicki's solution!
I had to implement this functionality a while ago. I am just going to copy-paste the code I came up with at that point.
I am not claiming that this is the best or most elegant way to implement this kind of check! I did not bother thinking about the edge cases too much; you may need to adapt the code to fit your requirements.
To clarify: ContainsTypes checks if Rhs is a subset of Lhs.
template
struct ContainsType;
template
struct ContainsType, U>
{
static const bool VALUE = ContainsType, U>::VALUE;
};
template
struct ContainsType, T>
{
static const bool VALUE = true;
};
template
struct ContainsType, T>
{
static const bool VALUE = false;
};
// -----
template
struct ContainsTypes;
template
struct ContainsTypes>
{
static const bool VALUE = ContainsType::VALUE && ContainsTypes>::VALUE;
};
template
struct ContainsTypes>
{
static const bool VALUE = true;
};