mercredi 24 février 2021

Function returns const ref to std::unique_ptr, can it return null?

I have a function that return const ref to a std::unique_ptr. I'm getting this ptr from some container. I want to have a possibility to return nullptr or something when in my container of std::unique_ptr there is no appropriate object to the input values. It seems to be impossible with const ref. There is definitely an option to return const raw pointer, but I would like to stick to std::unique_ptr if it's possible.

Aucun commentaire:

Enregistrer un commentaire