jxbma
asked on
How do I iterate over a vector that is wrapped in a smart pointer in Microsoft C++ 11?
Hi:
I have a Microsoft C++ 11 application.
I have a vector of shared_ptrs that get returned from a method call.
In order for that vector not to be leaked, I have wrapped it in a shared_ptr as well.
How do I iterate over that vector when it is wrapped in a smart (shared) pointer?
I would have thought that "get()" would get me to the wrapped vector.
How would I go about doing this?
Is there a better pattern to use to achieve my goals?
Thanks,
JohnB
I have a Microsoft C++ 11 application.
I have a vector of shared_ptrs that get returned from a method call.
In order for that vector not to be leaked, I have wrapped it in a shared_ptr as well.
How do I iterate over that vector when it is wrapped in a smart (shared) pointer?
// Definition of the method
shared_ptr<vector<shared_ptr<Foo>>> GetVectorOfValues(){}
// Now in another method....
{
...
shared_ptr<vector<shared_ptr<Foo>>> values = GetVectorOfValues();
for (auto value : values.get())
{
}
}
I would have thought that "get()" would get me to the wrapped vector.
How would I go about doing this?
Is there a better pattern to use to achieve my goals?
Thanks,
JohnB
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER