acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
bits.h
1#pragma once
2
3
4
5
6template < prototype_natural NATURAL >
7class bits
8{
9public:
10
11
12 NATURAL m_natural;
13
14
15 bits() { m_natural = 0; }
16 bits(no_initialize_t) {}
17 bits(NATURAL n) : m_natural(n) { }
18 bits(nullptr_t) { m_natural = 0; }
19
20
21 template < prototype_integral INTEGRAL >
22 inline bool is_set(INTEGRAL bit) const { return (m_natural >> (::u8) bit) & 1; }
23 template < prototype_integral INTEGRAL >
24 inline void set(INTEGRAL bit) { m_natural = m_natural | (NATURAL)(1ull << (::u8)bit); }
25 template < prototype_integral INTEGRAL >
26 inline void unset(INTEGRAL bit) { m_natural = m_natural & (NATURAL)(~(1ull << (::u8)bit)); }
27 template < prototype_integral INTEGRAL >
28 inline void set(INTEGRAL bit, bool bSet) { if (bSet) set(bit); else unset(bit); }
29
30
31 template < prototype_integral INTEGRAL >
32 bool operator [] (INTEGRAL bit) const { return is_set(bit); }
33
34
35};
36
37
Definition _tags.h:5