The New C++ Library: Strong Library Foundation for Future Projects - Jonathan Müller & Arno Schödl

Sdílet
Vložit
  • čas přidán 14. 08. 2023
  • www.cppnow.org​
    / cppnow
    ---
    The New C++ Library on the Block: A Strong Library Foundation for Your Next Project - Jonathan Müller / Arno Schödl - CppNow 2023
    Slides: github.com/boostcon
    ---
    We have given many conceptual talks about iterators, ranges, string formatting, and generic programming in the past. Now, we would like to present the library that is the foundation of our code base and that lets us write code the way we like it: Short, elegant, and to the point.
    Did you know that std::move can be called on a const reference? And that you cannot move out of that const reference but will silently copy? Wouldn't it be nice to get a compiler error in that case?
    Our range implementation is more powerful and easier to use than std::ranges. We treat generator functions as ranges, too. With the same syntax as iterator-based ranges, you often do not need to know the difference.
    We extend the standard range algorithms (and our own additional algorithms) with return type arguments that express common programming patterns elegantly: How often did you call std::ranges::find_if and compare the result to an end iterator? Wouldn't it be shorter and more elegant to write something like tc::find_if tc::return_bool?
    The talk will focus on actual usage, rather than conceptual ideas. The library is open-source, header-only and thus easy to integrate into any project. For any new project, it will be a significant head start over the standard library. We strive for our library to be close to the standard library in names and conventions, so it is compatible with std ranges and algorithms and you can mix and match it with other libraries.
    ---
    Jonathan Müller
    Jonathan is a library developer at think-cell. In his spare time, he works on various C++ open source libraries for memory allocation, cache-friendly containers, or parsing. He also blogs at foonathan.net and is a member of the C++ standardization committee.
    Arno Schödl
    Founder & CTO
    Arno is responsible for the design, architecture and development of all our software products. He oversees think-cell's R&D team, Quality Assurance and Customer Care.
    Before founding think-cell, Arno worked at Microsoft Research and McKinsey. Arno studied computer science and management and holds a Ph.D. from the Georgia Institute of Technology with a specialization in Computer Graphics.
    ---
    Video Sponsors: think-cell and Bloomberg Engineering
    Audience Audio Sponsors: Innoplex and Maryland Research Institute
    ---
    Videos Filmed & Edited By Bash Films: bashfilms.com/
    CZcams Channel Managed & Optimized By Digital Medium Ltd: events.digital-medium.co.uk
    ---
    CppNow 2024
    www.cppnow.org​
    / cppnow
    ---
    #boost #cpp #cppprogramming
  • Věda a technologie

Komentáře • 16

  • @will1am
    @will1am Před 8 měsíci +8

    Finally a interesting presentation where they talk about C++ and not about some alternative C++ WIP languages ( or Rust) , at an event called CPPnow...
    Great!

  • @MatthewWalker0
    @MatthewWalker0 Před 9 měsíci +1

    lots of fun utils! Maybe just an oversight, but couple didn't have examples :( (at least for the best solution). Eg. final version of the scope_exit/defer, which is used like `tc_scope_exit [&] { do stuff; };` i think? Looks like a keyword!

    • @foonathan
      @foonathan Před 9 měsíci +1

      It's `tc_scope_exit { do stuff; }`. Yes, that it looks like a keyword is very much the idea.

  • @simonfarre4907
    @simonfarre4907 Před 9 měsíci +3

    As far as I am aware you "can't" (shouldn't) use span as substitute for string_view. A string_view is a view (immutable) while span is a range (possibly mutable), no?

    • @OMGclueless
      @OMGclueless Před 9 měsíci

      I don't think there's any difference in representation between std::string_view and std::span. Just some minor API differences related to how they're expected to be used.

    • @foonathan
      @foonathan Před 9 měsíci +1

      But you can use `std::span`.

  • @XzatonJW
    @XzatonJW Před 8 měsíci

    Im still not really used to the range-based stuff, and haven't seen enough uses of it to make me really think its a good idea.
    But the monadic stuff of programming the happy path and letting the "if it didnt work then bail early" type code does seem very neat.

  • @acestapp1884
    @acestapp1884 Před 7 měsíci

    Is find_first_if extensible? Or is the purpose to allow forwarding or the return types? What's the advantage over using different names, like find_first_if_bool() etc.?

    • @foonathan
      @foonathan Před 6 měsíci +1

      It is extensible. As in: You can write your own ReturnType policy.
      We do not have different names, because we have a couple dozen return type policies for a couple dozen algorithms. That would be hundreds of algorithms.

  • @Roibarkan
    @Roibarkan Před 9 měsíci +1

    6:08 Jonathan mentions the use of concepts in tandem with traits that can be specialized (in order to specifically opt-in/out of the concept). I wonder why think-cell chose to use concepts here, and not just have a trait with the same value. On the other hand, I wonder why concepts can’t be specialized (almost every other ‘templated’ thing in c++ can be specialized)

    • @foonathan
      @foonathan Před 9 měsíci

      That's a common idiom, e.g. `std::borrowed_range` has `std::enable_borrowed_range` you can specialize.

    • @Roibarkan
      @Roibarkan Před 9 měsíci +2

      Thanks for the reply. Indeed, allowing concepts to be overridden via specialization of some bool-like template is a common idiom in the language. In this comment I tried to ask 'why'. More specifically, I note that concepts are one of very few templated notions that cannot be specialized - and I see it as a potentially missing part in the language, that people work-around with this common idiom. When I choose whether to use a concept or another bool-like template - I am very aware of this limitation, and don't know if I should instinctively delegate add 'and not disable_my_concept' to most of the concepts I write (to allow opt out, like disable_sized_range), whether to add 'or enable_my_concept' like in this case, or perhaps to avoid using concepts in places where there's a good reason for users to specialize due to semantic knowledge of they types that can't be expressed generically. I wonder what is your take on this.

    • @Roibarkan
      @Roibarkan Před 8 měsíci +1

      @@foonathan BTW, in my talk from cppnow 2021 about concepts I call this idiom "Semantic sugar", because it allows people to give the compiler information about the semantics of their types. czcams.com/video/u0rvEMV8Qq4/video.html

  • @CuriousCauliflowerX
    @CuriousCauliflowerX Před 9 měsíci +9

    This is a great advertisement for Rust.

  • @TNothingFree
    @TNothingFree Před 9 měsíci +4

    Important talk but pretty boring sorry. Very hard to listen to