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

Flags!("empty", "multiline") flags;
assert(flags.empty == false && flags.multiline == false);
flags.multiline = true;
assert(flags.empty == false && flags.multiline == true);
flags.empty = true;
assert(flags.empty == true && flags.multiline == true);
flags.multiline = false;
assert(flags.empty == true && flags.multiline == false);
flags.empty = false;
assert(flags.empty == false && flags.multiline == false);

Flag accessors.

import std.stdio;
writeln("Flags unittest");

Flags!("empty", "multiline") flags;
assert(flags.empty == false && flags.multiline == false);
flags.multiline = true;
assert(flags.empty == false && flags.multiline == true);
flags.empty = true;
assert(flags.empty == true && flags.multiline == true);
flags.multiline = false;
assert(flags.empty == true && flags.multiline == false);
flags.empty = false;
assert(flags.empty == false && flags.multiline == false);

Meta