#include <boost/range/numeric.hpp>
#include <boost/function_output_iterator.hpp>
#include <functional>
#include <iostream>

template <class Container>
auto mybackinsrtr(Container& cont) {
    // Throw away the first element
    return boost::make_function_output_iterator(
            [&cont](auto i) -> void { 
              static bool first = true;
              if (first)
                first = false;
              else
                cont.push_back(i);
            });
}


int main() {
    std::vector<int> v { 0, 1, 2, 3 }; // any generic STL container
    std::vector<int> result;
    boost::adjacent_difference(v, mybackinsrtr(result), std::plus<>{});
    for (auto i : result) {
        std::cout << i << ", ";
    }
    std::cout << '\n';
    return 0;
}

