Better Code with C++ Attributes - Ben Saks - CppCon 2019

Sdílet
Vložit
  • čas přidán 2. 10. 2019
  • CppCon.org
    Discussion & Comments: / cpp
    Presentation Materials: github.com/CppCon/CppCon2019
    -
    Better Code with C++ Attributes
    Modern C++ attributes such as [[noreturn]] and [[deprecated]] can be used to improve code quality and programmer productivity. They provide valuable information to the compiler, allowing it to generate more efficient code and provide more useful warning messages. C++20 is slated to include several new attributes, including [[no_unique_address]] and the design-by-contract attributes. They also let you use compiler extensions on specific toolchains without locking you into using only those toolchains.
    This session explores several C++ attributes and provides examples of how to use each one to improve your programs. Although it focuses on the standard attributes, it also includes examples of non-standard attributes from specific toolchains.
    -
    Ben Saks
    -
    Videos Filmed & Edited by Bash Films: www.BashFilms.com
    *-----*
    Register Now For CppCon 2022: cppcon.org/registration/
    *-----*
  • Věda a technologie

Komentáře • 10

  • @seditt5146
    @seditt5146 Před 4 lety +55

    Just letting anyone watch know that the sound clears up around the 4 minute mark, you can keep watching and the Echo goes away.

  • @stephenjames2951
    @stephenjames2951 Před 4 lety +3

    Both videos by Ben Saks have been very interesting and valuable.

  • @dima1250narod0ru
    @dima1250narod0ru Před 3 měsíci

    Thanks a lot. It was very useful and helpful :)
    It's a pity: the standard gave us portable attributes, and then we have to wrap them in macros for portability :)

  • @ninepoints5932
    @ninepoints5932 Před 4 lety +2

    Ho conditional [[fallthrough]] I didn't realize that was possible :thumbsup:

  • @jimlin897
    @jimlin897 Před 4 lety +3

    I have imaged [[no_unique_address]] for a long time WOW

  • @tourdesource
    @tourdesource Před rokem

    IIRC flowing off the end of a function is actually UB. `main` might be the one exception.

  • @seditt5146
    @seditt5146 Před 4 lety +1

    37:20 I have attempted to use [[ likely ]] in a Ternary statement and it always tosses an error and won't compile. I have found no configuration which an attribute can be used in this case.

  • @Uristqwerty
    @Uristqwerty Před 4 lety +2

    Upon reaching the part about solutions for unrecognized attributes, I was amused at the thought that it might be, itself, solved with an attribute, like [[safe_to_ignore(list, of, known, attribute, names)]]. Ah well, guess it's boring *old* technology, without any self-referential humour.

    • @FF_Fanatic
      @FF_Fanatic Před 4 lety +1

      I'm thinking that since, e.g., Clang can give you "did you mean..." suggestions when you misspell something like a function or namespace, a compiler could potentially issue a warning for a misspelled attribute only if it's close enough to a known name (e.g., through Levenshtein distance).