I have a shared pointer to the result of some calculation as follows:
std::list<std::shared_ptr<myResult>> ResultList;
for (int i= 0; i < upperBound; i++)
{
DoCalculation();
std::shared_ptr<myResult> Res;
Res = DoCalculation->GetOutput();
ResultList.push_back(Res);
}
In debug mode I can see that at each iteration Res
is updated, though all values in ResultList
are equal to the last iteration's Res
pushed to ResultList
. How can I keep the result of calculation in the list using Res
?