I am reading a C++ code and I came across the use of the keyword typename
in the middle of the class
definition.
Here is the class definition and the keyword is used in the protected section.
template<typename CVertex, typename CEdge, typename CFace, typename CHalfEdge>
class CBoundary
{
typedef CLoop<CVertex,CEdge, CFace, CHalfEdge> TLoop;
public:
CBoundary( CBaseMesh<CVertex,CEdge,CFace,CHalfEdge> * pMesh );
~CBoundary();
std::vector<TLoop*> & loops()
{
return m_loops;
}
protected:
CBaseMesh<CVertex,CEdge,CFace,CHalfEdge> * m_pMesh;
typename std::vector<TLoop*> m_loops;
void _bubble_sort( std::vector<CLoop<CVertex, CEdge, CFace, CHalfEdge>*> & loops);
};
Is this the same as the typedef
keyword? There seem to be a couple of related questions like
so but I did not really understand the explanation there.
In fact since typename is one of the SO tags I will list the explanation which I did not understand
typename is a keyword in the C++ programming language with two meanings. First, it can be used to declare type arguments inside a template declaration, and is synonymous with "class." Second, it can be used to indicate that a dependent name refers to a type. A common cause of errors in C++ code is the omission of an essential typename.
It looks like I am dealing with the second use here. But I don't understand what "dependent name" means here.
I am just a beginner in template metaprogramming with C++ so a simple explanation of the use in the class above would be very helpful.