00001
00002
00003
00004
00005
00006 #ifndef _CHARM_TYPE_TRAITS_H_
00007 #define _CHARM_TYPE_TRAITS_H_
00008
00009 #include <charm++.h>
00010 #include <pup.h>
00011
00012
00013 namespace charmxx {
00014
00016 template <typename T>
00017 struct is_array_proxy : std::is_base_of<CProxy_ArrayElement, T>::type {};
00018
00020 template <typename T>
00021 struct is_chare_proxy : std::is_base_of<CProxy_Chare, T>::type {};
00022
00024 template <typename T>
00025 struct is_group_proxy : std::is_base_of<CProxy_IrrGroup, T>::type {};
00026
00028 template <typename T>
00029 struct is_node_group_proxy : std::is_base_of<CProxy_NodeGroup, T>::type {};
00030
00031 namespace cpp17 {
00032
00033 #if CMK_HAS_STD_VOID_T // std::void_t is C++17
00034 using std::void_t;
00035 #else // CMK_HAS_STD_VOID_T
00036 template <typename... Ts>
00037 using void_t = void;
00038 #endif // CMK_HAS_STD_VOID_T
00039
00040 }
00041
00043 template <typename T, typename = cpp17::void_t<>>
00044 struct is_bound_array : std::false_type {};
00045
00046 template <typename T>
00047 struct is_bound_array<T, cpp17::void_t<typename T::bind_to>> : std::true_type {
00048 static_assert(charmxx::is_array_proxy<typename T::type>::value,
00049 "Can only bind a chare array");
00050 static_assert(charmxx::is_array_proxy<typename T::bind_to::type>::value,
00051 "Can only bind to a chare array");
00052 };
00053
00054 template <typename T, typename = cpp17::void_t<>>
00055 struct has_pup_member : std::false_type {};
00056
00057 template <typename T>
00058 struct has_pup_member<
00059 T, cpp17::void_t<decltype(std::declval<T>().pup(std::declval<PUP::er&>()))>>
00060 : std::true_type {};
00061
00062 template <typename T>
00063 constexpr bool has_pup_member_v = has_pup_member<T>::value;
00064
00065 template <typename T>
00066 using has_pup_member_t = typename has_pup_member<T>::type;
00067
00068 template <typename T, typename U = void>
00069 struct is_pupable : std::false_type {};
00070
00071 template <typename T>
00072 struct is_pupable<
00073 T, cpp17::void_t<decltype(std::declval<PUP::er&>() | std::declval<T&>())>>
00074 : std::true_type {};
00075
00076 template <typename T>
00077 constexpr bool is_pupable_v = is_pupable<T>::value;
00078
00079 template <typename T>
00080 using is_pupable_t = typename is_pupable<T>::type;
00081
00082 }
00083
00084 #endif //_CHARM_TYPE_TRAITS_H_