TypeTraits.hpp
Go to the documentation of this file.
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 /// \file
5 /// Defines type traits related to Charm++ types
6 
7 #pragma once
8 
9 #include <charm++.h>
10 #include <pup.h>
11 
12 #include "Utilities/TypeTraits.hpp"
13 
14 namespace Parallel {
15 
16 /// \ingroup ParallelGroup
17 /// Check if `T` is a Charm++ proxy for an array chare
18 template <typename T>
19 struct is_array_proxy : std::is_base_of<CProxy_ArrayElement, T>::type {};
20 
21 /// \ingroup ParallelGroup
22 /// Check if `T` is a Charm++ proxy for a chare
23 template <typename T>
24 struct is_chare_proxy : std::is_base_of<CProxy_Chare, T>::type {};
25 
26 /// \ingroup ParallelGroup
27 /// Check if `T` is a Charm++ proxy for a group chare
28 template <typename T>
29 struct is_group_proxy : std::is_base_of<CProxy_IrrGroup, T>::type {};
30 
31 /// \ingroup ParallelGroup
32 /// Check if `T` is a Charm++ proxy for a node group chare
33 template <typename T>
34 struct is_node_group_proxy : std::is_base_of<CProxy_NodeGroup, T>::type {};
35 
36 /// \ingroup ParallelGroup
37 /// Check if `T` is a ParallelComponent for a Charm++ bound array
38 template <typename T, typename = cpp17::void_t<>>
40 
41 template <typename T>
42 struct is_bound_array<T, cpp17::void_t<typename T::bind_to>> : std::true_type {
44  "Can only bind an array chare");
46  "Can only bind to an array chare");
47 };
48 
49 // @{
50 /// \ingroup ParallelGroup
51 /// \brief Check if `T` has a `pup` member function
52 ///
53 /// \details
54 /// Inherits from std::true_type if the type `T` has a `pup(PUP::er&)` member
55 /// function, otherwise inherits from std::false_type
56 ///
57 /// \usage
58 /// For any type `T`,
59 /// \code
60 /// using result = tt::has_pup_member<T>;
61 /// \endcode
62 ///
63 /// \metareturns
64 /// cpp17::bool_constant
65 ///
66 /// \semantics
67 /// If the type `T` has a `pup(PUP::er&)` member function, then
68 /// \code
69 /// typename result::type = std::true_type;
70 /// \endcode
71 /// otherwise
72 /// \code
73 /// typename result::type = std::false_type;
74 /// \endcode
75 ///
76 /// \example
77 /// \snippet Parallel/Test_TypeTraits.cpp has_pup_member_example
78 /// \see is_pupable
79 /// \tparam T the type to check
80 template <typename T, typename = cpp17::void_t<>>
82 /// \cond HIDDEN_SYMBOLS
83 template <typename T>
84 struct has_pup_member<
85  T, cpp17::void_t<decltype(std::declval<T>().pup(std::declval<PUP::er&>()))>>
86  : std::true_type {};
87 /// \endcond
88 /// \see has_pup_member
89 template <typename T>
91 
92 /// \see has_pup_member
93 template <typename T>
95 // @}
96 
97 // @{
98 /// \ingroup ParallelGroup
99 /// \brief Check if type `T` has operator| defined for Charm++ serialization
100 ///
101 /// \details
102 /// Inherits from std::true_type if the type `T` has operator| defined,
103 /// otherwise inherits from std::false_type
104 ///
105 /// \usage
106 /// For any type `T`,
107 /// \code
108 /// using result = tt::is_pupable<T>;
109 /// \endcode
110 ///
111 /// \metareturns
112 /// cpp17::bool_constant
113 ///
114 /// \semantics
115 /// If the type `T` has operator| defined, then
116 /// \code
117 /// typename result::type = std::true_type;
118 /// \endcode
119 /// otherwise
120 /// \code
121 /// typename result::type = std::false_type;
122 /// \endcode
123 ///
124 /// \example
125 /// \snippet Parallel/Test_TypeTraits.cpp is_pupable_example
126 /// \see has_pup_member
127 /// \tparam T the type to check
128 template <typename T, typename U = void>
130 /// \cond HIDDEN_SYMBOLS
131 template <typename T>
132 struct is_pupable<
133  T, cpp17::void_t<decltype(std::declval<PUP::er&>() | std::declval<T&>())>>
134  : std::true_type {};
135 /// \endcond
136 /// \see is_pupable
137 template <typename T>
139 
140 /// \see is_pupable
141 template <typename T>
143 // @}
144 
145 } // namespace Parallel
Check if type T has operator| defined for Charm++ serialization.
Definition: TypeTraits.hpp:129
Check if T is a Charm++ proxy for a chare.
Definition: TypeTraits.hpp:24
void void_t
Given a set of types, returns void
Definition: TypeTraits.hpp:214
constexpr bool has_pup_member_v
Definition: TypeTraits.hpp:90
typename is_pupable< T >::type is_pupable_t
Definition: TypeTraits.hpp:142
Contains functions that forward to Charm++ parallel functions.
Definition: Abort.hpp:13
Check if T is a Charm++ proxy for a group chare.
Definition: TypeTraits.hpp:29
Check if T has a pup member function.
Definition: TypeTraits.hpp:81
Check if T is a Charm++ proxy for a node group chare.
Definition: TypeTraits.hpp:34
typename has_pup_member< T >::type has_pup_member_t
Definition: TypeTraits.hpp:94
Check if T is a Charm++ proxy for an array chare.
Definition: TypeTraits.hpp:19
C++ STL code present in C++17.
Definition: Array.hpp:16
Defines type traits, some of which are future STL type_traits header.
constexpr bool is_pupable_v
Definition: TypeTraits.hpp:138
Check if T is a ParallelComponent for a Charm++ bound array.
Definition: TypeTraits.hpp:39