PacktPublishing / The-Modern-Cpp-Challenge

The Modern C++ Challenge, published by Packt
MIT License
308 stars 105 forks source link

Question, why we do not return std::unique_ptr with std::move? #10

Open movhdi opened 8 months ago

movhdi commented 8 months ago

https://github.com/PacktPublishing/The-Modern-Cpp-Challenge/blame/6a79f529c038a15c752acb67b4aef7c0d366f1a3/Chapter08/problem_69/main.cpp#L146-L151

In the piece of code referred by the above link, I am quite confused why we do not we return std::unique_ptr from map by means of std::move(), I tried and the code did not generate numbers. However if we use std::unique_ptr& as the return type it works? what is the problem?