使用“自动”类型推导-如何找出编译器推导的类型?
我如何找出使用auto关键字时编译器推断出的类型? 示例1:更简单 auto tickTime = 0.001; 是推导为afloat还是adouble? 示例2:更复杂(和我目前的头痛): typedef std::ratio<1, 1> sec; std::chrono::duration<double, sec > timePerTick2{0.001}; auto nextTickTime = std::chrono::high_resolution_clock::now() + timePerTick2; 什么类型的nextTickTime? 我遇到的问题是尝试发送nextTickTime给时std::cout。我收到以下错误: ./main.cpp: In function ‘int main(int, char**)’: ./main.cpp:143:16: error: cannot bind ‘std::basic_ostream<char>’ lvalue to ‘std::basic_ostream<char>&&’ std::cout << std::setprecision(12) << nextTickTime << std::endl; // time in seconds ^ …