You can do something like this:
Cont<int, 6> cnt; // ^ as long as this is of type T (in this case int) // def_val will be of type int and have a value of 6
Template parameters do not have to be types.
This only works when T is an integral type ( int , unsigned , long , char , etc., but not float , std::string , const char* , etc.), Riga mentioned in her comment.
user142019
source share