You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-1Lines changed: 38 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,6 +45,7 @@ int main() {
45
45
46
46
* [Motivation](#motivation)
47
47
* [Getting Started](#getting-started)
48
+
* [Raw flags vs flags](#raw-flags-vs-flags)
48
49
* [How to Declare Set of Flags?](#how-to-declare-set-of-flags)
49
50
* [Bits and Names](#bits-and-names)
50
51
* [Bitwise Operators](#bitwise-operators)
@@ -94,9 +95,29 @@ _So, why should I use `bitflags` library?_
94
95
95
96
`bitflags` is a single-header header-only C++17 library for easily managing set of auto-generated type-safe flags.
96
97
98
+
### Raw flags vs flags?
99
+
100
+
`bitflags` library provides you with 2 flag types:
101
+
102
+
-__raw_flag__ without its string representation (sort of lightweight version)
103
+
-__flag__ with its string representation
104
+
97
105
### How to Declare Set of Flags?
98
106
99
-
In order to declare a set of auto-generated flags, there are few helper macros that hide kind of "ugly" declaration syntax and provide auto-generated value for each flag:
107
+
In order to declare a set of auto-generated flags, there are few helper macros that hide kind of "ugly" declaration syntax and provide auto-generated value for each flag.
108
+
109
+
Macros for creating set of raw flags, i.e. flags __without__ string representation:
110
+
111
+
*`BEGIN_RAW_BITFLAGS(NAME)`
112
+
-`NAME` - name of set of raw flags
113
+
114
+
*`RAW_FLAG(NAME)`
115
+
-`NAME` - name of specific raw flag
116
+
117
+
*`END_RAW_BITFLAGS(NAME)`
118
+
-`NAME` - name of set of raw flags
119
+
120
+
Macros for creating set of ordinary flags, i.e. flags __with__ string representation:
100
121
101
122
*`BEGIN_BITFLAGS(NAME)`
102
123
-`NAME` - name of set of flags
@@ -139,10 +160,26 @@ using Flags = bf::bitflags<
139
160
>;
140
161
```
141
162
163
+
Usage is basically the same for `raw_flag`s.
164
+
142
165
### Bits and Names
143
166
167
+
While bits are part of both `raw_flag` and `flag`, names are part of `flag` type only.
168
+
144
169
Once the flags are specified, it is possible to get bits representing each flag as well as string representation of each flag:
0 commit comments