C ++ 11自动编译时间或运行时? [英] C++ 11 auto compile time or runtime?

查看:58
本文介绍了C ++ 11自动编译时间或运行时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

auto a = 10;

当编译器知道 a 是<$ c时$ c> int ,是在编译时还是在运行时?如果它在运行时推断出类型,是否会影响性能?

When compiler knows a is int, at compile time or at run-time? If it deduce type at run-time, will it not affect performance?

谢谢

推荐答案

编译时间。在C ++中,运行时类型信息在编译过程中被剥离(没有RTTI或虚拟继承)。实际上,不可能在运行时检查基本类型。

Compile time. In C++, runtime type information is stripped during compilation(without RTTI or virtual inheritance). It is not possible, in fact, to inspect the primitive type at runtime.

这篇关于C ++ 11自动编译时间或运行时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆