src/fields.cpp

100.0% Lines (51/51) 100.0% List of functions (12/12) 100.0% Branches (6/6)
fields.cpp
f(x) Functions (12)
Line Branch TLA Hits Source Code
1 //
2 // Copyright (c) 2021 Vinnie Falco ([email protected])
3 // Copyright (c) 2026 Mohammad Nejati
4 //
5 // Distributed under the Boost Software License, Version 1.0. (See accompanying
6 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 //
8 // Official repository: https://github.com/cppalliance/burl
9 //
10
11 #include <boost/burl/fields.hpp>
12
13 #include <utility>
14
15 namespace boost
16 {
17 namespace burl
18 {
19
20 379x fields::
21 379x fields() noexcept
22 379x : fields_base()
23 {
24 379x }
25
26 379x fields::
27 379x ~fields()
28 {
29 379x release_();
30 379x }
31
32 143x fields::
33 143x fields(fields&& other) noexcept
34 143x : fields()
35 {
36 143x swap_(other);
37 143x }
38
39 5x fields::
40 5x fields(fields_base const& other)
41 5x : fields()
42 {
43
1/1
✓ Branch 1 taken 5 times.
5x assign_(other, 0);
44 5x }
45
46 2x fields::
47 2x fields(fields const& other)
48 2x : fields(static_cast<fields_base const&>(other))
49 {
50 2x }
51
52 31x fields::
53 31x fields(std::initializer_list<field_view> init)
54 31x : fields()
55 {
56
1/1
✓ Branch 1 taken 30 times.
31x append(init);
57 31x }
58
59 fields&
60 5x fields::
61 operator=(fields&& other) noexcept
62 {
63 5x fields tmp(std::move(other));
64 5x swap_(tmp);
65 10x return *this;
66 5x }
67
68 fields&
69 9x fields::
70 operator=(fields_base const& other)
71 {
72
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
9x if(this != &other)
73 7x assign_(other, 0);
74 9x return *this;
75 }
76
77 fields&
78 6x fields::
79 operator=(fields const& other)
80 {
81 6x return *this = static_cast<fields_base const&>(other);
82 }
83
84 void
85 5x fields::
86 swap(fields& other) noexcept
87 {
88 5x swap_(other);
89 5x }
90
91 void
92 12x fields::
93 reserve(
94 std::size_t bytes,
95 std::size_t count)
96 {
97 12x reserve_(bytes, count);
98 8x }
99
100 void
101 3x fields::
102 shrink_to_fit()
103 {
104
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 time.
3x if(count_ == 0)
105 {
106 // release the allocation entirely
107 2x fields tmp;
108 2x swap_(tmp);
109 2x return;
110 2x }
111 1x shrink_to_fit_();
112 }
113
114 } // namespace burl
115 } // namespace boost
116