Tutorial by Examples

Prior to C++17, template deduction cannot deduce the class type for you in a constructor. It must be explicitly specified. Sometimes, however, these types can be very cumbersome or (in the case of lambdas) impossible to name, so we got a proliferation of type factories (like make_pair(), make_tuple(...
Template Generic Syntax template<typename T> void f(ParamType param); f(expr); Case 1: ParamType is a Reference or Pointer, but not a Universal or Forward Reference. In this case type deduction works this way. The compiler ignores the reference part if it exists in expr. The compiler t...
C++11 Type deduction using the auto keyword works almost the same as Template Type Deduction. Below are a few examples: auto x = 27; // (x is neither a pointer nor a reference), x's type is int const auto cx = x; // (cx is neither a pointer nor a reference), cs's type is const int ...

Page 1 of 1