#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;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGJvb3N0L2l0ZXJhdG9yL2l0ZXJhdG9yX2ZhY2FkZS5ocHA+Cgp0ZW1wbGF0ZSA8Y2xhc3MgVD4KY2xhc3MgQ29udGFpbmVyIHsKICAgIFQqIHQ7CnB1YmxpYzoKICAgIGNsYXNzIEl0ZXJhdG9yIDogcHVibGljIGJvb3N0OjppdGVyYXRvcl9mYWNhZGU8SXRlcmF0b3IsIFQsIGJvb3N0OjpyYW5kb21fYWNjZXNzX3RyYXZlcnNhbF90YWcsIFQsIGludD4gewogICAgICAgIGZyaWVuZCBjbGFzcyBib29zdDo6aXRlcmF0b3JfY29yZV9hY2Nlc3M7CiAgICAgICAgVCogdDsKICAgICAgICBpbnQgbjsKICAgICAgICAKICAgICAgICB2b2lkIGluY3JlbWVudCgpeyArK247IH0KICAgICAgICB2b2lkIGRlY3JlbWVudCgpeyAtLW47IH0KICAgICAgICBpbnQgZGlzdGFuY2VfdG8oY29uc3QgSXRlcmF0b3ImIG8pIGNvbnN0IHsgcmV0dXJuIG4gLSBvLm47IH0KICAgICAgICBpbnQmIGRlcmVmZXJlbmNlKCkgY29uc3QgeyByZXR1cm4gdFtuXTsgfQogICAgICAgIHZvaWQgYWR2YW5jZShpbnQgbSkgeyBuICs9IG07IH0KICAgICAgICBib29sIGVxdWFsKGNvbnN0IEl0ZXJhdG9yJiBvKSBjb25zdCB7IHJldHVybiBuID09IG8ubjsgfQogICAgcHVibGljOgogICAgICAgIEl0ZXJhdG9yKFQqIHUsIGludCBtKSA6IHQodSksIG4obSkge30KICAgIH07CiAgICAKICAgIENvbnRhaW5lcihUKiB1KSA6IHQodSkge30KICAgIAogICAgSXRlcmF0b3IgYmVnaW4oKSBjb25zdCB7IHJldHVybiBJdGVyYXRvcih0LCAwKTsgfQogICAgSXRlcmF0b3IgZW5kKGludCBuKSBjb25zdCB7IHJldHVybiBJdGVyYXRvcih0LCBuKTsgfQp9OwoKaW50IG1haW4oKSB7CiAgICBpbnQgaVtdID0gezUsIDUsIDUsIDUsIDV9OwogICAgQ29udGFpbmVyPGludD4gYyhpKTsKICAgIHN0ZDo6c29ydChjLmJlZ2luKCksIGMuZW5kKDUpKTsKICAgIAogICAgcmV0dXJuIDA7Cn0=
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h: In function ‘void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = Container<int>::Iterator]’:
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1829: instantiated from ‘void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:4785: instantiated from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = Container<int>::Iterator]’
prog.cpp:32: instantiated from here
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1760: error: lvalue required as left operand of assignment
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h: In function ‘void std::__unguarded_linear_insert(_RandomAccessIterator, _Tp) [with _RandomAccessIterator = Container<int>::Iterator, _Tp = int]’:
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1763: instantiated from ‘void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1829: instantiated from ‘void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:4785: instantiated from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = Container<int>::Iterator]’
prog.cpp:32: instantiated from here
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1720: error: lvalue required as left operand of assignment
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1724: error: lvalue required as left operand of assignment
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_heap.h: In function ‘void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = Container<int>::Iterator]’:
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1560: instantiated from ‘void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:4634: instantiated from ‘void std::partial_sort(_RAIter, _RAIter, _RAIter) [with _RAIter = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1907: instantiated from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = Container<int>::Iterator, _Size = int]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:4783: instantiated from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = Container<int>::Iterator]’
prog.cpp:32: instantiated from here
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_heap.h:259: error: lvalue required as left operand of assignment
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algobase.h: In static member function ‘static void std::__iter_swap<_BoolType>::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = Container<int>::Iterator, _ForwardIterator2 = Container<int>::Iterator, bool _BoolType = false]’:
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algobase.h:142: instantiated from ‘void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = Container<int>::Iterator, _ForwardIterator2 = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1867: instantiated from ‘_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, _Tp) [with _RandomAccessIterator = Container<int>::Iterator, _Tp = int]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1919: instantiated from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = Container<int>::Iterator, _Size = int]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:4783: instantiated from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = Container<int>::Iterator]’
prog.cpp:32: instantiated from here
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algobase.h:94: error: lvalue required as left operand of assignment
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algobase.h:95: error: lvalue required as left operand of assignment
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_heap.h: In function ‘void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp) [with _RandomAccessIterator = Container<int>::Iterator, _Distance = int, _Tp = int]’:
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_heap.h:392: instantiated from ‘void std::make_heap(_RAIter, _RAIter) [with _RAIter = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1557: instantiated from ‘void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:4634: instantiated from ‘void std::partial_sort(_RAIter, _RAIter, _RAIter) [with _RAIter = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1907: instantiated from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = Container<int>::Iterator, _Size = int]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:4783: instantiated from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = Container<int>::Iterator]’
prog.cpp:32: instantiated from here
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_heap.h:234: error: lvalue required as left operand of assignment
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_heap.h:240: error: lvalue required as left operand of assignment
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_heap.h: In function ‘void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp) [with _RandomAccessIterator = Container<int>::Iterator, _Distance = int, _Tp = int]’:
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_heap.h:244: instantiated from ‘void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp) [with _RandomAccessIterator = Container<int>::Iterator, _Distance = int, _Tp = int]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_heap.h:392: instantiated from ‘void std::make_heap(_RAIter, _RAIter) [with _RAIter = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1557: instantiated from ‘void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:4634: instantiated from ‘void std::partial_sort(_RAIter, _RAIter, _RAIter) [with _RAIter = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1907: instantiated from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = Container<int>::Iterator, _Size = int]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:4783: instantiated from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = Container<int>::Iterator]’
prog.cpp:32: instantiated from here
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_heap.h:136: error: lvalue required as left operand of assignment
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_heap.h:140: error: lvalue required as left operand of assignment
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algobase.h: In static member function ‘static _BI2 std::__copy_move_backward<<anonymous>, <anonymous>, <template-parameter-1-3> >::__copy_move_b(_BI1, _BI1, _BI2) [with _BI1 = Container<int>::Iterator, _BI2 = Container<int>::Iterator, bool <anonymous> = false, bool <anonymous> = false, <template-parameter-1-3> = boost::detail::iterator_category_with_traversal<std::input_iterator_tag, boost::random_access_traversal_tag>]’:
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algobase.h:592: instantiated from ‘_BI2 std::__copy_move_backward_a(_BI1, _BI1, _BI2) [with bool _IsMove = false, _BI1 = Container<int>::Iterator, _BI2 = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algobase.h:602: instantiated from ‘_BI2 std::__copy_move_backward_a2(_BI1, _BI1, _BI2) [with bool _IsMove = false, _BI1 = Container<int>::Iterator, _BI2 = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algobase.h:636: instantiated from ‘_BI2 std::copy_backward(_BI1, _BI1, _BI2) [with _BI1 = Container<int>::Iterator, _BI2 = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1759: instantiated from ‘void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:1829: instantiated from ‘void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = Container<int>::Iterator]’
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algo.h:4785: instantiated from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = Container<int>::Iterator]’
prog.cpp:32: instantiated from here
/usr/lib/gcc/i686-pc-linux-gnu/4.3.4/include/g++-v4/bits/stl_algobase.h:514: error: lvalue required as left operand of assignment