Hybrid ICN (hICN) plugin
v21.06-rc0-4-g18fa668
libtransport
includes
hicn
transport
utils
enum_iterator.h
1
/*
2
* Copyright (c) 2021 Cisco and/or its affiliates.
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at:
6
*
7
* http://www.apache.org/licenses/LICENSE-2.0
8
*
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
14
*/
15
16
#include <type_traits>
17
18
template
<
typename
C, C begin_val, C end_val>
19
class
Iterator
{
20
typedef
typename
std::underlying_type<C>::type val_t;
21
int
val;
22
23
public
:
24
Iterator
(
const
C& f) : val(
static_cast<
val_t
>
(f)) {}
25
26
Iterator
() : val(
static_cast<
val_t
>
(begin_val)) {}
27
28
Iterator
operator++() {
29
++val;
30
return
*
this
;
31
}
32
33
C operator*() {
return
static_cast<
C
>
(val); }
34
35
Iterator
begin() {
return
*
this
; }
// default ctor is good
36
37
Iterator
end() {
38
static
const
Iterator
endIter = ++
Iterator
(end_val);
// cache it
39
return
endIter;
40
}
41
42
bool
operator!=(
const
Iterator
& i) {
return
val != i.val; }
43
};
Iterator
Definition:
enum_iterator.h:19
Generated by
1.8.17