Keynote: What Does It Take to Implement the C++ Standard Library? - Christopher Di Bella - C++Online

Поділитися
Вставка
  • Опубліковано 10 тра 2024
  • The Online C++ Conference - cpponline.uk/ -- @cpponlineconf
    ---
    Keynote: What Does It Take to Implement the C++ Standard Library? - Christopher Di Bella - C++Online
    Due to its vast complexity, there have only been a handful of C++ standard library implementations to date. In this session, we will discuss what separates the C++ standard library from C++ user code, the unique C++ design opportunities and constraints we have, and the considerations we need to make for our users.
    Slides: github.com/CppOnlineConferenc...
    ---
    Christopher Di Bella
    Christopher Di Bella is a senior software engineer working on improving the LLVM toolchain at Google. This includes working to improve Clang's diagnostics, adding Clang extensions, and implementing parts of the C++ standard library.
    ---
    Streamed & Edited by Digital Medium Ltd - online.digital-medium.co.uk
    ---
    C++Online - The Online C++ Conference organized by Shaved Yaks: shavedyaks.com/ & Digital Medium: events.digital-medium.co.uk
    ---
    #cpp #cplusplus #cpponline #programming #softwaredevelopment
  • Наука та технологія

КОМЕНТАРІ • 4

  • @Roibarkan
    @Roibarkan Місяць тому +1

    10:32 on slide 3.4 I think it might be better to use memcmp (or strncmp) to ensure that if the string implementation (that we’re testing) doesn’t put a null terminator (even if we planned for it to exist) we won’t hit UB. I guess this can get us down a rabbit hole - what if the data() member function has a bug and returns a dangling reference, etc.
    Great talk!

    • @anon_y_mousse
      @anon_y_mousse 28 днів тому

      That's getting a bit into the weeds unnecessarily. The entire test centers around string literals, and if it's changed in the future to use something else you'll have to be capable of determining the length of whatever string type you use without also hitting UB.

    • @cjdb-ns
      @cjdb-ns 20 днів тому +1

      Thanks for your comment! The issues you raise are indeed concerns. The null terminator issue will be caught by the unit tests for `basic_string::data`, as it's required to return a NUL-terminated pointer-to-char array (since C++11, and C++03 implementations also do this).
      The second issue you raised should be caught by sanitisers, fuzzing, and integration tests.

  • @anon_y_mousse
    @anon_y_mousse 28 днів тому

    Having made an attempt at implementing just the basic container types some 25-ish years back, I can tell you that you definitely don't want to start from scratch, especially in the current day. Also, I still say that std::map::operator[] shouldn't insert new keys. Implementing all of the C standard library was significantly easier back then, and even today is still significantly easier than the C++ standard library.
    If anyone is taking advice, unless you're willing to spend years on it, don't try to design and implement your own programming language, especially if you expect it to be a useful systems programming language. It is beyond annoying, although, from my own experience, consider using some sort of compiler construction tools or generating an IL such as what LLVM uses instead of writing the entire thing from scratch like an insane person.