27#ifndef SDBUS_CXX_TYPETRAITS_H_
28#define SDBUS_CXX_TYPETRAITS_H_
34#if __cplusplus >= 202002L
38#include <unordered_map>
47 template <
typename... _ValueTypes>
class Struct;
55 class PropertySetCall;
56 class PropertyGetReply;
57 template <
typename... _Results>
class Result;
64 using method_callback = std::function<void(MethodCall msg)>;
65 using async_reply_handler = std::function<void(MethodReply& reply,
const Error* error)>;
66 using signal_handler = std::function<void(Signal& signal)>;
67 using message_handler = std::function<void(Message& msg)>;
68 using property_set_callback = std::function<void(PropertySetCall& msg)>;
69 using property_get_callback = std::function<void(PropertyGetReply& reply)>;
72 using Slot = std::unique_ptr<void, std::function<void(
void*)>>;
82 [[deprecated(
"Replaced by floating_slot")]]
inline constexpr dont_request_slot_t dont_request_slot{};
98 template <
typename _T>
101 static constexpr bool is_valid =
false;
102 static constexpr bool is_trivial_dbus_type =
false;
104 static const std::string str()
108 static_assert(
sizeof(_T) < 0,
"Unknown DBus type");
113 template <
typename _T>
118 template <
typename _T>
126 static constexpr bool is_valid =
true;
127 static constexpr bool is_trivial_dbus_type =
false;
129 static const std::string str()
138 static constexpr bool is_valid =
true;
139 static constexpr bool is_trivial_dbus_type =
true;
141 static const std::string str()
150 static constexpr bool is_valid =
true;
151 static constexpr bool is_trivial_dbus_type =
true;
153 static const std::string str()
162 static constexpr bool is_valid =
true;
163 static constexpr bool is_trivial_dbus_type =
true;
165 static const std::string str()
174 static constexpr bool is_valid =
true;
175 static constexpr bool is_trivial_dbus_type =
true;
177 static const std::string str()
186 static constexpr bool is_valid =
true;
187 static constexpr bool is_trivial_dbus_type =
true;
189 static const std::string str()
198 static constexpr bool is_valid =
true;
199 static constexpr bool is_trivial_dbus_type =
true;
201 static const std::string str()
210 static constexpr bool is_valid =
true;
211 static constexpr bool is_trivial_dbus_type =
true;
213 static const std::string str()
222 static constexpr bool is_valid =
true;
223 static constexpr bool is_trivial_dbus_type =
true;
225 static const std::string str()
234 static constexpr bool is_valid =
true;
235 static constexpr bool is_trivial_dbus_type =
true;
237 static const std::string str()
246 static constexpr bool is_valid =
true;
247 static constexpr bool is_trivial_dbus_type =
false;
249 static const std::string str()
258 static constexpr bool is_valid =
true;
259 static constexpr bool is_trivial_dbus_type =
false;
261 static const std::string str()
267 template <std::
size_t _N>
270 static constexpr bool is_valid =
true;
271 static constexpr bool is_trivial_dbus_type =
false;
273 static const std::string str()
279 template <std::
size_t _N>
282 static constexpr bool is_valid =
true;
283 static constexpr bool is_trivial_dbus_type =
false;
285 static const std::string str()
294 static constexpr bool is_valid =
true;
295 static constexpr bool is_trivial_dbus_type =
false;
297 static const std::string str()
303 template <
typename... _ValueTypes>
306 static constexpr bool is_valid =
true;
307 static constexpr bool is_trivial_dbus_type =
false;
309 static const std::string str()
311 std::string signature;
322 static constexpr bool is_valid =
true;
323 static constexpr bool is_trivial_dbus_type =
false;
325 static const std::string str()
334 static constexpr bool is_valid =
true;
335 static constexpr bool is_trivial_dbus_type =
false;
337 static const std::string str()
346 static constexpr bool is_valid =
true;
347 static constexpr bool is_trivial_dbus_type =
false;
349 static const std::string str()
358 static constexpr bool is_valid =
true;
359 static constexpr bool is_trivial_dbus_type =
false;
361 static const std::string str()
367 template <
typename _Element,
typename _Allocator>
370 static constexpr bool is_valid =
true;
371 static constexpr bool is_trivial_dbus_type =
false;
373 static const std::string str()
379 template <
typename _Element, std::
size_t _Size>
382 static constexpr bool is_valid =
true;
383 static constexpr bool is_trivial_dbus_type =
false;
385 static const std::string str()
391#if __cplusplus >= 202002L
392 template <
typename _Element, std::
size_t _Extent>
395 static constexpr bool is_valid =
true;
396 static constexpr bool is_trivial_dbus_type =
false;
398 static const std::string str()
405 template <
typename _Key,
typename _Value,
typename _Compare,
typename _Allocator>
408 static constexpr bool is_valid =
true;
409 static constexpr bool is_trivial_dbus_type =
false;
411 static const std::string str()
417 template <
typename _Key,
typename _Value,
typename _Hash,
typename _KeyEqual,
typename _Allocator>
418 struct signature_of<std::unordered_map<_Key, _Value, _Hash, _KeyEqual, _Allocator>>
420 static constexpr bool is_valid =
true;
421 static constexpr bool is_trivial_dbus_type =
false;
423 static const std::string str()
432 template <
typename _Type>
437 template <
typename _Type>
442 template <
typename _Type>
447 template <
typename _ReturnType,
typename... _Args>
450 typedef _ReturnType result_type;
451 typedef std::tuple<_Args...> arguments_type;
452 typedef std::tuple<std::decay_t<_Args>...> decayed_arguments_type;
454 typedef _ReturnType function_type(_Args...);
456 static constexpr std::size_t arity =
sizeof...(_Args);
473 template <
size_t _Idx>
476 typedef std::tuple_element_t<_Idx, std::tuple<_Args...>> type;
479 template <
size_t _Idx>
480 using arg_t =
typename arg<_Idx>::type;
483 template <
typename _ReturnType,
typename... _Args>
487 static constexpr bool is_async =
false;
488 static constexpr bool has_error_param =
false;
491 template <
typename... _Args>
495 static constexpr bool has_error_param =
true;
498 template <
typename... _Args,
typename... _Results>
502 static constexpr bool is_async =
true;
506 template <
typename... _Args,
typename... _Results>
510 static constexpr bool is_async =
true;
514 template <
typename _ReturnType,
typename... _Args>
519 template <
typename _ClassType,
typename _ReturnType,
typename... _Args>
523 typedef _ClassType& owner_type;
526 template <
typename _ClassType,
typename _ReturnType,
typename... _Args>
530 typedef const _ClassType& owner_type;
533 template <
typename _ClassType,
typename _ReturnType,
typename... _Args>
537 typedef volatile _ClassType& owner_type;
540 template <
typename _ClassType,
typename _ReturnType,
typename... _Args>
544 typedef const volatile _ClassType& owner_type;
547 template <
typename FunctionType>
552 template <
class _Function>
555 template <
class _Function>
558 template <
typename _FunctionType>
561 template <
typename _FunctionType,
size_t _Idx>
564 template <
typename _FunctionType>
567 template <
typename _FunctionType>
570 template <
typename _Function>
576 template <
typename _Function>
577 using tuple_of_function_input_arg_types_t =
typename tuple_of_function_input_arg_types<_Function>::type;
579 template <
typename _Function>
585 template <
typename _Function>
586 using tuple_of_function_output_arg_types_t =
typename tuple_of_function_output_arg_types<_Function>::type;
588 template <
typename _Type>
591 static const std::string str()
597 template <
typename... _Types>
600 static const std::string str()
602 std::string signature;
603 (void)(signature += ... +=
signature_of<std::decay_t<_Types>>::str());
608 template <
typename _Function>
611 static const std::string str()
617 template <
typename _Function>
620 static const std::string str()
629 typedef std::tuple<_Args...> type;
642 template <
typename... _Args>
643 using future_return_t =
typename future_return<_Args...>::type;
648 template <
class _Function,
class _Tuple,
typename... _Args, std::size_t... _I>
649 constexpr decltype(
auto) apply_impl( _Function&& f
652 , std::index_sequence<_I...> )
654 return std::forward<_Function>(f)(std::move(r), std::get<_I>(std::forward<_Tuple>(t))...);
657 template <
class _Function,
class _Tuple, std::size_t... _I>
658 constexpr decltype(
auto) apply_impl( _Function&& f
661 , std::index_sequence<_I...> )
663 return std::forward<_Function>(f)(e, std::get<_I>(std::forward<_Tuple>(t))...);
668 template <
class _Function,
class _Tuple, std::size_t... _I>
669 constexpr decltype(
auto) apply_impl( _Function&& f
671 , std::index_sequence<_I...> )
673 if constexpr (!std::is_void_v<function_result_t<_Function>>)
674 return std::forward<_Function>(f)(std::get<_I>(std::forward<_Tuple>(t))...);
676 return std::forward<_Function>(f)(std::get<_I>(std::forward<_Tuple>(t))...), std::tuple<>{};
682 template <
class _Function,
class _Tuple>
683 constexpr decltype(
auto) apply(_Function&& f, _Tuple&& t)
685 return detail::apply_impl( std::forward<_Function>(f)
686 , std::forward<_Tuple>(t)
687 , std::make_index_sequence<std::tuple_size<std::decay_t<_Tuple>>::value>{} );
692 template <
class _Function,
class _Tuple,
typename... _Args>
693 constexpr decltype(
auto) apply(_Function&& f, Result<_Args...>&& r, _Tuple&& t)
695 return detail::apply_impl( std::forward<_Function>(f)
697 , std::forward<_Tuple>(t)
698 , std::make_index_sequence<std::tuple_size<std::decay_t<_Tuple>>::value>{} );
703 template <
class _Function,
class _Tuple>
704 constexpr decltype(
auto) apply(_Function&& f,
const Error* e, _Tuple&& t)
706 return detail::apply_impl( std::forward<_Function>(f)
708 , std::forward<_Tuple>(t)
709 , std::make_index_sequence<std::tuple_size<std::decay_t<_Tuple>>::value>{} );
Definition: MethodResult.h:50
Definition: TypeTraits.h:87
Definition: TypeTraits.h:84
Definition: TypeTraits.h:590
Definition: TypeTraits.h:81
Definition: TypeTraits.h:91
Definition: TypeTraits.h:78
Definition: TypeTraits.h:475
Definition: TypeTraits.h:449
Definition: TypeTraits.h:435
Definition: TypeTraits.h:628
Definition: TypeTraits.h:75
Definition: TypeTraits.h:619
Definition: TypeTraits.h:100
Definition: TypeTraits.h:581
Definition: TypeTraits.h:94