Code for sums in a vector
You make the assumption of random accesses iterators.
It would be nice to be able to do this with any iterator (including input iterator)

template &lt;class InIt, class OutIt&gt;
OutIt adjacent_sum(InIt begin, InIt end, OutIt result)
{ 
    if (begin == end)
    {     return result;    // From @Corbin
    }

    auto  last = (*begin);  // Get the value now before incrementing the iterator.
    ++begin;     
    while (begin != end)
    {
        auto next = (*begin);
        *result   = next + last;
        last      = next;

        ++result;
        ++begin;
    }
    return result;
}


Now the following works:

adjacent_sum(std::istream_iterator&lt;int&gt;(std::cin), std::istream_iterator&lt;int&gt;(), 
             std::ostream_iterator&lt;int&gt;(std::cout, "\t"));