3. Template type deduction when template parameter is neither a pointer nor a reference
Motivation for writing, this post is, In the past I interviewed many candidates for C++ and this was one of the topics where I found candidates getting confused with templates type deduction when template parameter is neither a pointer nor a reference. What is a template? As a quick short introduction, In General template, is a ‘pattern’ that is used to create specific instances. Moving from generics to specifics. This means you can generate specific instances by repeating the same pattern again and again for different types of inputs provided. For example, below we have the same presentation template used for C++ and Python-specific presentations for different audiences. C++ Templates In C++ a template is a class or a function that we parameterize with a set of types or values. We use templates to represent concepts that are best understood as something very general from which we can generate specific types and functions by specifying arguments, such as the element type double.