Как проверить, является ли один пакет параметров (интерпретируемый как набор) подмножеством другого?
Пока у меня есть только фрейм (с использованием std:: tuple), но нет функциональности.
#include <tuple>
#include <type_traits>
template <typename, typename>
struct is_subset_of : std::false_type
{
};
template <typename ... Types1, typename ... Types2>
struct is_subset_of<std::tuple<Types1...>, std::tuple<Types2...>>
: std::true_type
{
// Should only be true_type if Types1 is a subset of Types2
};
int main() {
using t1 = std::tuple<int, double>;
using t2 = std::tuple<double, int>;
using t3 = std::tuple<int, double, char>;
static_assert(is_subset_of<t1, t1>::value, "err");
static_assert(is_subset_of<t1, t2>::value, "err");
static_assert(is_subset_of<t2, t1>::value, "err");
static_assert(is_subset_of<t2, t3>::value, "err");
static_assert(!is_subset_of<t3, t2>::value, "err");
}
Каждому типу не разрешается встречаться более одного раза в наборе.
Было бы неплохо, если бы решение работало с С++ 11.