What does the template <> mean (without any class T in <>)?

I am reading some source code in stl_construct.h, In most cases it has sth in <> and I see some lines with " template<> ...". what is it?

+5
source share
3 answers

This will mean that the following is a template specialization .

+10
source

Guess I completely misunderstood Q and answered what I was not asked.
Therefore, I answer question Q:

This is an Explicit Specialization with an empty list of template arguments.

, . . , . , . .

template<> , .

:

  • -
  • -
+2

This is a template specification where all template parameters are fully specified and there are <>no parameters left.

For instance:

template<class A, class B>   // base template
struct Something
{ 
    // do something here
};

template<class A>            // specialize for B = int
struct Something<A, int>
{ 
    // do something different here
};

template<>                   // specialize both parameters
struct Something<double, int>
{ 
    // do something here too
};
0
source

All Articles