References
- https://en.cppreference.com/w/cpp/language/templates
- We will be studing about only function templates and abbreviated function template using keyword 'auto' which is also explained in above link(auto is just c++20 feature).
Main points
- Templates have been introduced in 1991.
-
we use templates like:
template <typename/class T> //we can use the keywords typename or class T function_name(T parameter_names) // scope of T is within the function only. { } -
we can use template using keyword
autowhich is just c++20 feature only.(compile with -std = c++20 )auto function_name(auto parameter_names) { // function body; note that 'auto' will deduce the type for us. } -
InstantiationIt is process of making codes by compiler, In previous lecture 1 we saw that the compiler was make codes for us, and that is known as Instantiation.