Template Argument Deduction for Class Templates

This lesson will make you learn how to skip make_Type functions to construct a template object.

Do you often use make_Type functions to construct a templated object (like std::make_pair)? With C++17 you can forget about (most of) them and just use a regular constructor.

C++17 has filled a gap in the deduction rules for templates. Now template deduction can occur for standard class templates and not just for functions. That also means that a lot of your code that uses make_Type functions can now be removed.

For instance, to create an std::pair object, it was usually more comfortable to write:

auto myPair = std::make_pair(42, "hello world");

Rather than:

std::pair<int, std::string> myPair(42, "hello world");

Get hands-on with 1200+ tech skills courses.