2
3
4
5
6
7
8
9
10
11
12
14#ifndef IPADDRESS_BYTE_ARRAY_HPP
15#define IPADDRESS_BYTE_ARRAY_HPP
22
23
24
25
26
27
28
29
30
31
34 using value_type = uint8_t;
37 using pointer = value_type*;
38 using const_pointer =
const value_type*;
39 using reference = value_type&;
40 using const_reference =
const value_type&;
42 using iterator = pointer;
43 using const_iterator = const_pointer;
45 using reverse_iterator = std::reverse_iterator<iterator>;
46 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
51
52
53
54
56 return const_iterator(_data);
60
61
62
63
65 return const_iterator(_data) + N;
69
70
71
72
74 return const_reverse_iterator(end());
78
79
80
81
83 return const_reverse_iterator(begin());
87
88
89
90
96
97
98
99
105
106
107
108
110 return const_reverse_iterator(cend());
114
115
116
117
119 return const_reverse_iterator(cbegin());
123
124
125
126
132
133
134
135
141
142
143
144
150
151
152
153
154
155
161
162
163
164
165
166
172
173
174
175
176
177
183
184
185
186
187
188
194
195
196
197
203
204
205
206
212
213
214
215
221
222
223
224
230
231
232
233
239
240
241
242
248
249
250
251
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;
264 using value_type = uint8_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&;
272 using iterator = pointer;
273 using const_iterator = const_pointer;
275 using reverse_iterator = std::reverse_iterator<iterator>;
276 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
279 return const_iterator(data());
283 return const_iterator(data());
287 return const_reverse_iterator(end());
291 return const_reverse_iterator(begin());
303 return const_reverse_iterator(cend());
307 return const_reverse_iterator(cbegin());
367
368
369
370
371
372
373
374
375
376
377
380 for (size_t i = 0; i < N; ++i) {
381 if (lhs[i] != rhs[i]) {
389
390
391
392
393
394
395
396
397
398
399
402 return !(lhs == rhs);
405#ifdef IPADDRESS_HAS_SPACESHIP_OPERATOR
408
409
410
411
412
413
414
415
416
417
418
419
420
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) {
429 return std::strong_ordering::equivalent;
435
436
437
438
439
440
441
442
443
444
445
448 for (size_t i = 0; i < N; ++i) {
449 if (lhs._data[i] < rhs._data[i]) {
451 }
else if (lhs._data[i] != rhs._data[i]) {
459
460
461
462
463
464
465
472
473
474
475
476
477
478
485
486
487
488
489
490
491
#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