函数_Checked_base:
// _Checked_base函数,两个版本const和非const
template<class _Iter> inline
typename _Checked_iterator_base_helper<_Iter>::_Checked_iterator_base_type
_Checked_base(_Iter &_It)
{
typename _Checked_iterator_base_helper<_Iter>::_Checked_iterator_base_type_tag _Base_tag;
return _Checked_base(_It, _Base_tag);
}
template<class _Iter> inline
typename _Checked_iterator_base_helper<_Iter>::_Checked_iterator_base_type
_Checked_base(const _Iter &_It)
{
typename _Checked_iterator_base_helper<_Iter>::_Checked_iterator_base_type_tag _Base_tag;
return _Checked_base(_It, _Base_tag);
}
_Checked_iterator_base_helper模板
// 推导流程:__is_base_of==>helper2==>helper1
template <class _Iter>
class _Checked_iterator_base_helper
{
public:
typedef _Checked_iterator_base_helper2<_Iter, __is_base_of(_Iterator_base, _Iter)> _Base_helper2;
typedef _Checked_iterator_base_helper1<_Iter, typename _Base_helper2::_Checked_iterator_base_type > _Base_helper1;
typedef typename _Base_helper1::_Base_type_tag _Checked_iterator_base_type_tag;
typedef typename _Base_helper1::_Checked_iterator_base_type _Checked_iterator_base_type;
};
_Checked_iterator_base_helper2模板
// 模板_Checked_iterator_base_helper2
template <class _Iter, bool _Inherits_from_iterator_base>
class _Checked_iterator_base_helper2
{
public:
typedef _Unchanged_checked_iterator_base_type_tag _Checked_iterator_base_type;
};
template <class _Iter>
class _Checked_iterator_base_helper2<_Iter, true>
{
public:
typedef typename _Iter::_Checked_iterator_base_type _Checked_iterator_base_type;
};
_Checked_iterator_base_helper1模板
// 模板 _Checked_iterator_base_helper1
template <class _Iter, class _Base_type>
class _Checked_iterator_base_helper1
{
public:
typedef _Different_checked_iterator_base_type_tag _Base_type_tag;
typedef _Base_type _Checked_iterator_base_type;
};
template <class _Iter>
class _Checked_iterator_base_helper1<_Iter, _Unchanged_checked_iterator_base_type_tag>
{
public:
typedef _Unchanged_checked_iterator_base_type_tag _Base_type_tag;
typedef _Iter _Checked_iterator_base_type;
};
_Checked_iterator_base_type_tag可能的取值:
struct _Unchanged_checked_iterator_base_type_tag
{
};
struct _Different_checked_iterator_base_type_tag
{
};