src/basics.h

changeset 354
91053052bb28
parent 339
4787d05e9c89
child 362
e1d646a4cbd8
--- a/src/basics.h	Sat Apr 08 16:12:12 2023 +0300
+++ b/src/basics.h	Sat Apr 08 16:41:40 2023 +0300
@@ -345,3 +345,14 @@
 {
 	return Message{.time = QDateTime::currentDateTime(), .type = Message::Error, .text = text};
 }
+
+template<typename BaseType, typename MemberType, typename DataType>
+struct MemberData
+{
+	std::size_t member;
+	DataType payload;
+	constexpr MemberType memberInstance(BaseType* instance) const
+	{
+		return *reinterpret_cast<MemberType*>(reinterpret_cast<char*>(instance) + this->member);
+	}
+};

mercurial