2

I want to get codes like this:

struct Order_t {
   time_point<system_clock, microseconds>  order_time;
   // some other fileds
};

template<typename Dura>
void onTimer( time_point<system_clock, Dura> tp_now ) {
    auto tp0 =  time_point_cast<Order_t::order_time::duration>( tp_now );

    // some other codes...
};

But these can not be compiled. In fact I need to declare a variable that has same type as Order_t::order_time, but there is no var of the type here.

Leon
  • 1,489
  • 1
  • 12
  • 31

1 Answers1

3

To get a nested type (::duration) you need a type, not a variable. Hence, it should be

auto tp0 = time_point_cast<decltype(Order_t::order_time)::duration>(tp_now);
Evg
  • 25,259
  • 5
  • 41
  • 83