aboutsummaryrefslogtreecommitdiff
path: root/include/openvic-dataloader/detail/SelfType.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/openvic-dataloader/detail/SelfType.hpp')
-rw-r--r--include/openvic-dataloader/detail/SelfType.hpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/openvic-dataloader/detail/SelfType.hpp b/include/openvic-dataloader/detail/SelfType.hpp
new file mode 100644
index 0000000..5209700
--- /dev/null
+++ b/include/openvic-dataloader/detail/SelfType.hpp
@@ -0,0 +1,28 @@
+#pragma once
+
+#include <type_traits>
+
+namespace ovdl::detail {
+#if !defined(_MSC_VER)
+#pragma GCC diagnostic push
+#pragma clang diagnostic ignored "-Wunknown-warning-option"
+#pragma GCC diagnostic ignored "-Wnon-template-friend"
+#endif
+ template<typename T>
+ struct Reader {
+ friend auto adl_GetSelfType(Reader<T>);
+ };
+
+ template<typename T, typename U>
+ struct Writer {
+ friend auto adl_GetSelfType(Reader<T>) { return U {}; }
+ };
+#if !defined(_MSC_VER)
+#pragma GCC diagnostic pop
+#endif
+
+ inline void adl_GetSelfType() {}
+
+ template<typename T>
+ using Read = std::remove_pointer_t<decltype(adl_GetSelfType(Reader<T> {}))>;
+}