全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Template instantiation?

Definition 4.4 University Computer Science — Year 2 · 第 4 章 — Templates and Generic Programming

Template instantiation is the generation, by the compiler, of a function or a class from a template and a list of template arguments, by substituting the arguments for the parameters. A use such as Vec<int> or larger(3, 7) causes the instantiation; a member function of a class template is instantiated only if it is used.

One template, two translation units, two argument lists. Each unit instantiates what it uses; the linker merges the two copies of Vec<int>::push_back.
One template, two translation units, two argument lists. Each unit instantiates what it uses; the linker merges the two copies of Vec<int>::push_back.
在原文中阅读 →