Created
May 31, 2019 15:12
-
-
Save Morwenn/b1d7583d0d52e58bdab8ace7969da15a to your computer and use it in GitHub Desktop.
Try to take advantage of the stable nature of insertion sort
This file contains 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 BidirectionalIterator, typename Compare, typename Projection> | |
auto insertion_sort(BidirectionalIterator first, BidirectionalIterator last, | |
stable_compare<Compare, Projection> compare, utility::identity) | |
-> void | |
{ | |
auto projection = compare.projection(); | |
cppsort::detail::insertion_sort( | |
first, last, compare.compare(), | |
[projection](auto&& value) mutable -> decltype(auto) { | |
return projection(std::forward<decltype(value)>(value).get()); | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment