aboutsummaryrefslogtreecommitdiff
path: root/include/openvic-dataloader/detail/SelfType.hpp
blob: 52097005400839ae8ba0b42d9ad7b55d022da863 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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> {}))>;
}