Fix the return type constraint

Apparently T is only convertible to T if it can be copy constructed.
This commit is contained in:
Robbert van der Helm
2021-05-20 00:08:47 +02:00
parent 35cc47d021
commit 6c58f4e305
+9 -1
View File
@@ -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 <typename From, typename To>
concept same_or_convertible_to =
std::same_as<From, To> || std::convertible_to<From, To>;
/**
* The same as the `std::invocable` concept, but also specifying the result
* type.
@@ -53,7 +61,7 @@ template <typename F, typename Result, typename... Args>
concept invocable_returning = requires(F&& f, Result&& result, Args&&... args) {
{
std::invoke(std::forward<F>(f), std::forward<Args>(args)...)
} -> std::convertible_to<Result>;
} -> same_or_convertible_to<Result>;
};
// The cannonical overloading template for `std::visitor`, not sure why this