STL源码剖析-绪论

来源:互联网 发布:空白网名软件 编辑:程序博客网 时间:2024/06/05 10:16

STL,标准模板库,无处不存在GP(generic programming泛型编程),有多种实现版本。

GNU C++采用的STL为:SGI STL,源码下载,参考文档。


STL文件讲解一:<stl_config.h> 针对不同的编译器,定义各种环境常量。选取其中的针对GNU编译器的一部分。

# ifdef __GNUC__#   if __GNUC__ == 2 && __GNUC_MINOR__ <= 7#     define __STL_STATIC_TEMPLATE_MEMBER_BUG#   endif#   if __GNUC__ < 2 #     define __STL_NEED_TYPENAME#     define __STL_NEED_EXPLICIT#   endif#   if __GNUC__ == 2 && __GNUC_MINOR__ <= 8#     define __STL_NO_EXCEPTION_HEADER#     define __STL_NO_BAD_ALLOC#   endif#   if __GNUC__ == 2 && __GNUC_MINOR__ >= 8#     define __STL_CLASS_PARTIAL_SPECIALIZATION#     define __STL_FUNCTION_TMPL_PARTIAL_ORDER#     define __STL_EXPLICIT_FUNCTION_TMPL_ARGS#     define __STL_MEMBER_TEMPLATES#     define __STL_CAN_THROW_RANGE_ERRORS      //    g++ 2.8.1 supports member template functions, but not member      //    template nested classes.#     if __GNUC_MINOR__ >= 9#       define __STL_MEMBER_TEMPLATE_CLASSES#       define __STL_TEMPLATE_FRIENDS#       define __SGI_STL_USE_AUTO_PTR_CONVERSIONS#       define __STL_HAS_NAMESPACES//#       define __STL_USE_NEW_IOSTREAMS#     endif#   endif#   define __STL_DEFAULT_CONSTRUCTOR_BUG#   ifdef __EXCEPTIONS#     define __STL_USE_EXCEPTIONS#   endif#   ifdef _REENTRANT#     define __STL_PTHREADS#   endif#   if (__GNUC__ < 2) || (__GNUC__ == 2 && __GNUC_MINOR__ < 95)#     define __STL_NO_FUNCTION_PTR_IN_CLASS_TEMPLATE#   endif# endif



0 0
原创粉丝点击