After a quick investigation it comes out that the rvalue reference support has not been added yet to streams.
To return a non-copyable object from a function indeed it is sufficient to implement the move constructor as follows:
struct noncopyable
{
noncopyable()
{}
// move constructor
noncopyable(noncopyable &&)
{}
private:
noncopyable(const noncopyable &);
noncopyable &operator=(const noncopyable &);
};
Such constructor is supposed to transfer the ownership to the new object leaving the one being passed in a default state.
That said, it is possible to return an object from a function in this way:
noncopyable factory()
{
noncopyable abc;
return std::move(abc);
}
While std::stream does not support move constructors it seems that STL containers shipped with gcc 4.3.2 do already support it.