Use Template Argument Deduction for Simplicity and Clarity
Learn to use template argument deduction for simplicity and clarity.
We'll cover the following
Template argument deduction occurs when the types of the arguments to a template function, or class template constructor (beginning with C++17), are clear enough to be understood by the compiler without the use of template arguments. There are certain rules to this feature, but it's mostly intuitive.
How to do it
In general, template argument deduction happens automatically when we use a template with clearly compatible arguments. Let's consider some examples.
In a function template, argument deduction usually looks something like this:
Get hands-on with 1400+ tech skills courses.