
记住,Foo< T>如果Foo是类模板,则引用一个类.如果类的typedef成员在程序中的某一点定义为一种类型,而另一种类型定义为另一种类型,则必然会出现错误.以下是与此相关的各种标准报价
A specialization for a function template,a member function template,or of a member function or static data member of a class template may have multiple points of instantiations within a translation unit. A specialization for a class template has at most one point of instantiation within a translation unit. A specialization for any template may have points of instantiation in multiple translation units. If two different points of instantiation give a template specialization different meanings according to the one deFinition rule (3.2),the program is ill-formed,no diagnostic required.
If a template,a member template or the member of a class template is explicitly specialized then that specialization shall be declared before the first use of that specialization that would cause an implicit instantiation to take place,in every translation unit in which such a use occurs; no diagnostic is required.
(跳过各种“噪音”)
总结[..VarIoUs entitIEs that may be defined multiple in the whole program..]. Given such an entity named D defined in more than one translation unit,then
each deFinition of D shall consist of the same sequence of tokens; in each deFinition of D,corresponding names,looked up according to 3.4,shall refer to an entity defined within the deFinition of D,or shall refer to the same entity,after overload resolution (13.3) and after matching of partial template specialization (14.8.3)… If D is a template,and is defined in more than one translation unit,then the last four requirements from the List above shall apply to names from the template’s enclosing scope used in the template deFinition (14.6.3),and also to dependent names at the point of instantiation (14.6.2). If the deFinitions of D satisfy all these requirements,then the program shall behave as if there were a single deFinition of D. If the deFinitions of D do not satisfy these requirements,then the behavior is undefined.
以上是内存溢出为你收集整理的是否可以在C中编写不纯的模板?全部内容,希望文章能够帮你解决是否可以在C中编写不纯的模板?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)