(评论)
(comments)

原始链接: https://news.ycombinator.com/item?id=43468976

一个 Hacker News 帖子讨论了一篇关于编写自定义 C++ 标准库的文章。一个用户指出,现代 C++ 特性越来越依赖于 `std` 命名空间,至少需要一个基本的标准库实现。另一个用户称赞了这篇文章的语气、范围(由特定的程序实现定义)以及与 STL 的比较。他们注意到作者的实现和 STL 的 `vector` 实现的代码行数差异很大,但编译时间却只相差 4 倍。他们建议将示例程序的源代码作为文本而不是图片包含在内。其他用户批评标题具有误导性,澄清作者并非重新实现了整个 STL,而是实现了在 STL 中具有相应功能的特定类。他们还指出了目前重新实现的范围有限。

相关文章
  • 从零开始编写你自己的C++标准库 2025-03-25
  • (评论) 2024-04-20
  • (评论) 2025-03-24
  • (评论) 2024-09-02
  • (评论) 2025-03-17

  • 原文
    Hacker News new | past | comments | ask | show | jobs | submit login
    Writing your own C++ standard library from scratch (nibblestew.blogspot.com)
    14 points by JNRowe 49 minutes ago | hide | past | favorite | 4 comments










    A problem I encountered while writing custom stdlib, is that certain language features expect stdlib to be there.

    For example, <=> operator assumes, that std::partial_ordering exists. Kinda lame. In the newer C++ standards, more and more features are unusable without stdlib (or at least std namespace).



    Very nice! I like the tone and flippant energy of the post, of course, and also the way to get a nice scope by having a concrete case of a program to implement.

    I also appreciated the comparisons against STL, very informative. It's ... interesting that if including `vector` in STL brings in 27,000 lines, and the author's implementation of the functionality for the example program was only 1,000 lines, that the compilation time difference is only 4X. Not sure I understand that, really. But benchmarking is hard, of course.

    If I could come with a single suggestion it would be to include the sample program's source as text, not as a picture of text. If that means losing the pretty syntax highlighting, that's fine (by me). :)



    The title is confusing. He is not reimplementing the STL. He is writing some C++ classes providing functionality that is also already implemented in STL.


    Yes, and he has so far reimplemented only a tiny fraction of that STL functionality.

    Still interesting, despite the misleading title.







    Join us for AI Startup School this June 16-17 in San Francisco!


    Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact



    Search:
    联系我们 contact @ memedata.com