Skip to content

Add Cpp17EqualityComparable - #704

Open
lucic71 wants to merge 17 commits into
Cpp2Rust:masterfrom
lucic71:remove-ord-trait
Open

lucic71 wants to merge 17 commits into
Cpp2Rust:masterfrom
lucic71:remove-ord-trait

Conversation

@lucic71

@lucic71 lucic71 commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

std::sort, std::find, etc, only require Cpp17EqualityComparable, i.e. T == U. The EqualityComparable trait that we have in master is stronger than that, it also requires T != U which is not needed in std::sort, std::find, etc.

Also, for the comparison traits, ask sema if a cmp b is a valid expression. This is needed for struct S { operator int(); } which does not have any operator< for example, but can be compared through int(S{}) < int(S{}) by something like std::sort.


Added BooleanTestable which is a marker trait over ConvertibleTo<T, bool>. Comparison traits now return BooleanTestable and return in passed storage because the BooleanTestable might possibly be non-trivially-copyable.

std::sort and other algorithm functions use a shorter version that does not need BooleanTestable because by the standard they always use bool instead of BooleanTestable.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant