cpp-sort
cpp-sort copied to clipboard
Container-awarer adapter and stability
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_adaptershould be able to understand astable_sortADL-found function with the same rules as the ones used to findsort. 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 forstable_sortinstead ofsort. Should we also takecontainer_aware_adapter<stable_adapter<Sorter>>into account? - SFINAE madness number 651:
container_aware_adaptershould be able to use an ADL-foundstable_sortfor an unstable sort when ADL doesn't find any suitablesortfunction in the container to sort's namespace. - When the new
is_stableis implement (see issue #75), we need to find a way to document whethercontainer_aware_adapter<Sorter>is stable when called withArgs.... It could probably be done by checking whether it finds asortfunction with ADL or whether it finds astable_sortfunction instead. New SFINAE madness incoming, but where is the fun without those?