LeviLamina
Loading...
Searching...
No Matches
EventRef.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5template <typename EventVariant>
6class EventRef {
7 static_assert(std::is_copy_constructible_v<EventVariant>, "EventVariant must be copy constructible");
8
9public:
10 template <typename Event>
11 EventRef(Event& event)
12 requires(!std::same_as<std::decay_t<Event>, EventRef> && std::is_const_v<Event>)
13 : variant_(std::cref(event)) {}
14
15 template <typename Event>
16 EventRef(Event& event)
17 requires(!std::same_as<std::decay_t<Event>, EventRef> && !std::is_const_v<Event>)
18 : variant_(std::ref(event)) {}
19
20 EventRef(const EventRef& other) = default;
21
22 EventVariant& get() { return variant_; }
23
24 EventVariant const& get() const { return variant_; }
25
26private:
27 EventVariant variant_;
28};
Definition EventRef.h:6