]> git.proxmox.com Git - ceph.git/blame - 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
CommitLineData
7c673cae
FG
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
16namespace beast {
17namespace detail {
18
19template<class... Ts>
20struct make_void
21{
22 using type = void;
23};
24
25template<class... Ts>
26using void_t = typename make_void<Ts...>::type;
27
28template<class... Ts>
29inline
30void
31ignore_unused(Ts const& ...)
32{
33}
34
35template<class... Ts>
36inline
37void
38ignore_unused()
39{}
40
41template<class U>
42std::size_t constexpr
43max_sizeof()
44{
45 return sizeof(U);
46}
47
48template<class U0, class U1, class... Us>
49std::size_t constexpr
50max_sizeof()
51{
52 return
53 max_sizeof<U0>() > max_sizeof<U1, Us...>() ?
54 max_sizeof<U0>() : max_sizeof<U1, Us...>();
55}
56
57template<unsigned N, class T, class... Tn>
58struct repeat_tuple_impl
59{
60 using type = typename repeat_tuple_impl<
61 N - 1, T, T, Tn...>::type;
62};
63
64template<class T, class... Tn>
65struct repeat_tuple_impl<0, T, Tn...>
66{
67 using type = std::tuple<T, Tn...>;
68};
69
70template<unsigned N, class T>
71struct repeat_tuple
72{
73 using type =
74 typename repeat_tuple_impl<N-1, T>::type;
75};
76
77template<class T>
78struct repeat_tuple<0, T>
79{
80 using type = std::tuple<>;
81};
82
83template<class Exception>
84Exception
85make_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