Skip to content

Drop-merge sort does not work with types that are not default-constructible #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Morwenn opened this issue Jan 12, 2017 · 0 comments
Closed

Comments

@Morwenn
Copy link
Contributor

Morwenn commented Jan 12, 2017

I've got a small helper type in a sorting library of mine to check that a sorting algorithm supports the same requirements as std::sort:

  • It works with move-only types
  • It works with types that are not default-constructible
  • It even checks that it does not perform any read from a moved-from object

While your drop-merge sort does work with move-only types, it seems that it doesn't like types that are not default-constructible. When I tried to use the aforementioned type, it chocked on std::vector::resize. Apparently, dropping the resize and using a loop of equivalent pop_back in its stead is enough to make the algorithm work with types that are not default-constructible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant