-
Notifications
You must be signed in to change notification settings - Fork 6
convert
Alexandre Marcireau edited this page May 31, 2018
·
7 revisions
In header "../third_party/tarsier/source/convert.hpp"
tarsier::convert
maps a type to another.
namespace tarsier {
template <typename Event, typename EventToConvertedEvent, typename HandleConvertedEvent>
class convert {
public:
convert(EventToConvertedEvent event_to_converted_event, HandleConvertedEvent handle_converted_event);
/// operator() handles an event.
virtual void operator()(Event event);
};
}
-
Event
is the input type. - The expression
event_to_converted_event(event)
, whereevent
is anEvent
object andx
andy
are floats, must be valid and return a type compatible withhandle_converted_event
. - The expression
handle_converted_event(converted_event)
, whereconverted_event
is returned byevent_to_converted_event
, must be valid.
Event
must be specified when using make_convert
:
struct event {};
struct converted_event {};
auto compute_activity = tarsier::make_convert<event>(
[](event event) -> converted_event {
return {};
},
[](converted_event converted_event) {
// do something with converted_event
});