C++ Logo


Advanced search

Re: [std-proposals] Introduction of std::is_uniqued()

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Sat, 15 Apr 2023 22:07:12 -0400
On Fri, Apr 14, 2023 at 6:19 PM Jonathan Wakely via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Fri, 14 Apr 2023, 17:02 LoS via Std-Proposals, <
> std-proposals_at_[hidden]> wrote:
>> As suggested in a reply to my previous proposal, I drafted a proposal to
>> introduce the std::is_uniqued() function.
> I feel somebody should point out that uniqued is not a word.

Technically correct <https://scrabble.merriam.com/finder/uniqued>, the best
kind of correct. :)

On Sat, Apr 15, 2023 at 6:32 AM LoS wrote:

> @Jonathan, probably you are right.
> However, I thought the name was not a bad idea since there is already the
> following algorithm:
> https://swiftinit.org/reference/swift/sequence.uniqued%28%29?from=swift-algorithms

That's useful prior art for the verb (besides the prior art in C++ and Unix
<https://linux.die.net/man/1/uniq>). Do note that Swift's notion of
"uniqued" is "contains *no* duplicates," whereas C++'s and
Unix's is "contains no *adjacent* duplicates." This could be confusing; but
I think the existence of the `std::unique` algorithm in C++ makes it pretty
easy to remember (and teach) what `is_uniqued` means.
- `std::sort` sorts an array and makes it sorted, such that it `is_sorted`.
- `std::unique` uniques an array and makes it uniqued, such that it
The odd one out is `std::make_heap` (`make_unique` was taken ;)) and
`is_heap` — that pair of algorithms could better have been named `heapify`
and `is_heapified`.

I've put up a draft revision of D2848R0 "std::is_uniqued" here
<https://quuxplusone.github.io/draft/d2848-std-is-uniqued.html>. Comments
welcome. (Also pull requests
<https://github.com/Quuxplusone/llvm-project/pulls>, if anyone wants to
beat me to a libc++ implementation. I don't plan to work on that for the
next 12 hours at least.)


Received on 2023-04-16 02:07:25