I'm trying to understand some C++ code. I'm an experienced Java programmer trying to learn C++. I've already read some exhaustive articles on templates, but no one of them answered me what does the following template specification mean.
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 some type specification is missing. But the code compiles without problems.
Using NodeBuilderTT
as an example because it's easier:
NodeBuilderTT
is a template parameter that is itself a template having one parameter -- let's call that Z
.
You could have chosen to formally name Z
and the code would compile just the same:
template<class Z> class NodeBuilderTT
So far this is quite similar to declaring function arguments:
void foo(int x) {} // works
void foo(int) {} // also works
However, with the functions you would typically 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 naming it and it is idiomatic to write
template<class> class NodeBuilderTT
My thanks to K-ballo for helping set the record straight here.