cpp-sort icon indicating copy to clipboard operation
cpp-sort copied to clipboard

Container-awarer adapter and stability

Open Morwenn opened this issue 9 years ago • 0 comments

Issue #67 introduced the basic container_aware_adapter understanding a sort ADL-found function and added algorithms for std::list and std::forward_list with a few sorters. However, it lets a lot of questions unanswered, mainly about stability:

  • First things first: for stable sorting algorithms, container_aware_adapter should be able to understand a stable_sort ADL-found function with the same rules as the ones used to find sort. All the easy additional overloads should also be generated to properly handle comparisons, projections and the lack thereof.
  • In order to identify whether the user wants to use a stable sorting algorithm or not, we could use stable_adapter<container_aware_adapter<Sorter>>. If such a sorter is given a suitable collection to sort, it would look for stable_sort instead of sort. Should we also take container_aware_adapter<stable_adapter<Sorter>> into account?
  • SFINAE madness number 651: container_aware_adapter should be able to use an ADL-found stable_sort for an unstable sort when ADL doesn't find any suitable sort function in the container to sort's namespace.
  • When the new is_stable is implement (see issue #75), we need to find a way to document whether container_aware_adapter<Sorter> is stable when called with Args.... It could probably be done by checking whether it finds a sort function with ADL or whether it finds a stable_sort function instead. New SFINAE madness incoming, but where is the fun without those?

Morwenn avatar Jun 12 '16 10:06 Morwenn