]> git.proxmox.com Git - ceph.git/blob - ceph/src/Beast/include/beast/core/detail/get_lowest_layer.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / Beast / include / beast / core / detail / get_lowest_layer.hpp
1 //
2 // Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
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)
6 //
7
8 #ifndef BEAST_DETAIL_GET_LOWEST_LAYER_HPP
9 #define BEAST_DETAIL_GET_LOWEST_LAYER_HPP
10
11 #include <type_traits>
12
13 namespace beast {
14 namespace detail {
15
16 template<class T>
17 class has_lowest_layer
18 {
19 template<class U, class R =
20 typename U::lowest_layer_type>
21 static std::true_type check(int);
22 template<class>
23 static std::false_type check(...);
24 using type = decltype(check<T>(0));
25 public:
26 static bool constexpr value = type::value;
27 };
28
29 template<class T, bool B>
30 struct maybe_get_lowest_layer
31 {
32 using type = T;
33 };
34
35 template<class T>
36 struct maybe_get_lowest_layer<T, true>
37 {
38 using type = typename T::lowest_layer_type;
39 };
40
41 // If T has a nested type lowest_layer_type,
42 // returns that, else returns T.
43 template<class T>
44 struct get_lowest_layer
45 {
46 using type = typename maybe_get_lowest_layer<T,
47 has_lowest_layer<T>::value>::type;
48 };
49
50 } // detail
51 } // beast
52
53 #endif