#include <vector>
#include <algorithm>
struct MyClass
{
int a;
int b;
bool operator < (const MyClass& other){return other.a < a;}
};
typedef std::vector<MyClass> MyVector;
int main()
{
MyVector test;
const MyVector& stupidError = test;
std::sort(stupidError.begin(), stupidError.end());
return 0;
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGFsZ29yaXRobT4KCnN0cnVjdCBNeUNsYXNzCnsKICAgIGludCBhOwoJaW50IGI7Cglib29sIG9wZXJhdG9yIDwgKGNvbnN0IE15Q2xhc3MmIG90aGVyKXtyZXR1cm4gb3RoZXIuYSA8IGE7fSAKfTsKCnR5cGVkZWYgc3RkOjp2ZWN0b3I8TXlDbGFzcz4gTXlWZWN0b3I7CgppbnQgbWFpbigpCnsKCU15VmVjdG9yIHRlc3Q7Cgljb25zdCBNeVZlY3RvciYgc3R1cGlkRXJyb3IgPSB0ZXN0OwoJc3RkOjpzb3J0KHN0dXBpZEVycm9yLmJlZ2luKCksIHN0dXBpZEVycm9yLmVuZCgpKTsKCXJldHVybiAwOwp9
In file included from /usr/include/c++/4.8/algorithm:62:0,
from prog.cpp:2:
/usr/include/c++/4.8/bits/stl_algo.h: In instantiation of ‘void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >]’:
/usr/include/c++/4.8/bits/stl_algo.h:2235:62: required from ‘void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >]’
/usr/include/c++/4.8/bits/stl_algo.h:5476:47: required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >]’
prog.cpp:17:50: required from here
/usr/include/c++/4.8/bits/stl_algo.h:2161:13: error: passing ‘const MyClass’ as ‘this’ argument of ‘bool MyClass::operator<(const MyClass&)’ discards qualifiers [-fpermissive]
if (*__i < *__first)
^
/usr/include/c++/4.8/bits/stl_algo.h:2166:17: error: passing ‘const MyClass’ as ‘this’ argument of ‘MyClass& MyClass::operator=(MyClass&&)’ discards qualifiers [-fpermissive]
*__first = _GLIBCXX_MOVE(__val);
^
/usr/include/c++/4.8/bits/stl_algo.h: In instantiation of ‘void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >]’:
/usr/include/c++/4.8/bits/stl_algo.h:5322:51: required from ‘void std::partial_sort(_RAIter, _RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >]’
/usr/include/c++/4.8/bits/stl_algo.h:2333:60: required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >; _Size = int]’
/usr/include/c++/4.8/bits/stl_algo.h:5475:36: required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >]’
prog.cpp:17:50: required from here
/usr/include/c++/4.8/bits/stl_algo.h:1959:11: error: passing ‘const MyClass’ as ‘this’ argument of ‘bool MyClass::operator<(const MyClass&)’ discards qualifiers [-fpermissive]
if (*__i < *__first)
^
/usr/include/c++/4.8/bits/stl_algo.h: In instantiation of ‘void std::__move_median_first(_Iterator, _Iterator, _Iterator) [with _Iterator = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >]’:
/usr/include/c++/4.8/bits/stl_algo.h:2306:60: required from ‘_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >]’
/usr/include/c++/4.8/bits/stl_algo.h:2338:54: required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >; _Size = int]’
/usr/include/c++/4.8/bits/stl_algo.h:5475:36: required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >]’
prog.cpp:17:50: required from here
/usr/include/c++/4.8/bits/stl_algo.h:84:16: error: passing ‘const MyClass’ as ‘this’ argument of ‘bool MyClass::operator<(const MyClass&)’ discards qualifiers [-fpermissive]
if (*__a < *__b)
^
/usr/include/c++/4.8/bits/stl_algo.h:86:13: error: passing ‘const MyClass’ as ‘this’ argument of ‘bool MyClass::operator<(const MyClass&)’ discards qualifiers [-fpermissive]
if (*__b < *__c)
^
/usr/include/c++/4.8/bits/stl_algo.h:88:18: error: passing ‘const MyClass’ as ‘this’ argument of ‘bool MyClass::operator<(const MyClass&)’ discards qualifiers [-fpermissive]
else if (*__a < *__c)
^
/usr/include/c++/4.8/bits/stl_algo.h:91:21: error: passing ‘const MyClass’ as ‘this’ argument of ‘bool MyClass::operator<(const MyClass&)’ discards qualifiers [-fpermissive]
else if (*__a < *__c)
^
/usr/include/c++/4.8/bits/stl_algo.h:93:21: error: passing ‘const MyClass’ as ‘this’ argument of ‘bool MyClass::operator<(const MyClass&)’ discards qualifiers [-fpermissive]
else if (*__b < *__c)
^
/usr/include/c++/4.8/bits/stl_algo.h: In instantiation of ‘_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >; _Tp = MyClass]’:
/usr/include/c++/4.8/bits/stl_algo.h:2307:70: required from ‘_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >]’
/usr/include/c++/4.8/bits/stl_algo.h:2338:54: required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >; _Size = int]’
/usr/include/c++/4.8/bits/stl_algo.h:5475:36: required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >]’
prog.cpp:17:50: required from here
/usr/include/c++/4.8/bits/stl_algo.h:2266:20: error: passing ‘const MyClass’ as ‘this’ argument of ‘bool MyClass::operator<(const MyClass&)’ discards qualifiers [-fpermissive]
while (*__first < __pivot)
^
/usr/include/c++/4.8/bits/stl_algo.h:2269:19: error: passing ‘const MyClass’ as ‘this’ argument of ‘bool MyClass::operator<(const MyClass&)’ discards qualifiers [-fpermissive]
while (__pivot < *__last)
^
In file included from /usr/include/c++/4.8/bits/stl_algo.h:61:0,
from /usr/include/c++/4.8/algorithm:62,
from prog.cpp:2:
/usr/include/c++/4.8/bits/stl_heap.h: In instantiation of ‘void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >; _Distance = int; _Tp = MyClass]’:
/usr/include/c++/4.8/bits/stl_heap.h:407:71: required from ‘void std::make_heap(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >]’
/usr/include/c++/4.8/bits/stl_algo.h:1957:39: required from ‘void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >]’
/usr/include/c++/4.8/bits/stl_algo.h:5322:51: required from ‘void std::partial_sort(_RAIter, _RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >]’
/usr/include/c++/4.8/bits/stl_algo.h:2333:60: required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >; _Size = int]’
/usr/include/c++/4.8/bits/stl_algo.h:5475:36: required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const MyClass*, std::vector<MyClass> >]’
prog.cpp:17:50: required from here
/usr/include/c++/4.8/bits/stl_heap.h:235:35: error: passing ‘const MyClass’ as ‘this’ argument of ‘bool MyClass::operator<(const MyClass&)’ discards qualifiers [-fpermissive]
if (*(__first + __secondChild) < *(__first + (__secondChild - 1)))
^
/usr/include/c++/4.8/bits/stl_heap.h:237:29: error: passing ‘const MyClass’ as ‘this’ argument of ‘MyClass& MyClass::operator=(const MyClass&)’ discards qualifiers [-fpermissive]
*(__first + __holeIndex) = _GLIBCXX_MOVE(*(__first + __secondChild));
^
/usr/include/c++/4.8/bits/stl_heap.h:243:29: error: passing ‘const MyClass’ as ‘this’ argument of ‘MyClass& MyClass::operator=(const MyClass&)’ discards qualifiers [-fpermissive]
*(__first + __holeIndex) = _GLIBCXX_MOVE(*(__first
^