Have two vectors: std::vector<int> collA{2,4,6,3,5,7} & std::vector<int> collB(collA.size()), and I am trying to merge left half of collA(contains even numbers) with right side of collA(contains odd numbers) into collB:
std::merge(collA.cbegin(), std::next(collA.cbegin(), collA.size()/2 + 1), // left source std::next(collA.cbegin(), collA.size()/2), collA.cend(), // right source collB.begin()); // Output However, std::merge() fails somewhere and Visual Studio 2012 gives me following error:
--------------------------- Microsoft Visual C++ Runtime Library --------------------------- Debug Assertion Failed! Program: C:\Windows\system32\MSVCP110D.dll File: c:\program files (x86)\microsoft visual studio 11.0\vc\include\algorithm Line: 3102 Expression: sequence not ordered For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts. Both Input ranges are sorted, so why am I getting this error ? (Note: VS2012 does not support C++11 initializer list syntax, I used to save some space)