I want to check that a type T is also part of a parameter pack Ts. There are solutions that do that in C++14, but I'm wandering if this can be simplified in C++17. If T is not found in Tsthe compiler should stop (static_assertion should fail).
template<typename... Ts>
class A
{
template<typename T>
void action() {
// check that T is also in Ts (static_assertion)
}
}
I hear fold-expressions are the new hotness:
static_assert((std::is_same_v<T, Ts> || ...));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With