Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

templates

I'm reading some source code in stl_construct.h, In most cases it has sth in the <> and i see some lines with only "template<> ...". what's this?

like image 774
hongbin Avatar asked May 21 '12 09:05

hongbin


People also ask

What does template <> mean in C++?

Templates are a feature of the C++ programming language that allows functions and classes to operate with generic types. This allows a function or class to work on many different data types without being rewritten for each one.

What is the difference between template typename T and template T?

There is no difference. typename and class are interchangeable in the declaration of a type template parameter.

What does this template function indicate template class T?

What does this template function indicates? Explanation: As the return type of function is template T, therefore, the function is returning a general type. Now as the function is taking a template T as its argument which is a general type, therefore, it is accepting a single general type argument.

What do you mean by class template?

An individual class defines how a group of objects can be constructed, while a class template defines how a group of classes can be generated. Note the distinction between the terms class template and template class: Class template. is a template used to generate template classes.


1 Answers

This would mean that what follows is a template specialization.

like image 96
dirkgently Avatar answered Oct 06 '22 00:10

dirkgently