-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.h
More file actions
48 lines (39 loc) · 680 Bytes
/
index.h
File metadata and controls
48 lines (39 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef INDEX_H__
#define INDEX_H__
template<class T>
class idx
{
public:
static inline DWORD max()
{
return ((1 << (sizeof(T) * 8)) - 1);
}
static inline size_t from_symbol(T symbol)
{
return ((size_t)symbol + 1);
//return ((symbol) - '0');
}
static inline T to_symbol(DWORD index)
{
//return ((char)index + '0');
return ((T)index - 1 );
}
};
template<>
class idx<bit>
{
public:
static inline DWORD max()
{
return (2);
}
static inline size_t from_symbol(bit symbol)
{
return (symbol ? 2 : 1);
}
static inline bit to_symbol(DWORD index)
{
return ((index == 0) ? 0 : 1);
}
};
#endif //INDEX_H__