Flags

Struct holding multiple named boolean values in a single byte.

Can hold at most 8 values.

package
struct Flags (
names...
) if (
names.length <= 8
) {}

Examples

1 Flags!("empty", "multiline") flags;
2 assert(flags.empty == false && flags.multiline == false);
3 flags.multiline = true;
4 assert(flags.empty == false && flags.multiline == true);
5 flags.empty = true;
6 assert(flags.empty == true && flags.multiline == true);
7 flags.multiline = false;
8 assert(flags.empty == true && flags.multiline == false);
9 flags.empty = false;
10 assert(flags.empty == false && flags.multiline == false);

Flag accessors.

1 import std.stdio;
2 writeln("Flags unittest");
3 
4 Flags!("empty", "multiline") flags;
5 assert(flags.empty == false && flags.multiline == false);
6 flags.multiline = true;
7 assert(flags.empty == false && flags.multiline == true);
8 flags.empty = true;
9 assert(flags.empty == true && flags.multiline == true);
10 flags.multiline = false;
11 assert(flags.empty == true && flags.multiline == false);
12 flags.empty = false;
13 assert(flags.empty == false && flags.multiline == false);

Meta