From 6c58f4e30598d9c91cdd9e1ac1db20dbdea4ad3b Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 20 May 2021 00:08:47 +0200 Subject: [PATCH] Fix the return type constraint Apparently T is only convertible to T if it can be copy constructed. --- src/common/utils.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/common/utils.h b/src/common/utils.h index b7f8a0bf..69c86d8e 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -45,6 +45,14 @@ constexpr char product_name_override[] = "Get yabridge'd"; */ constexpr char vendor_name_override[] = "yabridge"; +/** + * The constraint is satisfied if the type is the same as `To`, or if it can be + * implicitly converted to it. The implementation of the constraint requires + * types to be copy constructable for them to be implicitly convertible. */ +template +concept same_or_convertible_to = + std::same_as || std::convertible_to; + /** * The same as the `std::invocable` concept, but also specifying the result * type. @@ -53,7 +61,7 @@ template concept invocable_returning = requires(F&& f, Result&& result, Args&&... args) { { std::invoke(std::forward(f), std::forward(args)...) - } -> std::convertible_to; + } -> same_or_convertible_to; }; // The cannonical overloading template for `std::visitor`, not sure why this