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;
383 template <
typename... _Args>
389 template <
typename... _Args,
typename... _Results>
393 static constexpr bool is_async =
true;
397 template <
typename... _Args,
typename... _Results>
401 static constexpr bool is_async =
true;
405 template <
typename _ReturnType,
typename... _Args>
410 template <
typename _ClassType,
typename _ReturnType,
typename... _Args>
414 typedef _ClassType& owner_type;
417 template <
typename _ClassType,
typename _ReturnType,
typename... _Args>
421 typedef const _ClassType& owner_type;
424 template <
typename _ClassType,
typename _ReturnType,
typename... _Args>
428 typedef volatile _ClassType& owner_type;
431 template <
typename _ClassType,
typename _ReturnType,
typename... _Args>
435 typedef const volatile _ClassType& owner_type;
438 template <
typename FunctionType>
443 template <
class _Function>
446 template <
typename _FunctionType>
449 template <
typename _FunctionType,
size_t _Idx>
452 template <
typename _FunctionType>
455 template <
typename _FunctionType>
458 template <
typename _Function>
464 template <
typename _Function>
465 using tuple_of_function_input_arg_types_t =
typename tuple_of_function_input_arg_types<_Function>::type;
467 template <
typename _Function>
473 template <
typename _Function>
474 using tuple_of_function_output_arg_types_t =
typename tuple_of_function_output_arg_types<_Function>::type;
476 template <
typename _Type>
479 static const std::string str()
485 template <
typename... _Types>
488 static const std::string str()
490 std::string signature;
491 (void)(signature += ... +=
signature_of<std::decay_t<_Types>>::str());
496 template <
typename _Function>
499 static const std::string str()
505 template <
typename _Function>
508 static const std::string str()
516 template <
class _Function,
class _Tuple,
typename... _Args, std::size_t... _I>
517 constexpr decltype(
auto) apply_impl( _Function&& f
520 , std::index_sequence<_I...> )
522 return std::forward<_Function>(f)(std::move(r), std::get<_I>(std::forward<_Tuple>(t))...);
525 template <
class _Function,
class _Tuple, std::size_t... _I>
526 constexpr decltype(
auto) apply_impl( _Function&& f
529 , std::index_sequence<_I...> )
531 return std::forward<_Function>(f)(e, std::get<_I>(std::forward<_Tuple>(t))...);
536 template <
class _Function,
class _Tuple, std::size_t... _I>
537 constexpr decltype(
auto) apply_impl( _Function&& f
539 , std::index_sequence<_I...> )
541 if constexpr (!std::is_void_v<function_result_t<_Function>>)
542 return std::forward<_Function>(f)(std::get<_I>(std::forward<_Tuple>(t))...);
544 return std::forward<_Function>(f)(std::get<_I>(std::forward<_Tuple>(t))...), std::tuple<>{};
550 template <
class _Function,
class _Tuple>
551 constexpr decltype(
auto) apply(_Function&& f, _Tuple&& t)
553 return detail::apply_impl( std::forward<_Function>(f)
554 , std::forward<_Tuple>(t)
555 , std::make_index_sequence<std::tuple_size<std::decay_t<_Tuple>>::value>{} );
560 template <
class _Function,
class _Tuple,
typename... _Args>
561 constexpr decltype(
auto) apply(_Function&& f, Result<_Args...>&& r, _Tuple&& t)
563 return detail::apply_impl( std::forward<_Function>(f)
565 , std::forward<_Tuple>(t)
566 , std::make_index_sequence<std::tuple_size<std::decay_t<_Tuple>>::value>{} );
571 template <
class _Function,
class _Tuple>
572 constexpr decltype(
auto) apply(_Function&& f,
const Error* e, _Tuple&& t)
574 return detail::apply_impl( std::forward<_Function>(f)
576 , std::forward<_Tuple>(t)
577 , std::make_index_sequence<std::tuple_size<std::decay_t<_Tuple>>::value>{} );
Definition: MethodResult.h:50
Definition: TypeTraits.h:478
Definition: TypeTraits.h:368
Definition: TypeTraits.h:342
Definition: TypeTraits.h:328
Definition: TypeTraits.h:507
Definition: TypeTraits.h:64
Definition: TypeTraits.h:469