Skip to content

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

@Morwenn

Description

@Morwenn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions