Зміст курсу
C++ Templates
C++ Templates
2. Templates Usage
3. Template Specialization
4. Class
Typename Naming Conventions
Just like the variable you can name templates parameters anything as you want and just like the common variables naming there are some bad and good practice.
good_naming_example
bad_naming_example
template<typename T> void myTemplate() { // Function implementation }
You might think why the second one is considered a bad example as it is clearer and easier to understand. The answer is simple. Using T
as a placeholder for template type parameters is a convention. It stands for Type and is commonly used to indicate that the template parameter represents a type.
Note
Sometimes when there are multiple parameters and the use is not immediately obvious then you can use descriptive names prefixed with T
Все було зрозуміло?
Секція 1. Розділ 5