Created on 2026-05-24.00:00:00 last changed 1 week ago
Proposed resolution:
This wording is relative to N5046.
Modify [hive.operations] as indicated:
template<class Compare = less<T>> void sort(Compare comp = Compare());-13- Preconditions: `T` is Cpp17MoveInsertable into `hive`, Cpp17MoveConstructible, Cpp17MoveAssignable, and Cpp17Swappable.
-14- Effects: Sorts `*this` according to the `comp` function object. If an exception is thrown, the order of the elements in `*this` is unspecified. […]
`std::hive::sort` ([hive.operations]) requires that `T` be Cpp17MoveInsertable into `hive`, Cpp17MoveAssignable, and Cpp17Swappable. It does not require `T` to be Cpp17MoveConstructible, which is a prerequisite for the internal use of `std::sort` by the implementation. Note that, in general, Cpp17MoveInsertable into `hive` (or any container) does not imply Cpp17MoveConstructible. Both the de facto reference implementation for `std::hive` (Matthew Bentley's plf::hive) and the ongoing implementation for VS use `std::sort` directly on `T`.
Strictly speaking, the lack of this precondition can be salvaged by invoking `std::sort` on a range of values of type `X`, where `X` is an ad-hoc type wrapping a `T` value and an allocator object which implements move construction in terms of std::allocator_traits<A>::construct. So, even if this issue is resolved as NAD, that would be informative for standard library implementors so that they can potentially fix their code.| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2026-05-24 14:35:26 | admin | set | messages: + msg16326 |
| 2026-05-24 00:00:00 | admin | create | |