27#ifndef SDBUS_CXX_TYPETRAITS_H_
28#define SDBUS_CXX_TYPETRAITS_H_
41 template <
typename... _ValueTypes>
class Struct;
48 class PropertySetCall;
49 class PropertyGetReply;
50 template <
typename... _Results>
class Result;
56 using method_callback = std::function<void(MethodCall msg)>;
57 using async_reply_handler = std::function<void(MethodReply& reply,
const Error* error)>;
58 using signal_handler = std::function<void(Signal& signal)>;
59 using property_set_callback = std::function<void(PropertySetCall& msg)>;
60 using property_get_callback = std::function<void(PropertyGetReply& reply)>;
62 template <
typename _T>
65 static constexpr bool is_valid =
false;
67 static const std::string str()
71 static_assert(
sizeof(_T) < 0,
"Unknown DBus type");
79 static constexpr bool is_valid =
true;
81 static const std::string str()
90 static constexpr bool is_valid =
true;
92 static const std::string str()
101 static constexpr bool is_valid =
true;
103 static const std::string str()
112 static constexpr bool is_valid =
true;
114 static const std::string str()
123 static constexpr bool is_valid =
true;
125 static const std::string str()
134 static constexpr bool is_valid =
true;
136 static const std::string str()
145 static constexpr bool is_valid =
true;
147 static const std::string str()
156 static constexpr bool is_valid =
true;
158 static const std::string str()
167 static constexpr bool is_valid =
true;
169 static const std::string str()
178 static constexpr bool is_valid =
true;
180 static const std::string str()
189 static constexpr bool is_valid =
true;
191 static const std::string str()
200 static constexpr bool is_valid =
true;
202 static const std::string str()
208 template <std::
size_t _N>
211 static constexpr bool is_valid =
true;
213 static const std::string str()
219 template <std::
size_t _N>
222 static constexpr bool is_valid =
true;
224 static const std::string str()
233 static constexpr bool is_valid =
true;
235 static const std::string str()
241 template <
typename... _ValueTypes>
244 static constexpr bool is_valid =
true;
246 static const std::string str()
248 std::string signature;
259 static constexpr bool is_valid =
true;
261 static const std::string str()
270 static constexpr bool is_valid =
true;
272 static const std::string str()
281 static constexpr bool is_valid =
true;
283 static const std::string str()
292 static constexpr bool is_valid =
true;
294 static const std::string str()
300 template <
typename _Element>
303 static constexpr bool is_valid =
true;
305 static const std::string str()
311 template <
typename _Key,
typename _Value>
314 static constexpr bool is_valid =
true;
316 static const std::string str()
325 template <
typename _Type>
330 template <
typename _Type>
335 template <
typename _Type>
340 template <
typename _ReturnType,
typename... _Args>
343 typedef _ReturnType result_type;
344 typedef std::tuple<_Args...> arguments_type;
345 typedef std::tuple<std::decay_t<_Args>...> decayed_arguments_type;
347 typedef _ReturnType function_type(_Args...);
349 static constexpr std::size_t arity =
sizeof...(_Args);
366 template <
size_t _Idx>
369 typedef std::tuple_element_t<_Idx, std::tuple<_Args...>> type;
372 template <
size_t _Idx>
373 using arg_t =
typename arg<_Idx>::type;
376 template <
typename _ReturnType,
typename... _Args>
380 static constexpr bool is_async =
false;
381 static constexpr bool has_error_param =
false;
384 template <
typename... _Args>
388 static constexpr bool has_error_param =
true;
391 template <
typename... _Args,
typename... _Results>
395 static constexpr bool is_async =
true;
399 template <
typename... _Args,
typename... _Results>
403 static constexpr bool is_async =
true;
407 template <
typename _ReturnType,
typename... _Args>
412 template <
typename _ClassType,
typename _ReturnType,
typename... _Args>
416 typedef _ClassType& owner_type;
419 template <
typename _ClassType,
typename _ReturnType,
typename... _Args>
423 typedef const _ClassType& owner_type;
426 template <
typename _ClassType,
typename _ReturnType,
typename... _Args>
430 typedef volatile _ClassType& owner_type;
433 template <
typename _ClassType,
typename _ReturnType,
typename... _Args>
437 typedef const volatile _ClassType& owner_type;
440 template <
typename FunctionType>
445 template <
class _Function>
448 template <
class _Function>
451 template <
typename _FunctionType>
454 template <
typename _FunctionType,
size_t _Idx>
457 template <
typename _FunctionType>
460 template <
typename _FunctionType>
463 template <
typename _Function>
469 template <
typename _Function>
470 using tuple_of_function_input_arg_types_t =
typename tuple_of_function_input_arg_types<_Function>::type;
472 template <
typename _Function>
478 template <
typename _Function>
479 using tuple_of_function_output_arg_types_t =
typename tuple_of_function_output_arg_types<_Function>::type;
481 template <
typename _Type>
484 static const std::string str()
490 template <
typename... _Types>
493 static const std::string str()
495 std::string signature;
496 (void)(signature += ... +=
signature_of<std::decay_t<_Types>>::str());
501 template <
typename _Function>
504 static const std::string str()
510 template <
typename _Function>
513 static const std::string str()
521 template <
class _Function,
class _Tuple,
typename... _Args, std::size_t... _I>
522 constexpr decltype(
auto) apply_impl( _Function&& f
525 , std::index_sequence<_I...> )
527 return std::forward<_Function>(f)(std::move(r), std::get<_I>(std::forward<_Tuple>(t))...);
530 template <
class _Function,
class _Tuple, std::size_t... _I>
531 constexpr decltype(
auto) apply_impl( _Function&& f
534 , std::index_sequence<_I...> )
536 return std::forward<_Function>(f)(e, std::get<_I>(std::forward<_Tuple>(t))...);
541 template <
class _Function,
class _Tuple, std::size_t... _I>
542 constexpr decltype(
auto) apply_impl( _Function&& f
544 , std::index_sequence<_I...> )
546 if constexpr (!std::is_void_v<function_result_t<_Function>>)
547 return std::forward<_Function>(f)(std::get<_I>(std::forward<_Tuple>(t))...);
549 return std::forward<_Function>(f)(std::get<_I>(std::forward<_Tuple>(t))...), std::tuple<>{};
555 template <
class _Function,
class _Tuple>
556 constexpr decltype(
auto) apply(_Function&& f, _Tuple&& t)
558 return detail::apply_impl( std::forward<_Function>(f)
559 , std::forward<_Tuple>(t)
560 , std::make_index_sequence<std::tuple_size<std::decay_t<_Tuple>>::value>{} );
565 template <
class _Function,
class _Tuple,
typename... _Args>
566 constexpr decltype(
auto) apply(_Function&& f, Result<_Args...>&& r, _Tuple&& t)
568 return detail::apply_impl( std::forward<_Function>(f)
570 , std::forward<_Tuple>(t)
571 , std::make_index_sequence<std::tuple_size<std::decay_t<_Tuple>>::value>{} );
576 template <
class _Function,
class _Tuple>
577 constexpr decltype(
auto) apply(_Function&& f,
const Error* e, _Tuple&& t)
579 return detail::apply_impl( std::forward<_Function>(f)
581 , std::forward<_Tuple>(t)
582 , std::make_index_sequence<std::tuple_size<std::decay_t<_Tuple>>::value>{} );
Definition: MethodResult.h:50
Definition: TypeTraits.h:483
Definition: TypeTraits.h:368
Definition: TypeTraits.h:342
Definition: TypeTraits.h:328
Definition: TypeTraits.h:512
Definition: TypeTraits.h:64
Definition: TypeTraits.h:474