11#include "type_list.hpp"
65template <
typename... Events>
67 static_assert(
sizeof...(Events) > 0,
68 "variant_event cannot have empty EventList");
70 using base_type = std::variant<Events...>;
71 using base_type::base_type;
73 friend auto operator<<(std::ostream &stream,
variant_event const &event)
75 requires(internal::ostreamable<Events> && ...)
78 [&](
auto const &e) -> std::ostream & {
return stream << e; },
87template <
typename EventList>
88struct variant_or_single_event_impl
89 : std::type_identity<variant_event<EventList>> {};
91template <
typename Event>
92struct variant_or_single_event_impl<type_list<Event>>
93 : std::type_identity<Event> {};
107template <
typename EventList>
130template <
typename Visitor,
typename Event>
132 return visitor(std::forward<Event>(event));
140template <
typename Visitor,
typename EventList>
144 return std::visit(std::forward<Visitor>(visitor), std::move(event));
152template <
typename Visitor,
typename EventList>
156 return std::visit(std::forward<Visitor>(visitor), event);
164template <
typename Visitor,
typename EventList>
167 return std::visit(std::forward<Visitor>(visitor), event);
Variant event.
Definition variant_event.hpp:61
internal::variant_or_single_event_impl< unique_type_list_t< EventList > >::type variant_or_single_event
Select the plain event if single, otherwise tcspc::variant_event.
Definition variant_event.hpp:108
unique_type_list< TypeList >::type unique_type_list_t
Helper type for tcspc::unique_type_list.
Definition type_list.hpp:335
constexpr auto visit_variant_or_single_event(Visitor visitor, Event &&event)
Apply a visitor to an event that is not a tcspc::variant_event.
Definition variant_event.hpp:131
libtcspc namespace.
Definition acquire.hpp:30
Compile-time representation of a list of types.
Definition type_list.hpp:38