vendredi 17 avril 2015

Explicitly use defaults for some parameters in template class instantiation

A template class can have multiple parameters that all have defaults.



template<typename UnderlyingT0 = int, typename UnderlyingtT1 = long, typename StringT = std::string>
struct options;


Instatiating the class with just default parameters is easy:



options<> my_default_options;


But what if I want to change a subset of parameters?



options<int, int, std::wstring> wstring_options;


It is not obvious that int is a default for the first parameter while for the second it isn't. Is there something like



options<default, int, std::wstring> wstring_options;


in C++?


Aucun commentaire:

Enregistrer un commentaire