microsoft / microsoft/STL

<algorithm>: Should push_heap() tolerate empty ranges?

Open
#280 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C++
Stars
11.1k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

https://eel.is/c++draft/push.heap#2 "Requires: The range [first, last - 1) shall be a valid heap with respect to comp and proj."

Our implementation is a no-op for empty ranges:

https://github.com/microsoft/STL/blob/f9b1dccd121b5f8bb76d06adb0c85aac3f766326/stl/inc/algorithm#L2592-L2604

Is there an algorithm precondition here?

(Standardese citations as of WG21-N4835.)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the cited [push.heap] wording in WG21-N4835 and the implementation at stl/inc/algorithm lines 2592-2604. Determine whether the empty-range behavior violates an algorithm precondition or should be specified, then identify the implementation or standard-conformance change needed. Done means the precondition question is resolved and the behavior is covered accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.