Is it possible to write a type trait whose value is true for all common STL structures (e.g., vector
, set
, map
, ...)?
To get started, I'd like to write a type trait that is true for a vector
and false otherwise. I tried this, but it doesn't compile:
template<class T, typename Enable = void>
struct is_vector {
static bool const value = false;
};
template<class T, class U>
struct is_vector<T, typename boost::enable_if<boost::is_same<T, std::vector<U> > >::type> {
static bool const value = true;
};
The error message is template parameters not used in partial specialization: U
.