Skip to content

Conversation

@CaseyCarter
Copy link
Contributor

@CaseyCarter CaseyCarter commented Dec 23, 2021

…ven after LWG-2774

LWG-2774 changes std::function's converting constructor to accept its argument by forwarding reference. With that change implemented, that constructor becomes a better match for non-const unique_function arguments than unique_function's const-qualified deleted conversion operator template to std::function. As a result, std::is_convertible_v<unique_function<T>, std::function<T>> changes from false to true when Standard Libraries implement LWG-2774. (MSVC recently implemented this LWG issue in microsoft/STL#2098 and noticed the unique_function test failing as a result.)

I believe the fix is to add another deleted conversion operator template that is not const-qualified to unique_function. This makes the test pass for me locally with the updated STL.

…ven after LWG-2774

[LWG-2774](https://wg21.link/lwg2774) changes `std::function`'s converting constructor to accept its argument by forwarding reference. With that change implemented, that constructor becomes a better match for non-`const` `unique_function` arguments than `unique_function`'s `const`-qualified deleted conversion operator template to `std::function`. As a result, `std::is_convertible_v<unique_function<T>, std::function<T>>` changes from `false` to `true` when Standard Libraries implement LWG-2774. (MSVC recently implemented this LWG issue in microsoft/STL#2098 and noticed the `unique_function` test failing as a result.)

I believe the fix is to add another deleted conversion operator template that is not `const`-qualified to `unique_function`. This makes the test pass locally, as well as correcting a simplified test case with GCC trunk (microsoft/STL#2098) which I believe also implements LWG-2774.
@edzh
Copy link

edzh commented Dec 31, 2021

Hi @CaseyCarter,
Thanks for making this pull request! We just need a couple of things from you to start our consideration of the PR. Can you please:

  1. Sign our Contributor's Agreement.
  2. Create a new SERVER ticket on JIRA.

Thanks!
Edwin

@CaseyCarter
Copy link
Contributor Author

  1. Sign our Contributor's Agreement.

Done!

  1. Create a new SERVER ticket on JIRA.

Also done: https://jira.mongodb.org/browse/SERVER-62498.

Do I need to link the ticket and PR somehow? I did add a link to the ticket pointing here.

@Schubes Schubes changed the title non-const unique_function should not convert to std::function e… SERVER-62498: non-const unique_function should not convert to std::function e… Jan 11, 2022
@ghost ghost closed this in 6fe4ec2 Apr 4, 2022
This pull request was closed.
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