dimanche 29 janvier 2017

return back original pointer from dereferenced pointer

auto &element = *std::make_unique<Source_Element>();
    auto n = sfElements.size();
    element.setIndex(n);
    element.setCurve(curve);

    sfElements.push_back(std::move(*element)); // -> this doesn't work

I tried auto element = std::make_unique<Source_Element>(); then , sfElements.push_back(std::move(element)); it works just fine

Dereferring unique pointer result in getting Source_Element Class. then it goes into element value. but I am wondering there is anyway to get the original pointer which is unique pointer from dereferenced pointer(which is Source_Element Class) just like a code i wrote on top

Aucun commentaire:

Enregistrer un commentaire