samedi 18 juillet 2015

What is the type of std::chrono::high_resolution_clock::now() in C++11?

I need to declare the following variable in a class:

auto gameStartClock = std::chrono::high_resolution_clock::now();

However, I receive this error message from gcc 5.1.0 (with C++11 enabled) whenever I try to do that:

<file>.hpp:274: error: non-static data member declared 'auto'
auto gameStartClock = std::chrono::high_resolution_clock::now();                                                               ^
non-static data member declared 'auto'

So I guess the error will be gone after I replace auto by the correct type. However, every example I found out there about ::now() uses auto.

What is its type?

Note: I tried std::chrono::time_point with a few templates but got no success. Not sure which are the correct ones.

Aucun commentaire:

Enregistrer un commentaire