2
3
4
5
6
7
8
9
10
11
12
13
14
15
17#ifndef IPADDRESS_IP_ANY_ITERATOR_HPP
18#define IPADDRESS_IP_ANY_ITERATOR_HPP
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
46 using iterator_category = std::random_access_iterator_tag;
48 using difference_type = int64_t;
49 using pointer =
const value_type*;
50 using reference =
const value_type&;
55
56
60
61
62
63
68
69
70
71
76
77
78
79
80
81
82
84 if (_version != other._version) {
87 return _version ==
ip_version::V4 ?
uint128_t(_iter.iter4.uint_diff(other._iter.iter4)) : _iter.iter6.uint_diff(other._iter.iter6);
91
92
93
94
100
101
102
103
109
110
111
112
113
115 const auto& it = *
this;
120
121
122
123
124
126 return _version ==
ip_version::V4 ? value_type(_iter.iter4[uint32_t(n)]) : value_type(_iter.iter6[n]);
130
131
132
133
140
141
142
143
151
152
153
154
161
162
163
164
172
173
174
175
176
177
178
185
186
187
188
189
190
191
198
199
200
201
202
203
204
211
212
213
214
215
216
217
224
225
226
227
228
229
230
238
239
240
241
242
243
244
252
253
254
255
256
257
258
259
265
266
267
268
269
270
271
272
278
279
280
281
282
283
284
292
293
294
295
296
297
298
306
307
308
309
310
311
312
314 if (_version != other._version) {
317 return _version ==
ip_version::V4 ? _iter.iter4 - other._iter.iter4 : _iter.iter6 - other._iter.iter6;
321
322
323
324
325
326
327
329 if (_version != other._version) {
332 return _version ==
ip_version::V4 ? _iter.iter4 == other._iter.iter4 : _iter.iter6 == other._iter.iter6;
336
337
338
339
340
341
342
344 return !(*
this == other);
347#ifdef IPADDRESS_HAS_SPACESHIP_OPERATOR
350
351
352
353
354
355
356
368
369
370
371
372
373
374
376 if (_version != other._version) {
379 return _version ==
ip_version::V4 ? _iter.iter4 < other._iter.iter4 : _iter.iter6 < other._iter.iter6;
383
384
385
386
387
388
389
391 return !(other < *
this);
395
396
397
398
399
400
401
403 return other < *
this;
407
408
409
410
411
412
413
415 return !(*
this < other);
431 _iter.iter4 += uint32_t(n);
432 _current = *_iter.iter4;
435 _current = *_iter.iter6;
441 _iter.iter4 -= uint32_t(n);
442 _current = *_iter.iter4;
445 _current = *_iter.iter6;
466 value_type _current {};
470
471
472
473
474
475
476
477
478
484 using pointer = value_type*;
485 using const_pointer =
const value_type*;
486 using reference = value_type&;
487 using const_reference =
const value_type&;
489 using iterator =
ip_any_iterator<value_type, ip_address_iterator<ipv4_address>, ip_address_iterator<ipv6_address>>;
490 using const_iterator = iterator;
496
497
498
499
500
505
506
507
508
509
514
515
516
517
523
524
525
526
532
533
534
535
537 return const_reverse_iterator(end());
541
542
543
544
546 return const_reverse_iterator(begin());
550
551
552
553
559
560
561
562
568
569
570
571
573 return const_reverse_iterator(cend());
577
578
579
580
582 return const_reverse_iterator(cbegin());
586
587
588
589
591 return _begin == _end;
595
596
597
598
600 return _end.uint_diff(_begin);
604
605
606
607
608
614
615
616
617
618
620 return *(_begin + n);
624
625
626
627
633
634
635
636
642 const_iterator _begin{};
643 const_iterator _end{};
647
648
649
650
651
652
653
654
655
656
660 using value_type = T;
663 using pointer = value_type*;
664 using const_pointer =
const value_type*;
665 using reference = value_type&;
666 using const_reference =
const value_type&;
669 using const_iterator = iterator;
675
676
677
678
679
684
685
686
687
688
693
694
695
696
702
703
704
705
711
712
713
714
716 return const_reverse_iterator(
end());
720
721
722
723
725 return const_reverse_iterator(
begin());
729
730
731
732
738
739
740
741
747
748
749
750
752 return const_reverse_iterator(
cend());
756
757
758
759
761 return const_reverse_iterator(
cbegin());
765
766
767
768
770 return _begin == _end;
774
775
776
777
779 return _end.uint_diff(_begin);
783
784
785
786
787
793
794
795
796
797
799 return *(_begin + n);
803
804
805
806
812
813
814
815
821 const_iterator _begin{};
822 const_iterator _end{};
A sequence of host IP addresses.
Definition ip-any-iterator.hpp:479
constexpr inline const_reverse_iterator crbegin() const noexcept
Gets the beginning const reverse iterator of the sequence.
Definition ip-any-iterator.hpp:572
constexpr inline value_type operator[](difference_type n) const noexcept
Accesses an element by index.
Definition ip-any-iterator.hpp:609
constexpr inline const_iterator begin() const noexcept
Gets the beginning iterator of the sequence.
Definition ip-any-iterator.hpp:518
constexpr inline bool empty() const noexcept
Checks if the sequence is empty.
Definition ip-any-iterator.hpp:590
constexpr inline value_type back() const noexcept
Accesses the last element in the sequence.
Definition ip-any-iterator.hpp:637
constexpr inline const_reverse_iterator crend() const noexcept
Gets the end const reverse iterator of the sequence.
Definition ip-any-iterator.hpp:581
constexpr inline value_type front() const noexcept
Accesses the first element in the sequence.
Definition ip-any-iterator.hpp:628
constexpr inline difference_type size() const noexcept
Gets the size of the sequence.
Definition ip-any-iterator.hpp:599
constexpr inline hosts_any_sequence(ip_address_iterator< ipv6_address > begin, ip_address_iterator< ipv6_address > end) noexcept
Constructs a hosts_any_sequence with specified network parameters.
Definition ip-any-iterator.hpp:510
constexpr inline const_reverse_iterator rend() const noexcept
Gets the end reverse iterator of the sequence.
Definition ip-any-iterator.hpp:545
constexpr inline const_iterator cend() const noexcept
Gets the end const iterator of the sequence.
Definition ip-any-iterator.hpp:563
constexpr inline const_iterator cbegin() const noexcept
Gets the beginning const iterator of the sequence.
Definition ip-any-iterator.hpp:554
constexpr inline const_iterator end() const noexcept
Gets the end iterator of the sequence.
Definition ip-any-iterator.hpp:527
constexpr inline value_type at(difference_type n) const noexcept
Accesses an element by index with bounds checking.
Definition ip-any-iterator.hpp:619
constexpr inline const_reverse_iterator rbegin() const noexcept
Gets the beginning reverse iterator of the sequence.
Definition ip-any-iterator.hpp:536
constexpr inline hosts_any_sequence(ip_address_iterator< ipv4_address > begin, ip_address_iterator< ipv4_address > end) noexcept
Constructs a hosts_any_sequence with specified network parameters.
Definition ip-any-iterator.hpp:501
A class that represents an IP address, supporting both IPv4 and IPv6 formats.
Definition ip-any-address.hpp:73
An iterator for unified traversal over IPv4 and IPv6 address spaces.
Definition ip-any-iterator.hpp:44
constexpr inline ip_any_iterator(Ipv6Iter iter) noexcept
Constructs an ip_any_iterator from an Ipv6Iter iterator.
Definition ip-any-iterator.hpp:72
constexpr inline ip_any_iterator() noexcept=default
Default constructor.
friend constexpr inline ip_any_iterator operator+(const uint128_t &n, const ip_any_iterator &it) noexcept
Addition operator.
Definition ip-any-iterator.hpp:273
constexpr inline bool operator<(const ip_any_iterator &other) const noexcept
Less-than operator.
Definition ip-any-iterator.hpp:375
constexpr inline value_type operator[](difference_type n) const noexcept
Accesses an element by index.
Definition ip-any-iterator.hpp:114
constexpr inline difference_type operator-(const ip_any_iterator &other) const noexcept
Subtraction operator.
Definition ip-any-iterator.hpp:313
constexpr inline ip_any_iterator & operator+=(const uint128_t &n) noexcept
Addition assignment operator.
Definition ip-any-iterator.hpp:192
constexpr inline ip_any_iterator operator+(difference_type n) const noexcept
Addition operator.
Definition ip-any-iterator.hpp:231
constexpr inline bool operator<=(const ip_any_iterator &other) const noexcept
Less-than-or-equal-to operator.
Definition ip-any-iterator.hpp:390
constexpr inline bool operator!=(const ip_any_iterator &other) const noexcept
Inequality operator.
Definition ip-any-iterator.hpp:343
constexpr inline ip_any_iterator & operator-=(const uint128_t &n) noexcept
Subtraction assignment operator.
Definition ip-any-iterator.hpp:218
constexpr inline ip_any_iterator operator-(difference_type n) const noexcept
Subtraction operator.
Definition ip-any-iterator.hpp:285
constexpr inline value_type operator[](const uint128_t &n) const noexcept
Accesses an element by index.
Definition ip-any-iterator.hpp:125
constexpr inline ip_any_iterator operator-(const uint128_t &n) const noexcept
Subtraction operator.
Definition ip-any-iterator.hpp:299
constexpr inline uint128_t uint_diff(const ip_any_iterator &other) const noexcept
Calculates the difference in the number of elements between this and another ip_any_iterator.
Definition ip-any-iterator.hpp:83
constexpr inline ip_any_iterator(Ipv4Iter iter) noexcept
Constructs an ip_any_iterator from an Ipv4Iter iterator.
Definition ip-any-iterator.hpp:64
constexpr inline bool operator>(const ip_any_iterator &other) const noexcept
Greater-than operator.
Definition ip-any-iterator.hpp:402
constexpr inline ip_any_iterator operator++(int) noexcept
Post-increment operator.
Definition ip-any-iterator.hpp:144
constexpr inline bool operator==(const ip_any_iterator &other) const noexcept
Equality operator.
Definition ip-any-iterator.hpp:328
constexpr inline bool operator>=(const ip_any_iterator &other) const noexcept
Greater-than-or-equal-to operator.
Definition ip-any-iterator.hpp:414
constexpr inline ip_any_iterator & operator--() noexcept
Pre-decrement operator.
Definition ip-any-iterator.hpp:155
friend constexpr inline ip_any_iterator operator+(difference_type n, const ip_any_iterator &it) noexcept
Addition operator.
Definition ip-any-iterator.hpp:260
constexpr inline pointer operator->() const noexcept
Returns a pointer to the current element.
Definition ip-any-iterator.hpp:104
constexpr inline ip_any_iterator operator+(const uint128_t &n) const noexcept
Addition operator.
Definition ip-any-iterator.hpp:245
constexpr inline ip_any_iterator & operator+=(difference_type n) noexcept
Addition assignment operator.
Definition ip-any-iterator.hpp:179
constexpr inline ip_any_iterator & operator++() noexcept
Pre-increment operator.
Definition ip-any-iterator.hpp:134
constexpr inline reference operator*() const noexcept
Returns a reference to the current element.
Definition ip-any-iterator.hpp:95
constexpr inline ip_any_iterator & operator-=(difference_type n) noexcept
Subtraction assignment operator.
Definition ip-any-iterator.hpp:205
constexpr inline ip_any_iterator operator--(int) noexcept
Post-decrement operator.
Definition ip-any-iterator.hpp:165
An iterator for traversing IP addresses within a network range.
Definition ip-network-iterator.hpp:33
A reverse iterator template class for IP addresses.
Definition ip-address-iterator.hpp:35
A sequence container for subnet ranges within a network.
Definition ip-any-iterator.hpp:658
constexpr inline const_reverse_iterator crbegin() const noexcept
Gets the beginning const reverse iterator of the sequence.
Definition ip-any-iterator.hpp:751
constexpr inline value_type operator[](difference_type n) const noexcept
Accesses an element by index.
Definition ip-any-iterator.hpp:788
constexpr inline const_iterator begin() const noexcept
Gets the beginning iterator of the sequence.
Definition ip-any-iterator.hpp:697
constexpr inline bool empty() const noexcept
Checks if the sequence is empty.
Definition ip-any-iterator.hpp:769
constexpr inline value_type back() const noexcept
Accesses the last element in the sequence.
Definition ip-any-iterator.hpp:816
constexpr inline const_reverse_iterator crend() const noexcept
Gets the end const reverse iterator of the sequence.
Definition ip-any-iterator.hpp:760
constexpr inline value_type front() const noexcept
Accesses the first element in the sequence.
Definition ip-any-iterator.hpp:807
constexpr inline difference_type size() const noexcept
Gets the size of the sequence.
Definition ip-any-iterator.hpp:778
constexpr inline subnets_any_sequence(ip_network_iterator< ipv4_network > begin, ip_network_iterator< ipv4_network > end) noexcept
Constructs a subnets_any_sequence with specified network parameters.
Definition ip-any-iterator.hpp:680
constexpr inline const_reverse_iterator rend() const noexcept
Gets the end reverse iterator of the sequence.
Definition ip-any-iterator.hpp:724
constexpr inline const_iterator cend() const noexcept
Gets the end const iterator of the sequence.
Definition ip-any-iterator.hpp:742
constexpr inline const_iterator cbegin() const noexcept
Gets the beginning const iterator of the sequence.
Definition ip-any-iterator.hpp:733
constexpr inline const_iterator end() const noexcept
Gets the end iterator of the sequence.
Definition ip-any-iterator.hpp:706
constexpr inline value_type at(difference_type n) const noexcept
Accesses an element by index with bounds checking.
Definition ip-any-iterator.hpp:798
constexpr inline const_reverse_iterator rbegin() const noexcept
Gets the beginning reverse iterator of the sequence.
Definition ip-any-iterator.hpp:715
constexpr inline subnets_any_sequence(ip_network_iterator< ipv6_network > begin, ip_network_iterator< ipv6_network > end) noexcept
Constructs a subnets_any_sequence with specified network parameters.
Definition ip-any-iterator.hpp:689
constexpr inline uint128_t(long lower) noexcept
Constructs a uint128_t instance from a signed integer.
Definition uint128.hpp:205
inline std::u8string to_u8string(format fmt=format::decimal) const
Converts the uint128_t value to a string representation.
Definition uint128.hpp:402
#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
ip_version
Enumerates the IP address versions.
Definition ip-address-base.hpp:29
@ V4
IPv4 version identifier.
@ V6
IPv6 version identifier.