bolts.experimental.signatures

Provides utilites that allow you to enforce signatures - a specification for a structure

Members

Mixin templates

Models
mixintemplate Models(alias Sig, string file = __FILE__, int line = __LINE__)

Mixin that ensures a type models the desired signature of a structure

Structs

ignoreAttributes
struct ignoreAttributes

Attribute that can be applied on identifiers in a signature that will let the model checker know not to take attributes in to account

ignoreQualifiers
struct ignoreQualifiers

Attribute that can be applied on identifiers in a signature that will let the model checker know not to take type qualifiers in to account

Templates

AssertModelOf
template AssertModelOf(alias _Model, alias _Sig, string file = __FILE__, int line = __LINE__)

Asserts that the given model follows the specification of the given signature

isModelOf
template isModelOf(alias _Model, alias _Sig)

Checks if type Model is a model of type Sig

Examples

interface InputRange(T) {
    @property bool empty();
    @property T front();
    @ignoreAttributes void popFront();
}

struct R(T) {
    mixin Models!(InputRange!T);

    T[] values;
    int index;
    this(T[] arr) {
        values = arr;
    }
    @property bool empty() {
        return values.length == index;
    }
    @property T front() {
        return values[index];
    }
    void popFront() {
        index++;
    }
}

import std.range: array;
auto r = R!int([1, 4, 2, 3]);
assert(r.array == [1, 4, 2, 3]);

Meta