mirror of
https://github.com/libSDL2pp/libSDL2pp.git
synced 2025-08-04 03:15:59 -04:00
Added enable_if for the EventHandler templates
This commit is contained in:
parent
a52074324e
commit
ab48a57a40
@ -91,13 +91,15 @@ namespace Private {
|
||||
struct IsEventHandler<
|
||||
EventHandlerType,
|
||||
EventType,
|
||||
typename std::enable_if<
|
||||
And<
|
||||
Or<
|
||||
IsEventHandlerObject<EventHandlerType, EventType>,
|
||||
IsEventHandlerFunctor<EventHandlerType, EventType>
|
||||
>,
|
||||
TupleHasType<EventType, ValidEventTypes>
|
||||
>
|
||||
>::value
|
||||
>::type
|
||||
> : std::true_type { };
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,9 @@ namespace Private {
|
||||
struct IsEventHandlerFunctor<
|
||||
EventHandlerType,
|
||||
EventType,
|
||||
std::is_convertible<EventHandlerType, EventHandlerFunctorSignature<EventType>>
|
||||
typename std::enable_if<
|
||||
std::is_convertible<EventHandlerType, EventHandlerFunctorSignature<EventType>>::value
|
||||
>::type
|
||||
> : std::true_type { };
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,15 @@ namespace SDL2pp {
|
||||
* This is code not to be used directly by users of SDL2pp.
|
||||
*/
|
||||
namespace Private {
|
||||
/*
|
||||
* Templated class to detect if a given type can handle a given event.
|
||||
*/
|
||||
template <typename EventHandlerType, typename EventType>
|
||||
struct HasEventHandlerMethod : std::is_same<
|
||||
decltype(std::declval<EventHandlerType>().HandleEvent(std::declval<const EventType &>())),
|
||||
void
|
||||
> { };
|
||||
|
||||
/*
|
||||
* Templated class to identify a class that is not an event handler object.
|
||||
*/
|
||||
@ -45,10 +54,9 @@ namespace Private {
|
||||
struct IsEventHandlerObject<
|
||||
EventHandlerType,
|
||||
EventType,
|
||||
std::is_same<
|
||||
decltype(std::declval<EventHandlerType>().HandleEvent(std::declval<const EventType &>())),
|
||||
void
|
||||
>
|
||||
typename std::enable_if<
|
||||
HasEventHandlerMethod<EventHandlerType, EventType>::value
|
||||
>::type
|
||||
> : std::true_type { };
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user