Skip to content

Conversation

@domin144
Copy link

There were two points, where copies were made:

  1. When binding a map for use in partial.

This could be avoided, by using std::ref, but then either partial would have to handle std::ref in special way, by unwrapping the reference at the call point or the wrapped function would have to specify the accepted argument type explicitly to force cast.

Instead, partial was replaced with a compare_at_key helper struct capturing the maps by reference.

  1. When returning the value from find wrapped into optional.

This is avoided by using at_key instead of find.

There were two points, where copies were made:

1. When binding a map for use in `partial`.

This could be avoided, by using `std::ref`, but then either `partial`
would have to handle `std::ref` in special way, by unwrapping the
reference at the call point or the wrapped function would have to
specify the accepted argument type explicitly to force cast.

Instead, partial was replaced with a `compare_at_key` helper struct
capturing the `maps` by reference.

2. When returning the value from `find` wrapped into optional.

This is avoided by using `at_key` instead of `find`.
@domin144
Copy link
Author

// Check if non-copyable objects can be compared
auto map_unique_1 = hana::make_map(hana::make_pair(hana::integral_constant<int, 0>{}, std::make_unique<int>(0)));
auto map_unique_2 = hana::make_map(hana::make_pair(hana::integral_constant<int, 0>{}, std::make_unique<int>(0)));
BOOST_HANA_RUNTIME_CHECK(map_unique_1 != map_unique_2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add map_unique_1 == map_unique_1. I am not seeing that hana::equal tries to short circuit identical types (or even address).

Copy link
Author

Choose a reason for hiding this comment

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

good point.

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.

2 participants