2 // Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BEAST_DETAIL_GET_LOWEST_LAYER_HPP
9 #define BEAST_DETAIL_GET_LOWEST_LAYER_HPP
11 #include <type_traits>
17 class has_lowest_layer
19 template<class U, class R =
20 typename U::lowest_layer_type>
21 static std::true_type check(int);
23 static std::false_type check(...);
24 using type = decltype(check<T>(0));
26 static bool constexpr value = type::value;
29 template<class T, bool B>
30 struct maybe_get_lowest_layer
36 struct maybe_get_lowest_layer<T, true>
38 using type = typename T::lowest_layer_type;
41 // If T has a nested type lowest_layer_type,
42 // returns that, else returns T.
44 struct get_lowest_layer
46 using type = typename maybe_get_lowest_layer<T,
47 has_lowest_layer<T>::value>::type;