Last active
December 23, 2016 15:36
-
-
Save deque-blog/2fcff638061a979fa8f936eab0504a81 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename ForwardIterator> | |
void stable_sort_forward(ForwardIterator first, ForwardIterator last) | |
{ | |
using Range = std::pair<ForwardIterator, ForwardIterator>; | |
using Counter = binary_counter<merger<ForwardIterator>, Range>; | |
Counter c { merger<ForwardIterator>{}, { last, last } }; | |
accumulate_iter(first, last, &c, | |
[](auto c, auto it) { | |
c->add({it, std::next(it)}); | |
return c; | |
})->reduce(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment