码迷,mamicode.com
首页 > 编程语言 > 详细

8.1.2 Template instantiation (Accelerated C++)

时间:2014-08-10 10:18:20      阅读:300      评论:0      收藏:0      [点我收藏+]

标签:os   io   for   art   ar   c++   type   ad   

The C++ standard says nothing about how implementations should manage template i nstantiation, so every implementation handles instantiation in its own particular way. While we cannot say exactly how your compiler will handle instantiation, there are two important points to keep in mind: The first is that for C++ implementations that follow the traditional edit-compile-link model, instantiation often happens not at compile time, but at link time. It is not until the templates are instantiated that the implementation can verify that the template code can be used with the types that were specified. Hence, it is possible to get what seem like compile-time errors at link time.

The second point matters if you write your own templates: Most current implementations require that in order to instantiate a template, the definition of the template, not just the declaration, has to be accessible to the implementation. Generally, this requirement implies access to the source files that define the template, as well as the header file. How the implementation locates the source file differs from one implementation to another. Many implementations expect the header file for the template to include the source file, either directly or via a #include. The most certain way to know what your implementation expects is to check its documentation.

8.1.2 Template instantiation (Accelerated C++),布布扣,bubuko.com

8.1.2 Template instantiation (Accelerated C++)

标签:os   io   for   art   ar   c++   type   ad   

原文地址:http://www.cnblogs.com/anit/p/3902404.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!