在编译时,类模板会发生什么
At compilation what happen with class template
当类模板实例化时会发生什么。 即我hv一个类模板,我已经为int创建了类,为float创建了类,那么在编译时会发生什么(编译器将为int和float创建2个单独的类(或不? 例如:
template <typename T>
class A
{
public:
void foo(T t)
{
//...
};
};
int main()
{
A<int> a;
A<float> b;
}
是的,编译器将即时创建两个新类 - 一个用于 int,一个用于浮点数。
相关文章:
- 是什么原因导致它无法编译?它是声明签名还是在函数本身的实现中
- C++如果必须在编译时确定大小,std::array 有什么意义?
- Red Hat:使用<atomic>编译很好,但链接器找不到__atomic_store_16;什么库?
- 代码编译但不起作用!cmd窗口只是理想和理想,但什么也没发生
- C++中的编译时函数是什么?
- 编译以下重载<<需要什么enable_if或其他提示?
- 使用 MSVC 编译时,msdpb* 文件的正确用法是什么?
- 关于这个在 Linux 上使用 gcc 编译的程序中的 vtable,nm 告诉我什么?
- 当我在支持 avx2 的机器上编译并在另一台仅支持 avx 的机器上运行二进制文件时会发生什么?
- Boost FFT示例-编译时出错,这段代码在做什么
- 在编译时,类模板会发生什么
- 在Windows Server 2012上运行VS2019编译的应用程序需要什么?
- Arduino IDE中自定义库类的.h文件编译错误的原因是什么
- VS2015 / 2017中的TRACE宏无法编译 - 我需要包含什么?
- 有什么需要,局部静态变量在编译时分配内存?
- 如果我在库中和应用程序中编译了相同的CPP文件,会发生什么
- C++:什么时候需要重新编译?
- GCC ARM 交叉编译,像未定义的引用"__cxa_end_catch@CXXABI_1.3"这样的错误表示什么?
- gcc 什么时候编译未使用的模板代码?
- 什么编译机制铸造新运算符的结果