Back to Basics: const and constexpr - Rainer Grimm - CppCon 2021

Поділитися
Вставка
  • Опубліковано 21 гру 2021
  • cppcon.org/
    github.com/CppCon/CppCon2021
    ---
    It is a virtue to program as const as possible in modern C++. Your program is by design way more type safe, has fewer concurrency issues, and runs with high probability faster.
    Const has many flavors in modern C++. Thanks to const, you can protect a value against mutation. With constexpr, you can initialize and compute values at compile time. Thanks to conteval, a computation can only run at compile time. In the end, constinit empowers you to initialize a modifiable value at compile time.
    Let me show you in my lecture how you can initialize a value with constexpr and constinit in a thread-safe way. Let me show you how const and constexpr help you protect values from mutation and, therefore, make them immune to data races. Finally, let me show you how constexpr and consteval empowers you to improve the performance of your program and get functions that are by design easy to test, easy to maintain, and implicitly thread-safe.
    ---
    Rainer Grimm
    I've worked as a software architect, team lead, and instructor since 1999. In 2002, I created company-intern meetings for further education. I have given training courses since 2002. My first tutorials were about proprietary management software, but I began teaching Python and C++ soon after. In my spare time, I like to write articles about C++, Python, and Haskell. I also like to speak at conferences. I publish weekly on my English blog (www.modernescpp.com/) and the (www.grimm-jaud.de/index.php/b..., hosted by Heise Developer. Since 2016 he is an independent instructor giving seminars about modern C++ and Python. Rainer published several books in various languages to modern C++ and concurrency, C++20, and the C++ Core Guidelines, in particular. Due to his profession, Rainer always searches for the best way to teach modern C++
    ---
    Videos Streamed & Edited by Digital Medium: online.digital-medium.co.uk
    *--*

КОМЕНТАРІ • 27

  • @superscatboy
    @superscatboy 2 роки тому +3

    Fantastic explanation of a subtle but fundamental set of tools.

  • @fppt1555
    @fppt1555 2 роки тому +4

    Thanks for the talk! Extremely helpful.

  • @discreet_boson
    @discreet_boson 2 роки тому +1

    This was a great refresher, thanks!

  • @m1t0z
    @m1t0z 2 роки тому +2

    Nice talk! Thanks for structuring different types of "const" both from historical and functional perspectives. Look forward to use constinit to solve issues with initialization order of the variables with ssd in our codebase (currently we are relaying on the linker order but are not really happy with that approach). P. S. In case you need some constructive feedback I would suggest to add an additional explicit section to your presentation where to highlight the guidelines where, when and why to use which type of "const".

  • @bogdansikach7709
    @bogdansikach7709 2 роки тому +4

    To read the type correctly (const char* const ptr, etc) use the "spiral rule" - not just "right to left".

  • @MaxCoplan
    @MaxCoplan 2 роки тому +1

    Great talk! I wish the chat could be shown on screen for the Q&A portion

  • @LiveseyMD
    @LiveseyMD 2 роки тому +6

    It would be really great to add time codes to the description.

  • @user-kh8nz7rg7j

    Great talk! Thanks for sharing! I wish subtitles was enabled.

  • @sadiqueali930
    @sadiqueali930 2 роки тому +6

    Fantastic Presentaion

  • @isayurdagul
    @isayurdagul Рік тому +1

    Is there a slip of tounge or did I misunderstand what is meant to be said at

  • @ChrisOffner
    @ChrisOffner 2 роки тому +2

    Unfortunately I still don't understand the meaning of "logical constness: The object is const but could be changed." Yes, there was an example about avoiding a compilation error when using

  • @saipan1970
    @saipan1970 2 роки тому +3

    Such a wonderful content, could not enjoy just because of small fonts.Sir,please consider also the mobile viewers, I sincerely follows your 📖 and articles on C++.

  • @sanjaygatne1424
    @sanjaygatne1424 2 роки тому +1

    small font size makes good information hard to understand. please give attention to font size its hard to read code on video.

  • @ejyjawa352
    @ejyjawa352 2 роки тому +2

    Where are the slides ?! Thanks !

  • @bsdooby
    @bsdooby 2 роки тому +1

    What about east const vs. const west?

  • @Heyothatsittahowski
    @Heyothatsittahowski Рік тому

    This is interesting @

  • @badassopenpolling

    One thing is missing regarding consteval - Why should we use consteval ? Motivation advantages ?

  • @OlliS71

    Of course const objects can be victim of data races if there are mutable members.

  • @Moriadin
    @Moriadin Рік тому

    The shared screen is awfully blurry :(