C++ Insights - Episode 21: How noexcept works

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 พ.ย. 2024

ความคิดเห็น • 18

  • @MarcosCpp
    @MarcosCpp หลายเดือนก่อน +2

    I liked this video, quick and straight to the point

  • @TheMR-777
    @TheMR-777 2 ปีที่แล้ว +3

    Now I got it! Thanks a lot for sharing this info :)

  • @serhiymalokhatko
    @serhiymalokhatko ปีที่แล้ว +2

    Does it mean that compiler generates extra code to handle this situation, and `noexcept` function can be larger/slower than `noexcept(false)`?

  • @tomkirbygreen
    @tomkirbygreen 5 หลายเดือนก่อน +1

    Very useful. Seems like it’s far from zero cost. Does noexcept get used much in (semi) realtime systems?

    • @andreas_fertig
      @andreas_fertig  4 หลายเดือนก่อน +1

      Your move-constructors and move-assignment operators are typically noexcept. That's the reason why we have noexcept in the first place.

  • @rinket7779
    @rinket7779 2 ปีที่แล้ว +1

    amazing vid! thanks so much!

  • @niyazijackson
    @niyazijackson 2 ปีที่แล้ว +2

    Awesome. wouldnt it be nice if a handler could be passed into noexcept to be called in catch scope, instead of calling std::terminate().

    • @AlfredoCorrea
      @AlfredoCorrea 10 หลายเดือนก่อน

      not exactly the same, but in C++ you can customize what terminate does.

  • @AlfredoCorrea
    @AlfredoCorrea ปีที่แล้ว

    I don’t get it, the compiler can demonstrate that the body of the function will not be able to throw, so it will not contemplate calling terminate. So the code will be optimal in this case anyway. This video gives the opposite impression because it doesn’t say that all this will be optimized. I think the problem is when you say no except and you are calling a function that the compiler cannot demonstrate it cannot throw. In this case the compiled code generated will generate the call to terminate. I heard that there was an old argument in the committee and there was a faction (Abrahams?) that wanted plain UB for uncatched throwing inside noexcept and the other wanted a guaranteed call to terminate. The second faction won but there were some regrets afterwards.

    • @andreas_fertig
      @andreas_fertig  10 หลายเดือนก่อน +1

      There is no guarantee that an optimizer must do a particular optimization. This simple example compiler-explorer.com/z/TGeWcxrcf leads to code the compiler cannot efficiently optimize even though Other could simply return 2.

  • @JustABigFan2010
    @JustABigFan2010 9 หลายเดือนก่อน +7

    Andrea 99% of the surface area of your video content is blank. And the most important parts of your video is in the top left corner which is only 1% of the area. Would you please on your next videos kind of focus on that 1%. Either make the font larger so that it kind of becomes the 50% of the video surface area. A lot of people with huge monitors make this mistake. We don't need to see the useless 99% of the blank area. For the people too comfortably see that 1% of the surface area they will need to buy large monitors same as you. So watching this video on a 15 inch PC monitor a tablet or a phone is basically useless because you cannot even Zoom in on TH-cam videos.

    • @phusicus_404
      @phusicus_404 8 หลายเดือนก่อน

      You can zoom a video on TH-cam on a phone.

    • @JustABigFan2010
      @JustABigFan2010 8 หลายเดือนก่อน +1

      @@phusicus_404 Write and we love reading source code on a 6 inch phone screen. Besides do you think the quality when you zoom in is going to be good enough to understand anything that you're reading in the source code. Don't be silly.

  • @panjak323
    @panjak323 4 หลายเดือนก่อน

    So why isn't noexcept the default?

    • @andreas_fertig
      @andreas_fertig  4 หลายเดือนก่อน +1

      Well, because it was introduced a long time after C++98. In addition it is a save default. Once you start throwing exceptions which pass functions which are noexcept default things get hard.

  • @concienciaconectiva
    @concienciaconectiva 2 ปีที่แล้ว

    What is AST?

    • @andreas_fertig
      @andreas_fertig  ปีที่แล้ว +1

      Sorry, AST stands for abstract syntax tree. Here is the Wikipedia page explaining AST: en.wikipedia.org/wiki/Abstract_syntax_tree

  • @ЮрійГордієнко-х2з
    @ЮрійГордієнко-х2з 8 หลายเดือนก่อน

    Wrong