When I was reading stdc++ code, I felt confused about the below lines. Here is a piece of code from stl_list.h.
template <class _Tp, class _Alloc>
class _List_base
: public _List_alloc_base<_Tp, _Alloc,
_Alloc_traits<_Tp, _Alloc>::_S_instanceless>
{
public:
typedef _List_alloc_base<_Tp, _Alloc,
_Alloc_traits<_Tp, _Alloc>::_S_instanceless>
_Base; /* Is _Base a kind of type?*/
typedef typename _Base::allocator_type allocator_type;
_List_base(const allocator_type& __a) : _Base(__a) {/* How can a type be initiated like this?*/
_M_node = _M_get_node();
_M_node->_M_next = _M_node;
_M_node->_M_prev = _M_node;
}
}
What confused me is _Base
. This name was defined by typedef
. I think it is as kind of type. But _Base
appears in initialization list.
How can I understand this usage? Or you please paste some useful links for me.