How can one check if two parameter packs are the same, ignoring their internal order?
So far I only have the frame (using std::tuple
), but no functionality.
#include <tuple>
#include <type_traits>
template <typename, typename>
struct type_set_eq : std::false_type
{
};
template <typename ... Types1, typename ... Types2>
struct type_set_eq<std::tuple<Types1...>, std::tuple<Types2...>>
: std::true_type
{
// Should only be true_type if the sets of types are equal
};
int main() {
using t1 = std::tuple<int, double>;
using t2 = std::tuple<double, int>;
using t3 = std::tuple<int, double, char>;
static_assert(type_set_eq<t1, t1>::value, "err");
static_assert(type_set_eq<t1, t2>::value, "err");
static_assert(!type_set_eq<t1, t3>::value, "err");
}
Every type is not allowed to occur more than once in a set.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…