]> git.proxmox.com Git - ceph.git/blob - ceph/src/Beast/include/beast/core/detail/type_traits.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / Beast / include / beast / core / detail / type_traits.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_TYPE_TRAITS_HPP
9 #define BEAST_DETAIL_TYPE_TRAITS_HPP
10
11 #include <tuple>
12 #include <type_traits>
13 #include <stdexcept>
14 #include <string>
15
16 namespace beast {
17 namespace detail {
18
19 template<class... Ts>
20 struct make_void
21 {
22 using type = void;
23 };
24
25 template<class... Ts>
26 using void_t = typename make_void<Ts...>::type;
27
28 template<class... Ts>
29 inline
30 void
31 ignore_unused(Ts const& ...)
32 {
33 }
34
35 template<class... Ts>
36 inline
37 void
38 ignore_unused()
39 {}
40
41 template<class U>
42 std::size_t constexpr
43 max_sizeof()
44 {
45 return sizeof(U);
46 }
47
48 template<class U0, class U1, class... Us>
49 std::size_t constexpr
50 max_sizeof()
51 {
52 return
53 max_sizeof<U0>() > max_sizeof<U1, Us...>() ?
54 max_sizeof<U0>() : max_sizeof<U1, Us...>();
55 }
56
57 template<unsigned N, class T, class... Tn>
58 struct repeat_tuple_impl
59 {
60 using type = typename repeat_tuple_impl<
61 N - 1, T, T, Tn...>::type;
62 };
63
64 template<class T, class... Tn>
65 struct repeat_tuple_impl<0, T, Tn...>
66 {
67 using type = std::tuple<T, Tn...>;
68 };
69
70 template<unsigned N, class T>
71 struct repeat_tuple
72 {
73 using type =
74 typename repeat_tuple_impl<N-1, T>::type;
75 };
76
77 template<class T>
78 struct repeat_tuple<0, T>
79 {
80 using type = std::tuple<>;
81 };
82
83 template<class Exception>
84 Exception
85 make_exception(char const* reason, char const* file, int line)
86 {
87 char const* n = file;
88 for(auto p = file; *p; ++p)
89 if(*p == '\\' || *p == '/')
90 n = p + 1;
91 return Exception{std::string(reason) + " (" +
92 n + ":" + std::to_string(line) + ")"};
93 }
94
95 } // detail
96 } // beast
97
98 #endif