In C++ what does template mean?

It is a template specialization. The typical case would be partial specialization:

#include <iostream>

template<class T1, class T2>
struct foo
{
  void doStuff() { std::cout << "generic foo "; }
};

template<class T1>
struct foo<T1, int>
{
 void doStuff() { std::cout << "specific foo with T2=int"; }
};

As you can see, the specialization removes one element from the template parameters and explicitly states a type instead of the removed one. That means if there is only one template type, the <> just become empty:

template<class T1>
struct bar
{
  void doStuff() { std::cout << "generic bar"; }
};

template<>
struct bar<int>
{
 void doStuff() { std::cout << "specific bar with T1=int"; }
};

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)