#include <algorithm>
#include <boost/iterator/iterator_facade.hpp>

template <class T>
class Container {
    T* t;
public:
    class Iterator : public boost::iterator_facade<Iterator, T, boost::random_access_traversal_tag, T, int> {
        friend class boost::iterator_core_access;
        T* t;
        int n;
        
        void increment(){ ++n; }
        void decrement(){ --n; }
        int distance_to(const Iterator& o) const { return n - o.n; }
        int& dereference() const { return t[n]; }
        void advance(int m) { n += m; }
        bool equal(const Iterator& o) const { return n == o.n; }
    public:
        Iterator(T* u, int m) : t(u), n(m) {}
    };
    
    Container(T* u) : t(u) {}
    
    Iterator begin() const { return Iterator(t, 0); }
    Iterator end(int n) const { return Iterator(t, n); }
};

int main() {
    int i[] = {5, 5, 5, 5, 5};
    Container<int> c(i);
    std::sort(c.begin(), c.end(5));
    
    return 0;
}