研读《C++ Primer 3/e》,各位会遭遇一个困扰:「没有完全
支援 C++ Standard 的编译器」可用。在 template 方面,
实作品(编译器)落後规格书尤其多。
以我常用的 VC6 和 BCB4 而言,它们都未「完全支援 C++ Standard」。
整体看来,BCB4 好很多,VC6 所未能支援的 member templates,
nested types of class templates, class template partial
specializations 等等,BCB4 都有支援。不过 BCB4 在 STL 方面
有少数不应该的 miss。至於 template separation compilation model,
两家编译器都不支援。
你无法从两家编译器的手册中看出它们支援什麽 features、不支援
什麽 features(前述所列都是我实地检测的结果)。所以各位在研
读《C++ Primer 3/e》的 chap10 Function Templates 和
chap16 Class Femplates 时,如果书上程式无法通过手中的编译器,
请不要在其实无误的程式码上钻三天三夜。
另外,书中程式常使用 max() 和 min() 两个名称做为 function
templates,或 class template 的 member functions。你要亲证
程式码时,最好把它们改改名字。因为 Borland C++ 编译器提供
有现成的 max() 和 min(),一个不小心,你在不知不觉中叫用了
现成的那两个函式,程式结果会让你百思不解。我在这上面浪费了
不少时间
...全文
245打赏收藏
{转]读《C++Primer》:编译器对C++Standerd的支持
研读《C++ Primer 3/e》,各位会遭遇一个困扰:「没有完全 支援 C++ Standard 的编译器」可用。在 template 方面, 实作品(编译器)落後规格书尤其多。 以我常用的 VC6 和 BCB4 而言,它们都未「完全支援 C++ Standard」。 整体看来,BCB4 好很多,VC6 所未能支援的 member templates, nested types of class templates, class template partial specializatio