ipaddress 1.1.0
Loading...
Searching...
No Matches
byte-array.hpp
Go to the documentation of this file.
1/**
2 * @file byte-array.hpp
3 * @brief Provides the byte_array template class for handling fixed-size byte arrays
4 * @author Vladimir Shaleev
5 * @copyright MIT License
6 *
7 * The byte_array template class is designed to encapsulate a fixed-size array of bytes (uint8_t),
8 * providing various type definitions for ease of use, and methods for accessing the array elements.
9 * Intended for use in managing IP address representations and manipulations. The class ensures that
10 * the array size is constant and known at compile-time, offering a compile-time guarantee of array
11 * bounds, which can prevent common errors associated with dynamic arrays.
12 */
13
14#ifndef IPADDRESS_BYTE_ARRAY_HPP
15#define IPADDRESS_BYTE_ARRAY_HPP
16
17#include "config.hpp"
18
19namespace IPADDRESS_NAMESPACE {
20
21/**
22 * A template class for creating and managing a fixed-size array of bytes.
23 *
24 * The byte_array class encapsulates a static-size array of bytes, providing type definitions
25 * for element access and iteration in both normal and reverse order. It is designed to be used
26 * where a constant size byte buffer is needed, such as in handling network addresses like IP addresses.
27 *
28 * @tparam N The number of bytes in the array.
29 * @remark The purpose of the byte_array class is to provide functionality similar to std::array in .
30 * environments where std::array cannot be used to its full extent during compile-time operations.
31 */
32IPADDRESS_EXPORT template <size_t N>
33struct byte_array {
34 using value_type = uint8_t; /**< The type of elements contained in the byte_array. */
35 using size_type = size_t; /**< The type representing sizes and counts. */
36 using difference_type = ptrdiff_t; /**< The type representing the difference between two pointers. */
37 using pointer = value_type*; /**< A pointer to an element in the byte_array. */
38 using const_pointer = const value_type*; /**< A pointer to a constant element in the byte_array. */
39 using reference = value_type&; /**< A reference to an element in the byte_array. */
40 using const_reference = const value_type&; /**< A reference to a constant element in the byte_array. */
41
42 using iterator = pointer; /**< A random access iterator to byte_array that allows modification of its elements. */
43 using const_iterator = const_pointer; /**< A random access iterator to constant byte_array that does not allow modification of its elements. */
44
45 using reverse_iterator = std::reverse_iterator<iterator>; /**< A reverse random access iterator to byte_array that allows modification of its elements. */
46 using const_reverse_iterator = std::reverse_iterator<const_iterator>; /**< A reverse random access iterator to constant byte_array that does not allow modification of its elements. */
47
48 value_type _data[N];
49
50 /**
51 * Returns a const_iterator to the beginning of the byte_array.
52 *
53 * @return A const_iterator pointing to the first element in the array.
54 */
55 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_iterator begin() const IPADDRESS_NOEXCEPT {
56 return const_iterator(_data);
57 }
58
59 /**
60 * Returns a const_iterator to the end of the byte_array.
61 *
62 * @return A const_iterator pointing to the past-the-end element in the array.
63 */
64 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_iterator end() const IPADDRESS_NOEXCEPT {
65 return const_iterator(_data) + N;
66 }
67
68 /**
69 * Returns a const_reverse_iterator to the beginning of the reversed byte_array.
70 *
71 * @return A const_reverse_iterator pointing to the first element of the reversed array.
72 */
73 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR_17 IPADDRESS_FORCE_INLINE const_reverse_iterator rbegin() const IPADDRESS_NOEXCEPT {
74 return const_reverse_iterator(end());
75 }
76
77 /**
78 * Returns a const_reverse_iterator to the end of the reversed byte_array.
79 *
80 * @return A const_reverse_iterator pointing to the past-the-end element in the reversed array.
81 */
82 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR_17 IPADDRESS_FORCE_INLINE const_reverse_iterator rend() const IPADDRESS_NOEXCEPT {
83 return const_reverse_iterator(begin());
84 }
85
86 /**
87 * Returns a const_iterator to the beginning of the byte_array (const version).
88 *
89 * @return A const_iterator pointing to the first element in the array.
90 */
91 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_iterator cbegin() const IPADDRESS_NOEXCEPT {
92 return begin();
93 }
94
95 /**
96 * Returns a const_iterator to the end of the byte_array (const version).
97 *
98 * @return A const_iterator pointing to the past-the-end element in the array.
99 */
100 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_iterator cend() const IPADDRESS_NOEXCEPT {
101 return end();
102 }
103
104 /**
105 * Returns a const_reverse_iterator to the beginning of the reversed byte_array (const version).
106 *
107 * @return A const_reverse_iterator pointing to the first element of the reversed array.
108 */
109 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR_17 IPADDRESS_FORCE_INLINE const_reverse_iterator crbegin() const IPADDRESS_NOEXCEPT {
110 return const_reverse_iterator(cend());
111 }
112
113 /**
114 * Returns a const_reverse_iterator to the end of the reversed byte_array (const version).
115 *
116 * @return A const_reverse_iterator pointing to the past-the-end element in the reversed array.
117 */
118 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR_17 IPADDRESS_FORCE_INLINE const_reverse_iterator crend() const IPADDRESS_NOEXCEPT {
119 return const_reverse_iterator(cbegin());
120 }
121
122 /**
123 * Checks if the byte_array is empty.
124 *
125 * @return `true` if the byte_array is empty, `false` otherwise.
126 */
128 return false;
129 }
130
131 /**
132 * Returns the size of the byte_array.
133 *
134 * @return The number of elements in the byte_array.
135 */
137 return N;
138 }
139
140 /**
141 * Returns the maximum size of the byte_array.
142 *
143 * @return The number of elements in the byte_array (same as size()).
144 */
146 return N;
147 }
148
149 /**
150 * Accesses the element at the specified index with bounds checking.
151 *
152 * @param[in] n The index of the element to access.
153 * @return A reference to the element at the specified index.
154 * @throw std::out_of_range When going beyond the bounds of the array.
155 */
157 return at(n);
158 }
159
160 /**
161 * Accesses the element at the specified index with bounds checking (const version).
162 *
163 * @param[in] n The index of the element to access.
164 * @return A const reference to the element at the specified index.
165 * @throw std::out_of_range When going beyond the bounds of the array.
166 */
167 IPADDRESS_NODISCARD_WHEN_NO_EXCEPTIONS IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_reference operator[](size_t n) const IPADDRESS_NOEXCEPT {
168 return at(n);
169 }
170
171 /**
172 * Accesses the element at the specified index with bounds checking.
173 *
174 * @param[in] n The index of the element to access.
175 * @return A reference to the element at the specified index.
176 * @throw std::out_of_range When going beyond the bounds of the array.
177 */
179 return _data[n];
180 }
181
182 /**
183 * Accesses the element at the specified index with bounds checking (const version).
184 *
185 * @param[in] n The index of the element to access.
186 * @return A const reference to the element at the specified index.
187 * @throw std::out_of_range When going beyond the bounds of the array.
188 */
189 IPADDRESS_NODISCARD_WHEN_NO_EXCEPTIONS IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_reference at(size_t n) const IPADDRESS_NOEXCEPT {
190 return _data[n];
191 }
192
193 /**
194 * Accesses the first element in the byte_array.
195 *
196 * @return A reference to the first element in the byte_array.
197 */
199 return _data[0];
200 }
201
202 /**
203 * Accesses the first element in the byte_array (const version).
204 *
205 * @return A const reference to the first element in the byte_array.
206 */
207 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_reference front() const IPADDRESS_NOEXCEPT {
208 return _data[0];
209 }
210
211 /**
212 * Accesses the last element in the byte_array.
213 *
214 * @return A reference to the last element in the byte_array.
215 */
217 return _data[N - 1];
218 }
219
220 /**
221 * Accesses the last element in the byte_array (const version).
222 *
223 * @return A const reference to the last element in the byte_array.
224 */
225 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_reference back() const IPADDRESS_NOEXCEPT {
226 return _data[N - 1];
227 }
228
229 /**
230 * Returns a pointer to the underlying array.
231 *
232 * @return A pointer to the underlying array of type value_type.
233 */
235 return _data;
236 }
237
238 /**
239 * Returns a const pointer to the underlying array (const version).
240 *
241 * @return A const pointer to the underlying array of type value_type.
242 */
243 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_pointer data() const IPADDRESS_NOEXCEPT {
244 return _data;
245 }
246
247 /**
248 * Swaps the contents of this byte_array with another byte_array.
249 *
250 * @param[in,out] other The other byte_array to swap contents with.
251 */
252 IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE void swap(byte_array& other) IPADDRESS_NOEXCEPT {
253 for (size_t i = 0; i < N; ++i) {
254 const auto tmp = _data[i];
255 _data[i] = other._data[i];
256 other._data[i] = tmp;
257 }
258 }
259}; // byte_array<N>
260
261IPADDRESS_EXPORT template <>
262class byte_array<0> {
263public:
264 using value_type = uint8_t;
265 using size_type = size_t;
266 using difference_type = std::ptrdiff_t;
267 using pointer = value_type*;
268 using const_pointer = const value_type*;
269 using reference = value_type&;
270 using const_reference = const value_type&;
271
272 using iterator = pointer;
273 using const_iterator = const_pointer;
274
275 using reverse_iterator = std::reverse_iterator<iterator>;
276 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
277
278 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_iterator begin() const IPADDRESS_NOEXCEPT {
279 return const_iterator(data());
280 }
281
282 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_iterator end() const IPADDRESS_NOEXCEPT {
283 return const_iterator(data());
284 }
285
286 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR_17 IPADDRESS_FORCE_INLINE const_reverse_iterator rbegin() const IPADDRESS_NOEXCEPT {
287 return const_reverse_iterator(end());
288 }
289
290 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR_17 IPADDRESS_FORCE_INLINE const_reverse_iterator rend() const IPADDRESS_NOEXCEPT {
291 return const_reverse_iterator(begin());
292 }
293
294 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_iterator cbegin() const IPADDRESS_NOEXCEPT {
295 return begin();
296 }
297
298 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_iterator cend() const IPADDRESS_NOEXCEPT {
299 return end();
300 }
301
302 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR_17 IPADDRESS_FORCE_INLINE const_reverse_iterator crbegin() const IPADDRESS_NOEXCEPT {
303 return const_reverse_iterator(cend());
304 }
305
306 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR_17 IPADDRESS_FORCE_INLINE const_reverse_iterator crend() const IPADDRESS_NOEXCEPT {
307 return const_reverse_iterator(cbegin());
308 }
309
310 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE bool empty() const IPADDRESS_NOEXCEPT {
311 return true;
312 }
313
314 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE size_t size() const IPADDRESS_NOEXCEPT {
315 return 0;
316 }
317
318 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE size_t max_size() const IPADDRESS_NOEXCEPT {
319 return 0;
320 }
321
322 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE reference operator[](size_t n) IPADDRESS_NOEXCEPT {
323 return at(n);
324 }
325
326 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_reference operator[](size_t n) const IPADDRESS_NOEXCEPT {
327 return at(n);
328 }
329
330 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE reference at(size_t /*n*/) IPADDRESS_NOEXCEPT {
331 return *data();
332 }
333
334 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_reference at(size_t /*n*/) const IPADDRESS_NOEXCEPT {
335 return *data();
336 }
337
338 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE reference front() IPADDRESS_NOEXCEPT {
339 return *data();
340 }
341
342 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_reference front() const IPADDRESS_NOEXCEPT {
343 return *data();
344 }
345
346 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE reference back() IPADDRESS_NOEXCEPT {
347 return *data();
348 }
349
350 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_reference back() const IPADDRESS_NOEXCEPT {
351 return *data();
352 }
353
354 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE pointer data() IPADDRESS_NOEXCEPT {
355 return nullptr;
356 }
357
358 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE const_pointer data() const IPADDRESS_NOEXCEPT {
359 return nullptr;
360 }
361
362 IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE void swap(byte_array& other) IPADDRESS_NOEXCEPT {
363 }
364}; // byte_array<0>
365
366/**
367 * Checks if two byte_array objects are equal.
368 *
369 * Compares two byte_array objects of the same size element-wise to determine if they are equal.
370 *
371 * @tparam N The size of the byte array.
372 * @param[in] lhs A reference to the left-hand side byte_array object.
373 * @param[in] rhs A reference to the right-hand side byte_array object.
374 * @return A boolean value indicating whether the two byte_array objects are equal.
375 * @retval true the two byte_array objects are equal
376 * @retval false the two byte_array objects are not equal
377 */
378IPADDRESS_EXPORT template <size_t N>
379IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE bool operator==(const byte_array<N>& lhs, const byte_array<N>& rhs) IPADDRESS_NOEXCEPT {
380 for (size_t i = 0; i < N; ++i) {
381 if (lhs[i] != rhs[i]) {
382 return false;
383 }
384 }
385 return true;
386}
387
388/**
389 * Checks if two byte_array objects are not equal.
390 *
391 * Compares two byte_array objects of the same size element-wise to determine if they are not equal.
392 *
393 * @tparam N The size of the byte array.
394 * @param[in] lhs A reference to the left-hand side byte_array object.
395 * @param[in] rhs A reference to the right-hand side byte_array object.
396 * @return A boolean value indicating whether the two byte_array objects are not equal.
397 * @retval true the two byte_array objects are not equal
398 * @retval false the two byte_array objects are equal
399 */
400IPADDRESS_EXPORT template <size_t N>
401IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE bool operator!=(const byte_array<N>& lhs, const byte_array<N>& rhs) IPADDRESS_NOEXCEPT {
402 return !(lhs == rhs);
403}
404
405#ifdef IPADDRESS_HAS_SPACESHIP_OPERATOR
406
407 /**
408 * Compares two byte_array objects for ordering.
409 *
410 * Performs a lexicographical comparison between two byte_array objects using the three-way comparison operator.
411 * The comparison is done element-wise and stops at the first unequal pair of elements, returning the result
412 * of comparing these two elements. If all elements are equal, the byte_arrays are considered equivalent.
413 *
414 * @tparam N The size of the byte array.
415 * @param[in] lhs A reference to the left-hand side byte_array object.
416 * @param[in] rhs A reference to the right-hand side byte_array object.
417 * @return An `std::strong_ordering` value indicating the ordering relationship.
418 * @retval std::strong_ordering::less if lhs is lexicographically less than rhs
419 * @retval std::strong_ordering::greater if lhs is lexicographically greater than rhs
420 * @retval std::strong_ordering::equivalent if lhs is lexicographically equal to rhs
421 */
422 IPADDRESS_EXPORT template <size_t N>
423 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE std::strong_ordering operator<=>(const byte_array<N>& lhs, const byte_array<N>& rhs) IPADDRESS_NOEXCEPT {
424 for (size_t i = 0; i < N; ++i) {
425 if (const auto result = lhs[i] <=> rhs[i]; result != std::strong_ordering::equivalent) {
426 return result;
427 }
428 }
429 return std::strong_ordering::equivalent;
430 }
431
432#else // !IPADDRESS_HAS_SPACESHIP_OPERATOR
433
434 /**
435 * Determines if one byte_array is less than another.
436 *
437 * Performs a lexicographical comparison of two byte_array objects. The comparison is done
438 * element-wise and stops at the first unequal pair where the left-hand side is less than
439 * the right-hand side.
440 *
441 * @tparam N The size of the byte arrays.
442 * @param[in] lhs A reference to the left-hand side byte_array object.
443 * @param[in] rhs A reference to the right-hand side byte_array object.
444 * @return `true` if lhs is lexicographically less than rhs, `false` otherwise.
445 */
446 IPADDRESS_EXPORT template <size_t N>
447 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE bool operator<(const byte_array<N>& lhs, const byte_array<N>& rhs) IPADDRESS_NOEXCEPT {
448 for (size_t i = 0; i < N; ++i) {
449 if (lhs._data[i] < rhs._data[i]) {
450 return true;
451 } else if (lhs._data[i] != rhs._data[i]) {
452 break;
453 }
454 }
455 return false;
456 }
457
458 /**
459 * Determines if one byte_array is greater than another.
460 *
461 * @tparam N The size of the byte arrays.
462 * @param[in] lhs A reference to the left-hand side byte_array object.
463 * @param[in] rhs A reference to the right-hand side byte_array object.
464 * @return `true` if lhs is lexicographically greater than rhs, `false` otherwise.
465 */
466 IPADDRESS_EXPORT template <size_t N>
467 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE bool operator>(const byte_array<N>& lhs, const byte_array<N>& rhs) IPADDRESS_NOEXCEPT {
468 return rhs < lhs;
469 }
470
471 /**
472 * Determines if one byte_array is less than or equal to another.
473 *
474 * @tparam N The size of the byte arrays.
475 * @param[in] lhs A reference to the left-hand side byte_array object.
476 * @param[in] rhs A reference to the right-hand side byte_array object.
477 * @return `true` if lhs is lexicographically less than or equal to rhs, `false` otherwise.
478 */
479 IPADDRESS_EXPORT template <size_t N>
480 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE bool operator<=(const byte_array<N>& lhs, const byte_array<N>& rhs) IPADDRESS_NOEXCEPT {
481 return !(rhs < lhs);
482 }
483
484 /**
485 * Determines if one byte_array is greater than or equal to another.
486 *
487 * @tparam N The size of the byte arrays.
488 * @param[in] lhs A reference to the left-hand side byte_array object.
489 * @param[in] rhs A reference to the right-hand side byte_array object.
490 * @return `true` if lhs is lexicographically greater than or equal to rhs, `false` otherwise.
491 */
492 IPADDRESS_EXPORT template <size_t N>
493 IPADDRESS_NODISCARD IPADDRESS_CONSTEXPR IPADDRESS_FORCE_INLINE bool operator>=(const byte_array<N>& lhs, const byte_array<N>& rhs) IPADDRESS_NOEXCEPT {
494 return !(lhs < rhs);
495 }
496
497#endif // !IPADDRESS_HAS_SPACESHIP_OPERATOR
498
499} // namespace IPADDRESS_NAMESPACE
500
501#endif // IPADDRESS_BYTE_ARRAY_HPP
#define IPADDRESS_EXPORT
Definition config.hpp:42
#define IPADDRESS_NODISCARD
Definition config.hpp:98
#define IPADDRESS_FORCE_INLINE
Definition config.hpp:112
#define IPADDRESS_NAMESPACE
Definition config.hpp:38
#define IPADDRESS_NOEXCEPT
Definition config.hpp:89
#define IPADDRESS_NODISCARD_WHEN_NO_EXCEPTIONS
Definition config.hpp:102
constexpr inline bool operator!=(const byte_array< N > &lhs, const byte_array< N > &rhs) noexcept
Checks if two byte_array objects are not equal.
Definition byte-array.hpp:401
constexpr inline bool operator>(const byte_array< N > &lhs, const byte_array< N > &rhs) noexcept
Determines if one byte_array is greater than another.
Definition byte-array.hpp:467
constexpr inline bool operator>=(const byte_array< N > &lhs, const byte_array< N > &rhs) noexcept
Determines if one byte_array is greater than or equal to another.
Definition byte-array.hpp:493
constexpr inline bool operator<=(const byte_array< N > &lhs, const byte_array< N > &rhs) noexcept
Determines if one byte_array is less than or equal to another.
Definition byte-array.hpp:480
constexpr inline bool operator<(const byte_array< N > &lhs, const byte_array< N > &rhs) noexcept
Determines if one byte_array is less than another.
Definition byte-array.hpp:447
constexpr inline bool operator==(const byte_array< N > &lhs, const byte_array< N > &rhs) noexcept
Checks if two byte_array objects are equal.
Definition byte-array.hpp:379
A template class for creating and managing a fixed-size array of bytes.
Definition byte-array.hpp:33
constexpr inline const_reverse_iterator crbegin() const noexcept
Returns a const_reverse_iterator to the beginning of the reversed byte_array (const version).
Definition byte-array.hpp:109
constexpr inline pointer data() noexcept
Returns a pointer to the underlying array.
Definition byte-array.hpp:234
constexpr inline reference front() noexcept
Accesses the first element in the byte_array.
Definition byte-array.hpp:198
constexpr inline reference operator[](size_t n) noexcept
Accesses the element at the specified index with bounds checking.
Definition byte-array.hpp:156
constexpr inline const_iterator begin() const noexcept
Returns a const_iterator to the beginning of the byte_array.
Definition byte-array.hpp:55
constexpr inline reference at(size_t n) noexcept
Accesses the element at the specified index with bounds checking.
Definition byte-array.hpp:178
constexpr inline bool empty() const noexcept
Checks if the byte_array is empty.
Definition byte-array.hpp:127
constexpr inline const_reverse_iterator crend() const noexcept
Returns a const_reverse_iterator to the end of the reversed byte_array (const version).
Definition byte-array.hpp:118
constexpr inline const_reference front() const noexcept
Accesses the first element in the byte_array (const version).
Definition byte-array.hpp:207
constexpr inline const_pointer data() const noexcept
Returns a const pointer to the underlying array (const version).
Definition byte-array.hpp:243
constexpr inline reference back() noexcept
Accesses the last element in the byte_array.
Definition byte-array.hpp:216
constexpr inline const_reference at(size_t n) const noexcept
Accesses the element at the specified index with bounds checking (const version).
Definition byte-array.hpp:189
constexpr inline const_reverse_iterator rend() const noexcept
Returns a const_reverse_iterator to the end of the reversed byte_array.
Definition byte-array.hpp:82
constexpr inline const_iterator cend() const noexcept
Returns a const_iterator to the end of the byte_array (const version).
Definition byte-array.hpp:100
constexpr inline const_reference operator[](size_t n) const noexcept
Accesses the element at the specified index with bounds checking (const version).
Definition byte-array.hpp:167
constexpr inline const_iterator cbegin() const noexcept
Returns a const_iterator to the beginning of the byte_array (const version).
Definition byte-array.hpp:91
constexpr inline const_iterator end() const noexcept
Returns a const_iterator to the end of the byte_array.
Definition byte-array.hpp:64
constexpr inline size_t size() const noexcept
Returns the size of the byte_array.
Definition byte-array.hpp:136
constexpr inline const_reverse_iterator rbegin() const noexcept
Returns a const_reverse_iterator to the beginning of the reversed byte_array.
Definition byte-array.hpp:73
constexpr inline void swap(byte_array &other) noexcept
Swaps the contents of this byte_array with another byte_array.
Definition byte-array.hpp:252
constexpr inline size_t max_size() const noexcept
Returns the maximum size of the byte_array.
Definition byte-array.hpp:145
constexpr inline const_reference back() const noexcept
Accesses the last element in the byte_array (const version).
Definition byte-array.hpp:225