C++ - copy and swap

Поделиться
HTML-код
  • Опубликовано: 24 янв 2025

Комментарии • 15

  • @nevogusto9935
    @nevogusto9935 10 лет назад +8

    You seriously need to do more of that.
    There aren't such high-level lessons that are so well presented.
    Thank you!

  • @ankursahu7704
    @ankursahu7704 3 года назад

    @Bradley Please come up with more c++ videos.Thanks :)

  • @matteobarnaba6518
    @matteobarnaba6518 2 года назад

    Great video and great series of tutorials. Thanks 😊

  • @KishoreG2396
    @KishoreG2396 5 лет назад +1

    8:04 Then what is the point of defining a move assignment operator at all? If the same assignment operator can be used for rvalue references and regular lvalues?

  • @necatiergin8430
    @necatiergin8430 8 лет назад

    Very nice presentation! I think that the usage of the raw pointer instead of a unique_ptr object is just for the sake of simplicity. That Bradley is using 0 in place of nullptr is to preserve legality with older compilers.

  • @threelittlefoxproductions
    @threelittlefoxproductions 11 лет назад

    awesome video thanks, looking forward for more such advanced videos

  • @jeevansreerama1119
    @jeevansreerama1119 11 лет назад

    Thanks for the video, very useful. Looking forward for more videos.

  • @mujeebishaq2237
    @mujeebishaq2237 8 лет назад

    Thanks a million. Helped a lot !

  • @lysdexic9129
    @lysdexic9129 8 лет назад

    I was wondering whether a smart pointer should be used in place of the raw pointer? the constructors could throw when allocating memory.

    • @lysdexic9129
      @lysdexic9129 8 лет назад

      not an issue, if a ctor throws its dtor isn't invoked. Already constructed members do have their dtors invoked in such a scenario

  • @LuizDahoraavida
    @LuizDahoraavida 3 года назад

    Thanks!

  • @abdelrhmanahmed1378
    @abdelrhmanahmed1378 4 года назад

    why we dont delete the old object ?!

    • @bradleyneedham1666
      @bradleyneedham1666  4 года назад +2

      Because we swapped the pointers with the local temporary object, so the destructor of the temporary object will take care of deleting the old object.

    • @abdelrhmanahmed1378
      @abdelrhmanahmed1378 4 года назад

      @@bradleyneedham1666 so the temporary object will only live tell the assignment operator function end and then the destructor get called on it ?!

    • @bradleyneedham1666
      @bradleyneedham1666  4 года назад +1

      @@abdelrhmanahmed1378 yes