Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 662 Bytes

class-vs-typename.md

File metadata and controls

18 lines (12 loc) · 662 Bytes

class-vs-typename

for template parameters, class and typename are more or less equivalent:

template void foo(){} <==> template void foo(){}

However, for template template parameters you must use class:

template<typename T, typename Alloc, template<typename,typename> class Container>

void foo(Container<T, Alloc>) {}

Using class hints that the type will be of user-defined class type on which certain operations can be performed, i.e. for which you can call methods. So use class where you expect a user-defined class-type and use typename where also primitive types such as int or char are allowed, or for functions (predicates).