mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Fix the return type constraint
Apparently T is only convertible to T if it can be copy constructed.
This commit is contained in:
+9
-1
@@ -45,6 +45,14 @@ constexpr char product_name_override[] = "Get yabridge'd";
|
|||||||
*/
|
*/
|
||||||
constexpr char vendor_name_override[] = "yabridge";
|
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
|
* The same as the `std::invocable` concept, but also specifying the result
|
||||||
* type.
|
* type.
|
||||||
@@ -53,7 +61,7 @@ template <typename F, typename Result, typename... Args>
|
|||||||
concept invocable_returning = requires(F&& f, Result&& result, Args&&... args) {
|
concept invocable_returning = requires(F&& f, Result&& result, Args&&... args) {
|
||||||
{
|
{
|
||||||
std::invoke(std::forward<F>(f), std::forward<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
|
// The cannonical overloading template for `std::visitor`, not sure why this
|
||||||
|
|||||||
Reference in New Issue
Block a user