Check a parameter pack for all of type T
Your syntax is just off a bit, you don't need two separate template declarations, that syntax is for defining member templates out-of-class:
template<typename Target, typename... Ts>
using areT = and_<std::is_same<Ts,Target>...>;
static_assert(areT<int,int,int,int>::value,"wat");
static_assert(!areT<int,float,int,int>::value,"wat");
Demo
C++17 defines a version of and_
called std::conjunction
defined in the <type_traits>
header from the standard library.
template <typename T, typename ...Ts>
using areT = std::conjunction<std::is_same<T,Ts>...>;
static_assert(areT<int,int,int,int>::value);
There is also a version of std::conjunction
called std::conjunction_v
which provides the value
data member of its instantiation. So too you could define an areT_v
C++14 variable template yourself:
template <typename T, typename ...Ts>
inline constexpr bool areT_v = std::conjunction_v<std::is_same<T,Ts>...>;
static_assert( areT_v<int,int,int,int>);
static_assert(!areT_v<int,int,int,char>);