Date: Tue, 13 Feb 2024 17:28:13 +0100
The return type of std::push_heap is void, but std::ranges::push_heap
returns an iterator to the last element.
This was introduced by P0896, but it merely states what must be returned
without giving a rationale. Does anybody know why?
I am asking because it would have been more useful to return an iterator
to the position of the pushed element (after the operation.)
For example, we could easily extend std::priority_queue::emplace() to
return a reference to the created element -- to be consistent with P0084
accepted in C++17 -- if std::push_heap is extended to return the
iterator to the inserted element. However, that would make it
inconsistent with std::ranges::push_heap.
returns an iterator to the last element.
This was introduced by P0896, but it merely states what must be returned
without giving a rationale. Does anybody know why?
I am asking because it would have been more useful to return an iterator
to the position of the pushed element (after the operation.)
For example, we could easily extend std::priority_queue::emplace() to
return a reference to the created element -- to be consistent with P0084
accepted in C++17 -- if std::push_heap is extended to return the
iterator to the inserted element. However, that would make it
inconsistent with std::ranges::push_heap.
Received on 2024-02-13 16:28:16