C++ From Scratch: Move Constructors

Поділитися
Вставка
  • Опубліковано 18 жов 2024
  • In this video we learn about the basics of move constructors in C++!
    C++ Reference move constructors: en.cppreferenc...
    C++ Reference vector push_back: en.cppreferenc...
    For code samples: github.com/coff...
    For live content: / coffeebeforearch

КОМЕНТАРІ • 5

  • @badassopenpolling
    @badassopenpolling Місяць тому

    It would be nice to see print out of destructors too with this prints

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

    This would be another example of the adage that for C when they saw a gap they just wrote more code, for {insert other languaage, C++ generally but these days you see it a lot} when they saw a gap they added syntax. While I do think it could've been designed in a better way, it at least made some kind of sense given that it's just doubling the symbol used for references. But I still wish they had gone with the @ symbol.

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

    If I do a second push, e.g, like the following,
    my_vector.push_back(std::move(p1));
    my_vector.push_back(std::move(p2));
    why do I see a copy constructor running in the end?

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

      The vector probably needed to allocate space to hold more than one element, and had to copy the first element to the newly allocated space

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

      @@CoffeeBeforeArch I see. Thank you for the response! Your videos are amazing btw! Thanks for making them.