私は持っています
auto now = std::chrono::high_resolution_clock::now();
そして、ある時点で一般的な型を使用して関数に渡したいと思います。使用する時計の解像度や種類を指定したくありません。
使ってみました
void my_function(std::chrono::time_point time_point);
しかし、成功しませんでした。どうやらstd::chrono::time_pointはタイプではないので。
はstd::chrono::time_point
テンプレート化されたクラスであり、少なくともclock
テンプレートパラメータが必要です。
次のように、明示的に時計を設定します
void my_function(std::chrono::time_point<std::chrono::high_resolution_clock> time_point);
または、関数自体をテンプレートにすることもできます。
template<typename Clock>
void my_function(std::chrono::time_point<Clock> time_point);
最後のケースでは、関数を呼び出すときに実際にテンプレートパラメータを指定する必要はなく、コンパイラがそれを判断します。
my_function(now);