|
|
Compiler: Default compiler Executing g++.exe... g++.exe "H:\C++\Mergesort.cpp" -o "H:\C++\Mergesort.exe" -I"H:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"H:\Dev-Cpp\include\c++\3.4.2\backward" -I"H:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"H:\Dev-Cpp\include\c++\3.4.2" -I"H:\Dev-Cpp\include" -L"H:\Dev-Cpp\lib" H:\C++\Mergesort.cpp: In function `std::vector<VectorType, std::allocator<_CharT> > mergeSort(std::vector<VectorType, std::allocator<_CharT> >) [with VectorType = int]': H:\C++\Mergesort.cpp:94: instantiated from here H:\C++\Mergesort.cpp:13: error: no match for 'operator<=' in '(&v)->std::vector<_Tp, _Alloc>::end [with _Tp = int, _Alloc = std::allocator<int>]() <= 1' H:\C++\Mergesort.cpp:94: instantiated from here H:\C++\Mergesort.cpp:21: error: no match for 'operator=' in 'mid = (__gnu_cxx::operator- [with _IteratorL = int*, _IteratorR = int*, _Container = std::vector<int, std::allocator<int> >](((const __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >&)((const __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >*)(&(&v)->std::vector<_Tp, _Alloc>::end [with _Tp = int, _Alloc = std::allocator<int>]()))), ((const __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >&)((const __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >*)(&(&v)->std::vector<_Tp, _Alloc>::begin [with _Tp = int, _Alloc = std::allocator<int>]())))) / 2)' H:/Dev-Cpp/include/c++/3.4.2/bits/stl_iterator.h:587: note: candidates are: __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >& __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >::operator=(const __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >&) H:\C++\Mergesort.cpp: In function `std::vector<VectorType, std::allocator<_CharT> > mergeVec(std::vector<VectorType, std::allocator<_CharT> >, std::vector<VectorType, std::allocator<_CharT> >) [with VectorType = int]': H:\C++\Mergesort.cpp:34: instantiated from `std::vector<VectorType, std::allocator<_CharT> > mergeSort(std::vector<VectorType, std::allocator<_CharT> >) [with VectorType = int]' H:\C++\Mergesort.cpp:94: instantiated from here H:\C++\Mergesort.cpp:48: error: no matching function for call to `std::vector<int, std::allocator<int> >::push_back(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >)' H:/Dev-Cpp/include/c++/3.4.2/bits/stl_vector.h:557: note: candidates are: void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = int, _Alloc = std::allocator<int>] H:\C++\Mergesort.cpp:34: instantiated from `std::vector<VectorType, std::allocator<_CharT> > mergeSort(std::vector<VectorType, std::allocator<_CharT> >) [with VectorType = int]' H:\C++\Mergesort.cpp:94: instantiated from here H:\C++\Mergesort.cpp:53: error: no matching function for call to `std::vector<int, std::allocator<int> >::push_back(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >)' H:/Dev-Cpp/include/c++/3.4.2/bits/stl_vector.h:557: note: candidates are: void std::vector<_Tp, _Alloc>::push_back(const _Tp&) [with _Tp = int, _Alloc = std::allocator<int>] Execution terminated |
if ( (int)v.size() < 1) { }
|
|
(*X.begin())
|
|
if ( (int)v.size() < 1)
will never trigger, because your vector is never going to be smaller than 1.
|
|
left = mergeSort(left); // Sort left half
if ( (int)v.size() < 1)
. Changing it to if ( (int)v.size() <= 1)
fixed it. Now I just need to figure out why it merged backwards.if (left.begin() <= right.begin())
to if (*left.begin() <= *right.begin())
|
|
if (*left.begin() <= *right.begin())