Advanced Topics: Copy Elision

Поділитися
Вставка
  • Опубліковано 15 січ 2020
  • In this video we talk about copy elision and the return value optimization!
    Arthur's Talk - • CppCon 2018: Arthur O'...
    For code samples: github.com/coffeebeforearch
    For live content: / coffeebeforearch
  • Наука та технологія

КОМЕНТАРІ • 8

  • @AbcDino843
    @AbcDino843 3 роки тому +4

    Awesome, I wish someone would teach a whole course of C++ with compiler explorer :).

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

      I've been wanting to fo a "C++ for Compiler Explorers" for a while, doing similar type videos. So many ideas, so little time...

  • @pseudounknow5559
    @pseudounknow5559 3 роки тому

    Note that the RVO can still apply even when the function has several return statements, as long as the returned objects are created on the return statements

  • @DJGrazba
    @DJGrazba 2 роки тому

    hi nick thanks for the great material, if i may give you a little audio advice is to apply a lowcut/highpass filter to cut the bass from the audio i thought my neighbors were doing some noise because of the bass rumble , and we/you don't need the bass frequency content of the audio in your videos. thanks again for the great videos !

  • @dragosmakovei
    @dragosmakovei 3 роки тому

    if you don't have copy elision, in the exaple with the struct, you won't be copying just a pointer to the array? What is it so awful to copy pointers? Or when it returns it copies a pointer to each chunk of 2 bytes (as the registers are). Thanks

    • @CoffeeBeforeArch
      @CoffeeBeforeArch  3 роки тому +4

      You wouldn't want to copy a pointer because the memory is located on the stack, and goes out of scope when the function returns.

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

    I didn't the initial part around 1:15. EAX and EDX are each 32bits and sizeof(int) is 32bits as well. So how can they store 4 ints that requires 128 bits and you have only 64 bits combined? You're confusing EAX and EDX with RAX and RDX?

    • @killacrad
      @killacrad 5 місяців тому

      It's making an optimization since the array is 0/default initialized, output is same for int data[4] = {1, 0, 1, 0}. Try int data[4] = {0, 0, 0, 1} or int data[4] = {0, 1, 0, 0}. Now rax and/or rdx must be utilized.