是否可以写一个类型的特点,它的值是所有常见的STL结构真(例如vector,set,map,...)?
首先,我想编写一个类型特征,对于a vector和false 都是如此.我试过这个,但它没有编译:
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;
};
Run Code Online (Sandbox Code Playgroud)
错误消息是template parameters not used in partial specialization: U.