GCC Code Coverage Report


Directory: libs/url/
File: boost/url/grammar/detail/recycled.hpp
Date: 2024-03-15 19:37:09
Exec Total Coverage
Lines: 6 6 100.0%
Functions: 4 4 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 //
2 // Copyright (c) 2022 Vinnie Falco (vinnie.falco@gmail.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 // Official repository: https://github.com/boostorg/url
8 //
9
10 #ifndef BOOST_URL_GRAMMAR_DETAIL_RECYCLED_HPP
11 #define BOOST_URL_GRAMMAR_DETAIL_RECYCLED_HPP
12
13 #include <utility>
14
15 namespace boost {
16 namespace urls {
17 namespace grammar {
18 namespace detail {
19
20 template<
21 std::size_t Size,
22 std::size_t Align>
23 struct aligned_storage_impl
24 {
25 44 void* addr() noexcept
26 {
27 44 return buf_;
28 }
29
30 void const* addr() const noexcept
31 {
32 return buf_;
33 }
34
35 private:
36 alignas(Align)
37 unsigned char buf_[Size];
38 };
39
40 constexpr
41 std::size_t
42 nearest_pow2(
43 std::size_t x,
44 std::size_t f = 0) noexcept
45 {
46 return
47 (f <= (std::size_t(-1)/2))
48 ? ( x <= f
49 ? f
50 : nearest_pow2(x, 2 * f))
51 : x;
52 }
53
54 //------------------------------------------------
55
56 BOOST_URL_DECL
57 void
58 recycled_add_impl(
59 std::size_t) noexcept;
60
61 BOOST_URL_DECL
62 void
63 recycled_remove_impl(
64 std::size_t) noexcept;
65
66 #ifdef BOOST_URL_REPORT
67
68 inline
69 void
70 recycled_add(
71 std::size_t n) noexcept
72 {
73 recycled_add_impl(n);
74 }
75
76 inline
77 void
78 recycled_remove(
79 std::size_t n) noexcept
80 {
81 recycled_remove_impl(n);
82 }
83
84 #else
85
86 6 inline void recycled_add(
87 std::size_t) noexcept
88 {
89 6 }
90 6 inline void recycled_remove(
91 std::size_t) noexcept
92 {
93 6 }
94
95 #endif
96
97 } // detail
98 } // grammar
99 } // urls
100 } // boost
101
102 #endif
103