begin and end overloads for istream_iterator
Not sure that's how I would have written in.
Its not normal to call std::begin() and std::end() on an iterator.

I would have arranged for a some type to represent the stream as a container:

#include &lt;iostream&gt;
#include &lt;iterator&gt;
#include &lt;fstream&gt;

namespace ThorsAnvil
{
    template&lt;typename T&gt;
    struct StreamAsContainer
    {
        std::istream&amp; str;
        StreamAsContainer(std::istream&amp; str) : str(str) {}
    };

    template &lt;typename T&gt;
    std::istream_iterator&lt;T&gt; begin(StreamAsContainer&lt;T&gt;&amp; c)
    {
        return std::istream_iterator&lt;T&gt;(c.str);
    }

    template &lt;typename T&gt;
    std::istream_iterator&lt;T&gt; end(StreamAsContainer&lt;T&gt;&amp;)
    {
        return std::istream_iterator&lt;T&gt;();
    }

}

int main()
{
    namespace TA=ThorsAnvil;
    for (std::string s : TA::StreamAsContainer&lt;std::string&gt;(std::cin))
    {
        std::cout &lt;&lt; s;
    }
}