angle brackets after struct

1.8k views Asked by At

I have problems with understanding the following line in a C++ Code:

template<class Variable> struct strVar< :: namespaceName::strVar2_<Variable>> : public trueType {};

What does the angle brackets after struct strVar mean? I never heard of this style before.

The line does not compile with my compiler, but it comes from a running software, so it must be right in some sense.

1

There are 1 answers

1
Angew is no longer proud of SO On BEST ANSWER

The code defines a partial specialisation of class template strVar. Somewhere earlier in the code, there must be at least a declaration of the primary template:

template <class T> struct strVar;

Then, the code you posted provides a definition which will be used for strVar whenever its template argument (corresponding to T) happens to be a specialisation of the class template ::namespaceName::strVar2_.

Example:

strVar<int> x;  // will use primary template
strVar<::namespaceName::strVar2_<int>> x;  // will use the specialisation