Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace improper static_variant operator overloads with comparators #154

Merged
merged 2 commits into from
Aug 30, 2019

Conversation

nathanielhourt
Copy link

static_variant provided operator overloads for == and < which compared only the types and not the values. This was used to make it easier to place static_variant types into flat_sets, but it constitutes a dangerous abuse of C++ operator overloading as code could accidentally be written using these operators and expecting them to be correctly implemented. Such code would be invisibly wrong. Removing these overloads eliminates this risk.

This commit removes the overloads and replaces them with comparator structs, and also provides a convenient type alias for a flat_set of static_variant types.

Requisite changes in BitShares are visible here and will be PReq'd after this is merged.

@abitmore abitmore added this to the core release 4.1.0 milestone Aug 28, 2019
tests/variant_test.cpp Outdated Show resolved Hide resolved
tests/variant_test.cpp Outdated Show resolved Hide resolved
include/fc/reflect/typename.hpp Outdated Show resolved Hide resolved
Copy link

@pmconrad pmconrad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, thanks!

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.

3 participants