Morwenn / cpp-sort

Sorting algorithms & related tools for C++14
MIT License
617 stars 57 forks source link

Revamp buffer providers #188

Open Morwenn opened 3 years ago

Morwenn commented 3 years ago

Currently the user-facing buffer providers suffer from poor decisions from the early days: they default-construct a buffer of elements, then the algorithms using buffer providers move elements to those. This design has a few issues:

I think that the right solution is to let the buffer providers allocate the storage for enough elements, but the buffered sorters should construct and destroy the elements in the buffer as needed instead of just performing moves. This would definitely be a breaking change, so it's not something to do on the branch 1.x, but rather something to plan for 2.0.0.

The new design makes the new buffer providers look awfully like allocators, but a few design differences might make them too difficult to use properly with allocators, so I don't really want to merge them unless there is a well-motivated demand for it.