IsTemplate.hpp
1 #pragma once
2 #include <cinttypes>
3 #include <type_traits>
4 
5 // Check
6 // https://stackoverflow.com/questions/39812789/is-there-any-way-of-detecting-arbitrary-template-classes-that-mix-types-and-non
7 // again with c++20
8 template <class T>
9 struct is_template : std::false_type
10 {
11 };
12 
13 template <template <class...> class T, class... Args>
14 struct is_template<T<Args...>> : std::true_type
15 {
16 };
17 
18 template <template <auto...> class T, auto... Args>
19 struct is_template<T<Args...>> : std::true_type
20 {
21 };
22 
23 template <template <class, auto, auto...> class T, class Arg1, auto Arg2, auto... Arg3>
24  requires(sizeof...(Arg3) > 0)
25 struct is_template<T<Arg1, Arg2, Arg3...>> : std::true_type
26 {
27 };
28 template <template <auto, class, class...> class T, auto Arg1, class Arg2, class... Arg3>
29  requires(sizeof...(Arg3) > 0)
30 struct is_template<T<Arg1, Arg2, Arg3...>> : std::true_type
31 {
32 };
33 
34 template <template <class, auto, class> class T, class Arg1, auto Arg2, class Arg3>
35 struct is_template<T<Arg1, Arg2, Arg3>> : std::true_type
36 {
37 };
38 
39 template <
40  template <class, auto, class, class> class T, class Arg1, auto Arg2, class Arg3,
41  class Arg4>
42 struct is_template<T<Arg1, Arg2, Arg3, Arg4>> : std::true_type
43 {
44 };
45 
46 template <
47  template <class, auto, class, class, class> class T, class Arg1, auto Arg2,
48  class Arg3, class Arg4, class Arg5>
49 struct is_template<T<Arg1, Arg2, Arg3, Arg4, Arg5>> : std::true_type
50 {
51 };
52 template <template <auto, class, auto> class T, auto Arg1, class Arg2, auto Arg3>
53 struct is_template<T<Arg1, Arg2, Arg3>> : std::true_type
54 {
55 };
56 
57 template <
58  template <class, class, class, class, auto, auto, class> class T, class A1, class A2,
59  class A3, class A4, auto A5, auto A6, class A7>
60 struct is_template<T<A1, A2, A3, A4, A5, A6, A7>> : std::true_type
61 {
62 };
63 
64 template <
65  template <class, class, class, class, class, auto, auto, class> class T, class A1,
66  class A2, class A3, class A4, class A5, auto A6, auto A7, class A8>
67 struct is_template<T<A1, A2, A3, A4, A5, A6, A7, A8>> : std::true_type
68 {
69 };
70 
71 template <template <class, auto> class T, class X, auto u>
72 struct is_template<T<X, u>> : std::true_type
73 {
74 };
75 
76 template <template <class, class, bool> class T, class A, class B, bool C>
77 struct is_template<T<A, B, C>> : std::true_type
78 {
79 };
80 
81 template <
82  template <class, class, class, class, class, class, bool> class T, class A1,
83  class A2, class A3, class A4, class A5, class A6, bool B>
84 struct is_template<T<A1, A2, A3, A4, A5, A6, B>> : std::true_type
85 {
86 };
87 
88 template <class>
89 struct is_custom_serialized : std::false_type
90 {
91 };