- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我无法理解为什么标准首先定义模板实例化为模板如下N3797::14.7/4 [temp.spec]
:
The act of instantiating a function, a class, a member of a class template or a member template is referred to as template instantiation.
但是它在任何地方都使用特化的实例化,例如下面的 N3797::14.7/4 [temp.spec]
:
An instantiated template specialization can be either implicitly instantiated (14.7.1) for a given argument list or be explicitly instantiated (14.7.2).
我不明白。模板本身是不同于模板特化的概念,它可以是显式特化
或部分特化
。例如 N3797::14.5.5/1 [temp.class.spec]
:
The primary template shall be declared before any specializations of that template.
我的问题是,为什么标准首先声明了模板的 instatiation
概念,然后又将该概念应用于模板特化?
此外,N3797::14.7/4 [temp.spec]
定义了如下特化概念:
A specialization is a class, function, or class member that is either instantiated or explicitly specialized (14.7.3).
所以,偏特化不是特化,对吗?我完全被这些概念搞糊涂了。你不能澄清一下吗?
最佳答案
这是一个类似的问题here .而现在,我试着再次回答这个问题。
模板是一种无限类型,所以我们不能实例化模板,我们只能实例化模板特化。
隐式实例化,当前编译单元需要使用模板代码,编译器自动实例化模板特化。
显式实例化,我们手动输入代码使编译器实例化模板特化。
关于c++ - 特化的隐式实例化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28734686/
我是一名优秀的程序员,十分优秀!