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

前端 未结 11 1069
伪装坚强ぢ
伪装坚强ぢ 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:53

    A lo-fi trick that doesn't require any prior helper definitions is:

    typename decltype(nextTickTime)::_
    

    The compiler will complain that _ isn't a member of whatever type nextTickTime is.

提交回复
热议问题