How can I find out what type the compiler deduced when using the auto
keyword?
Example 1: Simpler
auto tickTime = 0.001;
W
typeid can be used to get the type of variable most of the time. It is compiler dependent and I've seen it give strange results. g++ has RTTI on by default, not sure on the Windows side.
#include
#include
#include
#include
#include
typedef std::ratio<1, 1> sec;
int main()
{
auto tickTime = .001;
std::chrono::duration timePerTick2{0.001};
auto nextTickTime = std::chrono::high_resolution_clock::now() + timePerTick2;
std::cout << typeid(tickTime).name() << std::endl;
std::cout << typeid(nextTickTime).name() << std::endl;
return 0;
}
./a.out | c++filt
double
std::__1::chrono::time_point > >