Skip to content

Instantly share code, notes, and snippets.

Last active December 23, 2016 15:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
template<typename Iterator>
struct merger
using Value = typename std::iterator_traits<Iterator>::value_type;
using SortedRange = std::pair<Iterator, Iterator>;
SortedRange operator()(SortedRange const &lhs, SortedRange const &rhs) const {
assert(lhs.second == rhs.first);
std::vector<Value> tmp(lhs.first, lhs.second); //Copy the left range
std::begin(tmp), std::end(tmp), // Left container copy (source)
rhs.first, rhs.second, // Right container (source)
lhs.first); // Left container (destination)
return SortedRange(lhs.first, rhs.second);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment