summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCasey Carter <cacarter@microsoft.com>2021-12-23 14:56:59 -0800
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-04-04 21:09:18 +0000
commit6fe4ec2625b638abb709a002c765d23cfe9e4fd6 (patch)
tree989cd657d9f063be911998230777cb19286a76d9
parentc911a489290153d7154dfc9fbe85c1739e7d4e19 (diff)
downloadmongo-6fe4ec2625b638abb709a002c765d23cfe9e4fd6.tar.gz
SERVER-62498 Non-`const` `unique_function` should not convert to `std::function` even 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 https://github.com/microsoft/STL/pull/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 (https://github.com/microsoft/STL/pull/2098) which I believe also implements LWG-2774. Closes https://github.com/mongodb/mongo/pull/1437 Signed-off-by: Blake Oler <blake.oler@mongodb.com> and Billy Donahue <billy.donahue@mongodb.com>
-rw-r--r--src/mongo/util/functional.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/mongo/util/functional.h b/src/mongo/util/functional.h
index 9f353343b69..a680e54a266 100644
--- a/src/mongo/util/functional.h
+++ b/src/mongo/util/functional.h
@@ -231,6 +231,8 @@ public:
// NOTE: This is not quite able to disable all `std::function` conversions on MSVC, at this
// time.
template <typename Signature>
+ operator std::function<Signature>() = delete;
+ template <typename Signature>
operator std::function<Signature>() const = delete;
private: