mardi 3 décembre 2019

Missing type specifier and one more question

I'm trying to make a short chrono declarations

#pragma once
#include <chrono>

    class Foo//: public SINGLETON<Foo>
    {
    public:
        using point = std::chrono::steady_clock::time_point;
        using secs  = std::chrono::duration_cast<std::chrono::seconds>;
        using now   = std::chrono::steady_clock::now();
    };

So that's the whole code. First issue, this code don't want to compile. First compile error:

 error: 'duration_cast<std::chrono::seconds>' in namespace 'std::chrono' does not name a type
  using time_secs  = std::chrono::duration_cast<std::chrono::seconds>;

Second error;

error: expected type-specifier
  using time_now   = std::chrono::steady_clock::now();

Now a question about usage of those, i want to use them like this;

time_point  GetElapsedtTime(){return time_secs(time_now - Another_time_point ); }

Can i use them like above ?

I'm trying to set time point intro a variable, then to countdown the elapsed time until it reaches 1hour for example, then when 1 hour elapses.. do something.

Aucun commentaire:

Enregistrer un commentaire