7#if !defined(ASYNC_MQTT_STREAM_TRAITS_HPP)
8#define ASYNC_MQTT_STREAM_TRAITS_HPP
17std::false_type has_next_layer_impl(
void*);
20auto has_next_layer_impl(
decltype(
nullptr)) ->
21 decltype(std::declval<T&>().next_layer(), std::true_type{});
24using has_next_layer =
decltype(has_next_layer_impl<T>(
nullptr));
26template<typename T, bool = has_next_layer<T>::value>
27struct lowest_layer_type_impl {
28 using type =
typename std::remove_reference<T>::type;
32struct lowest_layer_type_impl<T, true> {
33 using type =
typename lowest_layer_type_impl<
34 decltype(std::declval<T&>().next_layer())>::type;
38using lowest_layer_type =
typename lowest_layer_type_impl<T>::type;
42get_lowest_layer_impl(T& t, std::false_type)
noexcept {
48get_lowest_layer_impl(T& t, std::true_type)
noexcept {
50 get_lowest_layer_impl(
52 has_next_layer<
typename std::decay<
decltype(t.next_layer())>::type>{}
59using executor_type =
decltype(std::declval<T>().get_executor());
62using lowest_layer_type = detail::lowest_layer_type<T>;
65lowest_layer_type<T>& get_lowest_layer(T& t)
noexcept {
67 detail::get_lowest_layer_impl(
69 detail::has_next_layer<T>{}