Using 'auto' type deduction - how to find out what type the compiler deduced?

前端 未结 11 1080
伪装坚强ぢ
伪装坚强ぢ 2021-01-30 07:54

How can I find out what type the compiler deduced when using the auto keyword?

Example 1: Simpler

auto tickTime = 0.001;

W

11条回答
  •  无人及你
    2021-01-30 08:38

    As a side note, to effectively print out the value in nextTickTime you should explicitly convert to a suitable std::chrono::duration and output the result of duration::count.

    using std::chrono::duration_cast;
    using std::chrono::seconds;
    
    auto baseTime = ...;
    std::cout << std::setprecision(12) << duration_cast(nextTickTime - baseTime).count()
        << std::endl; // time in seconds
    

提交回复
热议问题