
please wait
|
|
In function 'int main()': 16:8: error: no match for 'operator[]' (operand types are 'std::vector<Block>' and 'std::vector<Block>::iterator {aka __gnu_cxx::__normal_iterator<Block*, std::vector<Block> >}') 16:8: note: candidates are: In file included from /usr/include/c++/4.9/vector:64:0, from /usr/include/c++/4.9/bits/random.h:34, from /usr/include/c++/4.9/random:49, from /usr/include/c++/4.9/bits/stl_algo.h:66, from /usr/include/c++/4.9/algorithm:62, from 1: /usr/include/c++/4.9/bits/stl_vector.h:779:7: note: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = Block; _Alloc = std::allocator<Block>; std::vector<_Tp, _Alloc>::reference = Block&; std::vector<_Tp, _Alloc>::size_type = long unsigned int] operator[](size_type __n) _GLIBCXX_NOEXCEPT ^ /usr/include/c++/4.9/bits/stl_vector.h:779:7: note: no known conversion for argument 1 from 'std::vector<Block>::iterator {aka __gnu_cxx::__normal_iterator<Block*, std::vector<Block> >}' to 'std::vector<Block>::size_type {aka long unsigned int}' /usr/include/c++/4.9/bits/stl_vector.h:794:7: note: std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = Block; _Alloc = std::allocator<Block>; std::vector<_Tp, _Alloc>::const_reference = const Block&; std::vector<_Tp, _Alloc>::size_type = long unsigned int] operator[](size_type __n) const _GLIBCXX_NOEXCEPT ^ /usr/include/c++/4.9/bits/stl_vector.h:794:7: note: no known conversion for argument 1 from 'std::vector<Block>::iterator {aka __gnu_cxx::__normal_iterator<Block*, std::vector<Block> >}' to 'std::vector<Block>::size_type {aka long unsigned int}' In file included from /usr/include/c++/4.9/algorithm:61:0, from 1: /usr/include/c++/4.9/bits/stl_algobase.h: In instantiation of 'const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = __gnu_cxx::__normal_iterator<Block*, std::vector<Block> >; _Compare = main()::<lambda(Block, Block)>]': 15:123: required from here /usr/include/c++/4.9/bits/stl_algobase.h:264:26: error: no match for call to '(main()::<lambda(Block, Block)>) (const __gnu_cxx::__normal_iterator<Block*, std::vector<Block> >&, const __gnu_cxx::__normal_iterator<Block*, std::vector<Block> >&)' if (__comp(__a, __b)) ^ 15:76: note: candidates are: In file included from /usr/include/c++/4.9/algorithm:61:0, from 1: /usr/include/c++/4.9/bits/stl_algobase.h:264:26: note: bool (*)(Block, Block) <conversion> if (__comp(__a, __b)) ^ /usr/include/c++/4.9/bits/stl_algobase.h:264:26: note: candidate expects 3 arguments, 3 provided 15:95: note: main()::<lambda(Block, Block)> 15:95: note: no known conversion for argument 1 from 'const __gnu_cxx::__normal_iterator<Block*, std::vector<Block> >' to 'Block' |
|
|
std::max
compares two values (or values in initializer_list) and returns a value. You give two iterators and expect iterator.std::max_element
.