تمپلت با پارامتر type :
template<typename T>
struct Container {
T t;
};
// pass type "long" as argument.
Container<long> test;
تمپلت با پارامتر integer:
template<unsigned int S>
struct Vector {
unsigned char bytes[S];
};
// pass 3 as argument.
Vector<3> test;
تمپلت با پارامتر اشاره گر (اشاره گر به تابع):
template<void (*F)()>
struct FunctionWrapper {
static void call_it() { F(); }
};
// pass address of function do_it as argument.
void do_it() { }
FunctionWrapper<&do_it> test;
تمپلت با پارامتر رفرنس( پاس دادن integer) :
template<int &A>
struct SillyExample {
static void do_it() { A = 10; }
};
// pass flag as argument
int flag;
SillyExample<flag> test;