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.
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:
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.