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

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

    I like to use idea from Effective Modern C++ which uses non-implemented template; the type is output with compiler error:

     template struct TD;
    

    Now for auto variable var, after its definition add:

     TD td;
    

    And watch error message for your compiler, it will contain type of var.

提交回复
热议问题