I have a class Container, having a data member.
std::vector< std::unique_ptr<Sum_Function> > Functions;
This is how i add value to the vector.
MaxSize is the child of Sum_Function.
void WavefrontRenderer::AddMaxSize()
{
Container cont;
std::unique_ptr<Sum_Function> ptrMaxSize = std::make_unique<SumMaxSize>();
cont.AddFunction(ptrMaxSize);
}
this is the defination for Function in the Container class.
void Container::AddFunction(std::unique_ptr<Sum_Function> &func)
{
std::unique_ptr< Sum_Function > function(std::move(func));
this->Functions.push_back(function);
}
Is this the correct way to add Unique pointer to a vector.
Aucun commentaire:
Enregistrer un commentaire