-
Notifications
You must be signed in to change notification settings - Fork 50
/
recycled.hpp
102 lines (84 loc) · 1.53 KB
/
recycled.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
// Copyright (c) 2022 Vinnie Falco (vinnie.falco@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/url
//
#ifndef BOOST_URL_GRAMMAR_DETAIL_RECYCLED_HPP
#define BOOST_URL_GRAMMAR_DETAIL_RECYCLED_HPP
#include <utility>
namespace boost {
namespace urls {
namespace grammar {
namespace see_below {
template<
std::size_t Size,
std::size_t Align>
struct aligned_storage_impl
{
void* addr() noexcept
{
return buf_;
}
void const* addr() const noexcept
{
return buf_;
}
private:
alignas(Align)
unsigned char buf_[Size];
};
constexpr
std::size_t
nearest_pow2(
std::size_t x,
std::size_t f = 0) noexcept
{
return
(f <= (std::size_t(-1)/2))
? ( x <= f
? f
: nearest_pow2(x, 2 * f))
: x;
}
//------------------------------------------------
BOOST_URL_DECL
void
recycled_add_impl(
std::size_t) noexcept;
BOOST_URL_DECL
void
recycled_remove_impl(
std::size_t) noexcept;
#ifdef BOOST_URL_REPORT
inline
void
recycled_add(
std::size_t n) noexcept
{
recycled_add_impl(n);
}
inline
void
recycled_remove(
std::size_t n) noexcept
{
recycled_remove_impl(n);
}
#else
inline void recycled_add(
std::size_t) noexcept
{
}
inline void recycled_remove(
std::size_t) noexcept
{
}
#endif
} // implementation_defined
} // grammar
} // urls
} // boost
#endif