mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Add a concept for invocables with a return type
Because for some reason this is not part of the standard library.
This commit is contained in:
@@ -45,6 +45,17 @@ constexpr char product_name_override[] = "Get yabridge'd";
|
|||||||
*/
|
*/
|
||||||
constexpr char vendor_name_override[] = "yabridge";
|
constexpr char vendor_name_override[] = "yabridge";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The same as the `std::invocable` concept, but also specifying the result
|
||||||
|
* type.
|
||||||
|
*/
|
||||||
|
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>;
|
||||||
|
};
|
||||||
|
|
||||||
// The cannonical overloading template for `std::visitor`, not sure why this
|
// The cannonical overloading template for `std::visitor`, not sure why this
|
||||||
// isn't part of the standard library
|
// isn't part of the standard library
|
||||||
template <class... Ts>
|
template <class... Ts>
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ class MainContext {
|
|||||||
* that will cause them to stall indefinitely in this situation, but who
|
* that will cause them to stall indefinitely in this situation, but who
|
||||||
* knows which other plugins exert similar behaviour.
|
* knows which other plugins exert similar behaviour.
|
||||||
*/
|
*/
|
||||||
template <typename F, typename P>
|
template <std::invocable F, invocable_returning<bool> P>
|
||||||
void async_handle_events(F handler, P predicate) {
|
void async_handle_events(F handler, P predicate) {
|
||||||
// Try to keep a steady framerate, but add in delays to let other events
|
// Try to keep a steady framerate, but add in delays to let other events
|
||||||
// get handled if the GUI message handling somehow takes very long.
|
// get handled if the GUI message handling somehow takes very long.
|
||||||
|
|||||||
Reference in New Issue
Block a user