Line data Source code
1 : //
2 : // Copyright (c) 2025 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/cppalliance/buffers
8 : //
9 :
10 : #include <boost/buffers/any_buffers.hpp>
11 : #include <boost/buffers/detail/except.hpp>
12 :
13 : namespace boost {
14 : namespace buffers {
15 :
16 : template<>
17 1 : any_buffers<true>::
18 1 : any_buffers() noexcept
19 : {
20 : struct impl : any_impl
21 : {
22 1 : bool is_small_buffers() const noexcept override
23 : {
24 1 : return true;
25 : }
26 :
27 1 : bool is_small_iter() const noexcept override
28 : {
29 1 : return true;
30 : }
31 :
32 3 : void destroy() const override
33 : {
34 3 : }
35 :
36 2 : void copy(any_buffers& dest) const override
37 : {
38 2 : dest.p_ = this;
39 2 : }
40 :
41 1 : void it_copy(void*, void const*) const override
42 : {
43 1 : }
44 :
45 24 : void it_destroy(void*) const override
46 : {
47 24 : }
48 :
49 1 : void inc(void*) const override
50 : {
51 1 : }
52 :
53 1 : void dec(void*) const override
54 : {
55 1 : }
56 :
57 3 : value_type deref(void const*) const override
58 : {
59 3 : return {};
60 : }
61 :
62 12 : bool equal(void const*, void const*) const override
63 : {
64 12 : return true;
65 : }
66 :
67 12 : void begin(void*) const override
68 : {
69 12 : }
70 :
71 11 : void end(void*) const override
72 : {
73 11 : }
74 : };
75 :
76 1 : static impl const instance;
77 1 : p_ = &instance;
78 1 : }
79 :
80 : template<>
81 3 : any_buffers<false>::
82 3 : any_buffers() noexcept
83 : {
84 : struct impl : any_impl
85 : {
86 2 : bool is_small_buffers() const noexcept override
87 : {
88 2 : return true;
89 : }
90 :
91 2 : bool is_small_iter() const noexcept override
92 : {
93 2 : return true;
94 : }
95 :
96 5 : void destroy() const override
97 : {
98 5 : }
99 :
100 2 : void copy(any_buffers& dest) const override
101 : {
102 2 : dest.p_ = this;
103 2 : }
104 :
105 1 : void it_copy(void*, void const*) const override
106 : {
107 1 : }
108 :
109 28 : void it_destroy(void*) const override
110 : {
111 28 : }
112 :
113 1 : void inc(void*) const override
114 : {
115 1 : }
116 :
117 1 : void dec(void*) const override
118 : {
119 1 : }
120 :
121 3 : value_type deref(void const*) const override
122 : {
123 3 : return {};
124 : }
125 :
126 14 : bool equal(void const*, void const*) const override
127 : {
128 14 : return true;
129 : }
130 :
131 14 : void begin(void*) const override
132 : {
133 14 : }
134 :
135 13 : void end(void*) const override
136 : {
137 13 : }
138 : };
139 :
140 3 : static impl const instance;
141 3 : p_ = &instance;
142 3 : }
143 :
144 : template<>
145 0 : any_buffers<true>::
146 : any_buffers::
147 : const_iterator::
148 0 : const_iterator() noexcept
149 0 : : p_(any_buffers<true>().begin().p_)
150 : {
151 0 : }
152 :
153 : template<>
154 0 : any_buffers<false>::
155 : any_buffers::
156 : const_iterator::
157 0 : const_iterator() noexcept
158 0 : : p_(any_buffers<false>().begin().p_)
159 : {
160 0 : }
161 :
162 : } // buffers
163 : } // boost
|