2

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.

raspiede
  • 179
  • 1
  • 1
  • 11

1 Answers1

4

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
Angew is no longer proud of SO
  • 167,307
  • 17
  • 350
  • 455
  • Okay, thanks! I will try to figure it out...maybe I forgot including some other headers. I never heard of partial specialisation of a struct, but you are right it must be that way – raspiede Sep 05 '13 at 14:30