fork(1) download
  1. #include <algorithm>
  2. #include <vector>
  3.  
  4. int main() {
  5. std::vector<int> v = {3, 2, 1, 0};
  6. std::sort(v.begin(), v.end(), [](int &a, int &b) {
  7. return a < b;
  8. });
  9. return 0;
  10. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/stl_algo.h: In instantiation of ‘_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Tp = int; _Compare = main()::__lambda0]’:
/usr/include/c++/4.8/bits/stl_algo.h:2319:78:   required from ‘_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = main()::__lambda0]’
/usr/include/c++/4.8/bits/stl_algo.h:2360:62:   required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Size = int; _Compare = main()::__lambda0]’
/usr/include/c++/4.8/bits/stl_algo.h:5513:44:   required from ‘void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Compare = main()::__lambda0]’
prog.cpp:8:3:   required from here
/usr/include/c++/4.8/bits/stl_algo.h:2287:35: error: no match for call to ‘(main()::__lambda0) (int&, const int&)’
    while (__comp(*__first, __pivot))
                                   ^
prog.cpp:6:33: note: candidates are:
  std::sort(v.begin(), v.end(), [](int &a, int &b) {
                                 ^
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/stl_algo.h:2287:35: note: bool (*)(int&, int&) <conversion>
    while (__comp(*__first, __pivot))
                                   ^
/usr/include/c++/4.8/bits/stl_algo.h:2287:35: note:   candidate expects 3 arguments, 3 provided
prog.cpp:6:49: note: main()::__lambda0
  std::sort(v.begin(), v.end(), [](int &a, int &b) {
                                                 ^
prog.cpp:6:49: note:   no known conversion for argument 2 from ‘const int’ to ‘int&’
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/stl_algo.h:2290:34: error: no match for call to ‘(main()::__lambda0) (const int&, int&)’
    while (__comp(__pivot, *__last))
                                  ^
prog.cpp:6:33: note: candidates are:
  std::sort(v.begin(), v.end(), [](int &a, int &b) {
                                 ^
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/stl_algo.h:2290:34: note: bool (*)(int&, int&) <conversion>
    while (__comp(__pivot, *__last))
                                  ^
/usr/include/c++/4.8/bits/stl_algo.h:2290:34: note:   candidate expects 3 arguments, 3 provided
prog.cpp:6:49: note: main()::__lambda0
  std::sort(v.begin(), v.end(), [](int &a, int &b) {
                                                 ^
prog.cpp:6:49: note:   no known conversion for argument 1 from ‘const int’ to ‘int&’
stdout
Standard output is empty