lundi 23 septembre 2019

C++ 11 std::chrono::duration_cast<> text of units being used

I am writing a templated timer class where one of the template typenames is the resolution being used, for example std::chrono::milliseconds.

I would like to be able to output the result of the measurement with the proper units based on the resolution that was selected:

std::cout std::chrono::duration_cast<Resolution>(Clock::now() - mStart).count(); 

I would like to complete this statement with the units; is there a C++ 11 function that can give me the text of the "Resolution" being used, i.e. the string "milliseconds".

Aucun commentaire:

Enregistrer un commentaire