If you're using C++11, you could return a smart pointer to a new allocated stream object.



std::unique_ptr< std::istream > makeStream( /* various argument here ....... */ )
{
return...