关键词随便记
迭代器用到“相应型别”
什么是相应型别?迭代器所指之物的型别便是其一
需求:声明一个变量,以迭代器所指对象的型别为型别
解决:function template的参数推导机制
traits编程技法
template<class I>
struct iterator_traits{
typedef typename I::value_type value_type;
}
template<class I>
typename iterator_traits<I>::value_type func(I ite){
return *ite;
}
想到为什么后面没有采用I::value_type了,因为不存在
//int*不是一种class type,亦可以通过traits取其value_type
template<class T>
struct iterator_traits<T*>{
typedef T value_type;
}
template<class T>
struct iterator_traits<const T*>{
typedef T value_type;
}


不懂的点
RTTI性质的typeid()
网友评论