search

Home  >  Q&A  >  body text

关于c++11move copy contructor

ringa_leeringa_lee2773 days ago419

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 14:02:14

    1) Returns a nullptr, which has no special function.

    2) Because the compiler will optimize out your code when dealing with this situation, similar to:

    my_unique_ptr<Mint> p4(new Mint(19));
    
    

    So your move ctor is not called. This optimization is usually called Return Value Optimization(RVO) and is called Copy Elision in the standard. If you are using G++, you can disable this optimization by adding -fno-elide-constructors to the compilation parameters and see the difference in the results.

    reply
    0
  • Cancelreply