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) . 回答1: You can design your template in a clever way: template < typename T,