jeudi 5 mars 2015

How can I use std::chrono::duration as a template parameter?

I have a template class, something like:



template < typename T, size_t Seconds > class MyClass {}


Now, I would like to change Seconds to be a duration, so the class can be parametrized with std::chrono::duration. For example, I'd like to be able to do this:



MyClass < std::string, std::chrono::seconds(30) > object;


Also, in the template, I'd like to specify a default value, something like std::chrono::seconds(30).


Aucun commentaire:

Enregistrer un commentaire