The following code example is taken from the book
C++17 - The Complete Guide
by Nicolai M. Josuttis,
Leanpub, 2017
The code is licensed under a
Creative Commons Attribution 4.0 International License.
#include <type_traits>
// check whether passed types are homogeneous:
template<typename T1, typename... TN>
struct IsHomogeneous {
static constexpr bool value = (std::is_same_v<T1,TN> && ...);
};
// check whether passed arguments have the same type:
template<typename T1, typename... TN>
constexpr bool isHomogeneous(T1, TN...)
{
return (std::is_same_v<T1,TN> && ...);
}