#include template struct Pack { static constexpr std::size_t size = sizeof...(Ts); }; template struct Contains; template struct Contains { static constexpr bool value = false; }; template struct Contains { static constexpr bool value = true; }; template struct Contains { static constexpr bool value = Contains::value; }; template struct Make_Unique; template struct Make_Unique, T, Ts...> { private: using result = std::conditional_t< Contains::value, Pack, Pack >; public: using type = typename Make_Unique::type; }; template struct Make_Unique> { using type = Pack; }; template struct Count_Unique { private: using result = typename Make_Unique, Ts...>::type; public: static constexpr std::size_t value = result::size; }; int main() { static_assert( Count_Unique<>::value == 0 ); static_assert( Count_Unique::value == 1 ); static_assert( Count_Unique::value == 3 ); static_assert( Count_Unique::value == 2 ); static_assert( Count_Unique::value == 2 ); }