关于 GNU 的 STL 版本更替

最近在看侯捷老师的《STL 源码剖析》,当读到 STL 的实现版本时,其中提到:

SGI 版本被 GCC 采用。你可以在 GCC 的 include 目录中(相对于 cygwin 的安装目录,其相对路径为 .\lib\gcc\x86_64-pc-cygwin\10\include\c++,我们下面的目录都以此目录为根目录)找到所有 STL 文件。

但是我在自己的 MinGW 上找到的 STL 并不是 SGI 的实现。起初我以为是系统的原因,所以我安装了 Cygwin,又去 Linux 上用 yum 安装了 gcc 和 g++ ,并查看了它们的 libstdc++,发现还不是 SGI 的实现(比如不存在 stl_alloc.h 头文件)。后来我在网上的某个网友的分享里发现了下面这句话:

GNU STL
这是 GCC 自带的 STL 实现,包含在 libstdc++ 这个库里面,写 C++ 一旦用到库函数是基本会链接这个库。GNU STL 是在 SGI STL 基础上开发的,所以 SGI STL 我就不再单独列出了。

并且之前查看的不是 SGI 实现的源码开头都有这段话(只有第一行的时间不同):

// Copyright © 2001-2021 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// http://www.gnu.org/licenses/.

/*

  • Copyright © 1996-1997
  • Silicon Graphics Computer Systems, Inc.
  • Permission to use, copy, modify, distribute and sell this software
  • and its documentation for any purpose is hereby granted without fee,
  • provided that the above copyright notice appear in all copies and
  • that both that copyright notice and this permission notice appear
  • in supporting documentation. Silicon Graphics makes no
  • representations about the suitability of this software for any
  • purpose. It is provided “as is” without express or implied warranty.

*/

考虑到作者当年的编译环境,于是我觉得可能是 Free Software Foundation 公司在 2001-2021 这段时间都不再直接使用 SGI STL,而是对其进行了整合。

在 GNU 的 API 分享中查找以往发布的 libstdc++,并选择一个在2001年前的下载下来。

在这里插入图片描述

此时我们下载并查看 STL 的相关文件,终于发现了 SGI STL 的相关头文件:

在这里插入图片描述


留待以后更新

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值