2011-11-14 129 views
0

可能重复:
Template instantiation details of GCC and MS compilersC++模板内部

  1. 如何做一个C++编译器便于模板编程?我有兴趣了解编译器在模板编程中遵循的方案。

  2. 另外,根据C++模板,typename和class之间有什么区别?

+0

2. http://stackoverflow.com/questions/2023977/c-difference-of-keywords-typename-and-class-in-templates – Pubby

+0

Thx为我指出了Pubby&德米特里。不知何故,我无法找到一个领先的。 –

回答

1

C++编译器如何促进模板编程?我有兴趣了解编译器在模板编程中遵循的方案。

模板实际上由编译器保存为某种宏,然后在专门化时应用扩展(模板部分替换为给定值),应用模板中指定的约束检查。

0

另外,根据C++模板,typename和class之间有什么区别?

没有区别,除非你使用模板,模板参数:

template <template <typename> class T> 
... 

不能

template <template <typename> typename T> 
//       ^^^^^^^^ wrong 
... 

Templates in c++,typename and class更换。