Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 1 | // Copyright 2019 The SwiftShader Authors. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #ifndef rr_Traits_hpp |
| 16 | #define rr_Traits_hpp |
| 17 | |
| 18 | #include <stdint.h> |
| 19 | #include <type_traits> |
| 20 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 21 | namespace rr { |
| 22 | |
| 23 | // Forward declarations |
| 24 | class Value; |
| 25 | |
| 26 | class Void; |
| 27 | class Bool; |
| 28 | class Byte; |
| 29 | class SByte; |
| 30 | class Short; |
| 31 | class UShort; |
| 32 | class Int; |
| 33 | class UInt; |
| 34 | class Long; |
| 35 | class Half; |
| 36 | class Float; |
| 37 | class Float4; |
| 38 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 39 | template<class T> |
| 40 | class Pointer; |
| 41 | template<class T> |
| 42 | class LValue; |
| 43 | template<class T> |
| 44 | class RValue; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 45 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 46 | // IsDefined<T>::value is true if T is a valid type, otherwise false. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 47 | template<typename T, typename Enable = void> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 48 | struct IsDefined |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 49 | { |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 50 | static constexpr bool value = false; |
| 51 | }; |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 52 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 53 | template<typename T> |
Ben Clayton | 316f0cb | 2020-01-08 23:12:14 +0000 | [diff] [blame] | 54 | struct IsDefined<T, std::enable_if_t<(sizeof(T) > 0)>> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 55 | { |
| 56 | static constexpr bool value = true; |
| 57 | }; |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 58 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 59 | template<> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 60 | struct IsDefined<void> |
| 61 | { |
| 62 | static constexpr bool value = true; |
| 63 | }; |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 64 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 65 | // CToReactorT<T> resolves to the corresponding Reactor type for the given C |
| 66 | // template type T. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 67 | template<typename T, typename ENABLE = void> |
| 68 | struct CToReactor; |
| 69 | template<typename T> |
| 70 | using CToReactorT = typename CToReactor<T>::type; |
Ben Clayton | 663dcef | 2019-11-26 11:01:48 +0000 | [diff] [blame] | 71 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 72 | // CToReactor specializations for POD types. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 73 | template<> |
| 74 | struct CToReactor<void> |
| 75 | { |
| 76 | using type = Void; |
| 77 | }; |
| 78 | template<> |
| 79 | struct CToReactor<bool> |
| 80 | { |
| 81 | using type = Bool; |
| 82 | static Bool cast(bool); |
| 83 | }; |
| 84 | template<> |
| 85 | struct CToReactor<uint8_t> |
| 86 | { |
| 87 | using type = Byte; |
| 88 | static Byte cast(uint8_t); |
| 89 | }; |
| 90 | template<> |
| 91 | struct CToReactor<int8_t> |
| 92 | { |
| 93 | using type = SByte; |
| 94 | static SByte cast(int8_t); |
| 95 | }; |
| 96 | template<> |
| 97 | struct CToReactor<int16_t> |
| 98 | { |
| 99 | using type = Short; |
| 100 | static Short cast(int16_t); |
| 101 | }; |
| 102 | template<> |
| 103 | struct CToReactor<uint16_t> |
| 104 | { |
| 105 | using type = UShort; |
| 106 | static UShort cast(uint16_t); |
| 107 | }; |
| 108 | template<> |
| 109 | struct CToReactor<int32_t> |
| 110 | { |
| 111 | using type = Int; |
| 112 | static Int cast(int32_t); |
| 113 | }; |
| 114 | template<> |
| 115 | struct CToReactor<uint32_t> |
| 116 | { |
| 117 | using type = UInt; |
| 118 | static UInt cast(uint32_t); |
| 119 | }; |
| 120 | template<> |
| 121 | struct CToReactor<float> |
| 122 | { |
| 123 | using type = Float; |
| 124 | static Float cast(float); |
| 125 | }; |
| 126 | template<> |
| 127 | struct CToReactor<float[4]> |
| 128 | { |
| 129 | using type = Float4; |
| 130 | static Float4 cast(float[4]); |
| 131 | }; |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 132 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 133 | // TODO: Long has no constructor that takes a uint64_t |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 134 | template<> |
| 135 | struct CToReactor<uint64_t> |
| 136 | { |
| 137 | using type = Long; /* static Long cast(uint64_t); */ |
| 138 | }; |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 139 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 140 | // HasReactorType<T>::value resolves to true iff there exists a |
| 141 | // CToReactorT specialization for type T. |
| 142 | template<typename T> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 143 | using HasReactorType = IsDefined<CToReactorT<T>>; |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 144 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 145 | // CToReactorPtr<T>::type resolves to the corresponding Reactor Pointer<> |
| 146 | // type for T*. |
| 147 | // For T types that have a CToReactorT<> specialization, |
| 148 | // CToReactorPtr<T>::type resolves to Pointer< CToReactorT<T> >, otherwise |
| 149 | // CToReactorPtr<T>::type resolves to Pointer<Byte>. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 150 | template<typename T, typename ENABLE = void> |
| 151 | struct CToReactorPtr |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 152 | { |
| 153 | using type = Pointer<Byte>; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 154 | static inline type cast(const T *v); // implemented in Traits.inl |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 155 | }; |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 156 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 157 | // CToReactorPtr specialization for T types that have a CToReactorT<> |
| 158 | // specialization. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 159 | template<typename T> |
Ben Clayton | 316f0cb | 2020-01-08 23:12:14 +0000 | [diff] [blame] | 160 | struct CToReactorPtr<T, std::enable_if_t<HasReactorType<T>::value>> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 161 | { |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 162 | using type = Pointer<CToReactorT<T>>; |
| 163 | static inline type cast(const T *v); // implemented in Traits.inl |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 164 | }; |
Ben Clayton | 51f0831 | 2019-11-08 14:39:26 +0000 | [diff] [blame] | 165 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 166 | // CToReactorPtr specialization for void*. |
| 167 | // Maps to Pointer<Byte> instead of Pointer<Void>. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 168 | template<> |
| 169 | struct CToReactorPtr<void, void> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 170 | { |
| 171 | using type = Pointer<Byte>; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 172 | static inline type cast(const void *v); // implemented in Traits.inl |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 173 | }; |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 174 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 175 | // CToReactorPtr specialization for function pointer types. |
| 176 | // Maps to Pointer<Byte>. |
| 177 | // Drops the 'const' qualifier from the cast() method to avoid warnings |
| 178 | // about const having no meaning for function types. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 179 | template<typename T> |
Ben Clayton | 316f0cb | 2020-01-08 23:12:14 +0000 | [diff] [blame] | 180 | struct CToReactorPtr<T, std::enable_if_t<std::is_function<T>::value>> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 181 | { |
| 182 | using type = Pointer<Byte>; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 183 | static inline type cast(T *v); // implemented in Traits.inl |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 184 | }; |
Ben Clayton | 663dcef | 2019-11-26 11:01:48 +0000 | [diff] [blame] | 185 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 186 | template<typename T> |
| 187 | using CToReactorPtrT = typename CToReactorPtr<T>::type; |
Ben Clayton | a9f511b | 2019-11-18 22:18:48 +0000 | [diff] [blame] | 188 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 189 | // CToReactor specialization for pointer types. |
| 190 | // For T types that have a CToReactorT<> specialization, |
| 191 | // CToReactorT<T*>::type resolves to Pointer< CToReactorT<T> >, otherwise |
| 192 | // CToReactorT<T*>::type resolves to Pointer<Byte>. |
| 193 | template<typename T> |
Ben Clayton | 316f0cb | 2020-01-08 23:12:14 +0000 | [diff] [blame] | 194 | struct CToReactor<T, std::enable_if_t<std::is_pointer<T>::value>> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 195 | { |
| 196 | using elem = typename std::remove_pointer<T>::type; |
| 197 | using type = CToReactorPtrT<elem>; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 198 | static inline type cast(T v); // implemented in Traits.inl |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 199 | }; |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 200 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 201 | // CToReactor specialization for enum types. |
| 202 | template<typename T> |
Ben Clayton | 316f0cb | 2020-01-08 23:12:14 +0000 | [diff] [blame] | 203 | struct CToReactor<T, std::enable_if_t<std::is_enum<T>::value>> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 204 | { |
| 205 | using underlying = typename std::underlying_type<T>::type; |
| 206 | using type = CToReactorT<underlying>; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 207 | static type cast(T v); // implemented in Traits.inl |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 208 | }; |
Ben Clayton | a9f511b | 2019-11-18 22:18:48 +0000 | [diff] [blame] | 209 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 210 | // IsRValue::value is true if T is of type RValue<X>, where X is any type. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 211 | template<typename T, typename Enable = void> |
| 212 | struct IsRValue |
| 213 | { |
| 214 | static constexpr bool value = false; |
| 215 | }; |
| 216 | template<typename T> |
Ben Clayton | 316f0cb | 2020-01-08 23:12:14 +0000 | [diff] [blame] | 217 | struct IsRValue<T, std::enable_if_t<IsDefined<typename T::rvalue_underlying_type>::value>> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 218 | { |
| 219 | static constexpr bool value = true; |
| 220 | }; |
Ben Clayton | a9f511b | 2019-11-18 22:18:48 +0000 | [diff] [blame] | 221 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 222 | // IsLValue::value is true if T is of, or derives from type LValue<T>. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 223 | template<typename T> |
| 224 | struct IsLValue |
| 225 | { |
| 226 | static constexpr bool value = std::is_base_of<LValue<T>, T>::value; |
| 227 | }; |
Ben Clayton | a9f511b | 2019-11-18 22:18:48 +0000 | [diff] [blame] | 228 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 229 | // IsReference::value is true if T is of type Reference<X>, where X is any type. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 230 | template<typename T, typename Enable = void> |
| 231 | struct IsReference |
| 232 | { |
| 233 | static constexpr bool value = false; |
| 234 | }; |
| 235 | template<typename T> |
Ben Clayton | 316f0cb | 2020-01-08 23:12:14 +0000 | [diff] [blame] | 236 | struct IsReference<T, std::enable_if_t<IsDefined<typename T::reference_underlying_type>::value>> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 237 | { |
| 238 | static constexpr bool value = true; |
| 239 | }; |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 240 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 241 | // ReactorTypeT<T> returns the LValue Reactor type for T. |
| 242 | // T can be a C-type, RValue or LValue. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 243 | template<typename T, typename ENABLE = void> |
| 244 | struct ReactorType; |
| 245 | template<typename T> |
| 246 | using ReactorTypeT = typename ReactorType<T>::type; |
| 247 | template<typename T> |
Ben Clayton | 316f0cb | 2020-01-08 23:12:14 +0000 | [diff] [blame] | 248 | struct ReactorType<T, std::enable_if_t<IsDefined<CToReactorT<T>>::value>> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 249 | { |
| 250 | using type = CToReactorT<T>; |
| 251 | static type cast(T v) { return CToReactor<T>::cast(v); } |
| 252 | }; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 253 | template<typename T> |
Ben Clayton | 316f0cb | 2020-01-08 23:12:14 +0000 | [diff] [blame] | 254 | struct ReactorType<T, std::enable_if_t<IsRValue<T>::value>> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 255 | { |
| 256 | using type = typename T::rvalue_underlying_type; |
| 257 | static type cast(T v) { return type(v); } |
| 258 | }; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 259 | template<typename T> |
Ben Clayton | 316f0cb | 2020-01-08 23:12:14 +0000 | [diff] [blame] | 260 | struct ReactorType<T, std::enable_if_t<IsLValue<T>::value>> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 261 | { |
| 262 | using type = T; |
| 263 | static type cast(T v) { return type(v); } |
| 264 | }; |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 265 | template<typename T> |
Ben Clayton | 316f0cb | 2020-01-08 23:12:14 +0000 | [diff] [blame] | 266 | struct ReactorType<T, std::enable_if_t<IsReference<T>::value>> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 267 | { |
| 268 | using type = T; |
| 269 | static type cast(T v) { return type(v); } |
| 270 | }; |
Ben Clayton | 208ed40 | 2019-05-03 22:30:03 +0100 | [diff] [blame] | 271 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 272 | // Reactor types that can be used as a return type for a function. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 273 | template<typename T> |
| 274 | struct CanBeUsedAsReturn |
| 275 | { |
| 276 | static constexpr bool value = false; |
| 277 | }; |
| 278 | template<> |
| 279 | struct CanBeUsedAsReturn<Void> |
| 280 | { |
| 281 | static constexpr bool value = true; |
| 282 | }; |
| 283 | template<> |
| 284 | struct CanBeUsedAsReturn<Int> |
| 285 | { |
| 286 | static constexpr bool value = true; |
| 287 | }; |
| 288 | template<> |
| 289 | struct CanBeUsedAsReturn<UInt> |
| 290 | { |
| 291 | static constexpr bool value = true; |
| 292 | }; |
| 293 | template<> |
| 294 | struct CanBeUsedAsReturn<Float> |
| 295 | { |
| 296 | static constexpr bool value = true; |
| 297 | }; |
| 298 | template<typename T> |
| 299 | struct CanBeUsedAsReturn<Pointer<T>> |
| 300 | { |
| 301 | static constexpr bool value = true; |
| 302 | }; |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 303 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 304 | // Reactor types that can be used as a parameter types for a function. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 305 | template<typename T> |
| 306 | struct CanBeUsedAsParameter |
| 307 | { |
| 308 | static constexpr bool value = false; |
| 309 | }; |
| 310 | template<> |
| 311 | struct CanBeUsedAsParameter<Int> |
| 312 | { |
| 313 | static constexpr bool value = true; |
| 314 | }; |
| 315 | template<> |
| 316 | struct CanBeUsedAsParameter<UInt> |
| 317 | { |
| 318 | static constexpr bool value = true; |
| 319 | }; |
| 320 | template<> |
| 321 | struct CanBeUsedAsParameter<Float> |
| 322 | { |
| 323 | static constexpr bool value = true; |
| 324 | }; |
| 325 | template<typename T> |
| 326 | struct CanBeUsedAsParameter<Pointer<T>> |
| 327 | { |
| 328 | static constexpr bool value = true; |
| 329 | }; |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 330 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 331 | // AssertParameterTypeIsValid statically asserts that all template parameter |
| 332 | // types can be used as a Reactor function parameter. |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 333 | template<typename T, typename... other> |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 334 | struct AssertParameterTypeIsValid : AssertParameterTypeIsValid<other...> |
| 335 | { |
| 336 | static_assert(CanBeUsedAsParameter<T>::value, "Invalid parameter type"); |
| 337 | }; |
| 338 | template<typename T> |
| 339 | struct AssertParameterTypeIsValid<T> |
| 340 | { |
| 341 | static_assert(CanBeUsedAsParameter<T>::value, "Invalid parameter type"); |
| 342 | }; |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 343 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 344 | // AssertFunctionSignatureIsValid statically asserts that the Reactor |
| 345 | // function signature is valid. |
| 346 | template<typename Return, typename... Arguments> |
| 347 | class AssertFunctionSignatureIsValid; |
| 348 | template<typename Return> |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 349 | class AssertFunctionSignatureIsValid<Return(Void)> |
| 350 | {}; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 351 | template<typename Return, typename... Arguments> |
| 352 | class AssertFunctionSignatureIsValid<Return(Arguments...)> |
| 353 | { |
| 354 | static_assert(CanBeUsedAsReturn<Return>::value, "Invalid return type"); |
| 355 | static_assert(sizeof(AssertParameterTypeIsValid<Arguments...>) >= 0, ""); |
| 356 | }; |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 357 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 358 | } // namespace rr |
Ben Clayton | 351be42 | 2019-04-30 12:26:57 +0100 | [diff] [blame] | 359 | |
Ben Clayton | 713b8d3 | 2019-12-17 20:37:56 +0000 | [diff] [blame] | 360 | #endif // rr_Traits_hpp |