STL源代码里面满山遍野都是宏,让我这个菜鸟感到有点无所适从了。在看过EFFECITVE STL中对vector容器的介绍以后,我感觉还是从某个容器下手开始学习STL源代码(我看的是SGI版的STL)。
      打开<vector>这个标准头文件发现一堆#include
#ifndef __SGI_STL_VECTOR
#define  __SGI_STL_VECTOR


#include 
< stl_range_errors.h >
#include 
< stl_algobase.h >
#include 
< stl_alloc.h >
#include 
< stl_construct.h >
#include 
< stl_uninitialized.h >
#include 
< stl_vector.h >
#include 
< stl_bvector.h >

#endif  /* __SGI_STL_VECTOR */
       看来只能各个击破了。打开<stl_range_errors.h>看看,发现只有一个头文件被包含#include <stl_config.h>。直觉告诉我,这个应该就是宏老大!打开文件stl_config.h,果然宏都在这里开会。还好SGI的大牛们还给了堆注释,不然早就崩溃了。
      从注释中我发现大部分宏是都是在对各种编译器作妥协。主要还是template技术太过前卫了,很多编译器都不认识它。
 

posted on 2006-04-21 14:44 PeterFelux 阅读(377) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理