View source code
Display the source code in std/bitmanip.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone.

Enum member std.bitmanip.taggedClassRef

This string mixin generator allows one to create tagged class reference inside structs and classes.

enum taggedClassRef(T, string name, Ts...) = createTaggedReference!(T, 8, name, Ts);

A tagged class reference uses the bits known to be zero in a normal class reference to store extra information. For example, a pointer to an integer must be 4-byte aligned, so there are 2 bits that are always known to be zero. One can store a 2-bit integer there.

The example above creates a tagged reference to an Object in the struct A. This expects the same parameters as taggedPointer, except the first argument which must be a class type instead of a pointer type.

Example

struct A
{
    int a;
    mixin(taggedClassRef!(
        Object, "o",
        uint, "i", 2));
}
A obj;
obj.o = new Object();
obj.i = 3;

Authors

Walter Bright, Andrei Alexandrescu, Jonathan M Davis, Alex Rønne Petersen, Damian Ziemba, Amaury SECHET

License

Boost License 1.0.