C ++: what does the <class> template mean?
I am trying to understand some C ++ code. I am an experienced Java programmer trying to learn C ++. I have already read some comprehensive articles on templates, but none of them answered me what the following template specification means.
template< template<template<class> class, class> class VisualOdometryTT, template<class> class NodeBuilderTT, class PoseGraphT> class VORosInterface{ ... }; The part I donβt understand is template<class> , where I think the specification of some kind is missing. But the code compiles without problems.
Using NodeBuilderTT as an example because it is simpler:
NodeBuilderTT is a template parameter, which itself is a template with one parameter - call to Z
You could formally name Z , and the code would compile in exactly the same way:
template<class Z> class NodeBuilderTT So far, this is pretty similar to declaring function arguments:
void foo(int x) {} // works void foo(int) {} // also works However, with functions that you would normally use the name x inside the function body. With templates, you cannot use Z in the definition of VORosInterface , so there is absolutely no point in its name, and itβs idiomatic to write
template<class> class NodeBuilderTT I thank K-ballo for helping to set the record right here.