Wednesday, July 3, 2013

FeedaMail: Comments for Sutter̢۪s Mill

feedamail.com Comments for Sutter's Mill

Comment on GotW #91 Solution: Smart Pointer Parameters by Emmanuel Thivierge

Hi everybody,
I came back o read again this post because I was in front of a dilema and I was wondering what is the best way to express it.

I had created a std:vector and I was going to pass it to a function

std:vector widgetList;
myWidgetManager.addWidgetList(widgetList);
[\code]

To me addWidgetList is a sink, the object will take the ownership of the vector. So I tough, I should pass a std:unique_ptr<std::vector>, first it start to be a mouthful to write and my object is actually on the stack.

In this guru you don’t only talk about smart pointers but also on when/how to pass argument to functions. To me this situation is like c) the function is a sink but for the stack i would express it as std::vector&&.

Would that be a good practice?
thanks
Mani

Read More »
 
Delievered to you by Feedamail.
Unsubscribe