Returning containers from function - C++ I've been trying to implement a few interfaces for processing data. And most of the time I do new of container and return a smart pointer to this container. Something like this:

class GenericUtil
{
    private: 
        // Some members here

    public:
        unique_ptr&lt;vector&lt;string&gt;&gt; BreakStringOnDelimiter( string&amp; dataStr );
};


But recently I came across "The c++ Programming Language" book and observed that Stroustrup seems to be suggesting to return containers just like that. But some other cases, he also demonstrates use of smart pointers for the same. So I have been just wondering what would be most efficient and maintainable way (plus a style which doesn't come as surprise to other fellow devs) of doing this?

unique_ptr&lt;vector&lt;string&gt;&gt; BreakStringOnDelimiter( string&amp; dataStr );


or

vector&lt;string&gt; BreakStringOnDelimiter( string&amp; dataStr );


or

vector&lt;string&gt;* BreakStringOnDelimiter( string&amp; dataStr );


or something else?

Please suggest which one and why?

Thanks in advance!
In C++ 11 you probably would use 

vector&lt;string&gt; BreakStringOnDelimiter( const string&amp; dataStr );


The container classes can be very efficiently move constructed (this is a new and smart feature of C++ 11 which can avoid temporary objects in many cases), which means that on return no expensive copy construction of the containers (and the strings in the container) is needed. Essentially only the some pointers are passed around on return.

Alternatively the solution with unique_ptr would also work, but is in my opinion not as good (and probably not really more efficient).

Given these alternative options, returning a bare pointer is not recommended.

For maximum efficiency you should consider using the emplace function when filling the vector. This avoids additional copies of string.

Also probably const string &amp; as argument is better suited.