Params

Represents a set of flags built from an enum intended to be used at compile-time for configuring the behaviour of templates, mixins, or other compile-time features.

Credit to Ethan Watson and his wonderful DConf 2019 talk for this idea.

Constructors

this
this(inout(T)[] flags)

Constructs a new parameter set from the specified overrides.

this
this(Self other)

Copy constructor.

Members

Functions

opBinary
bool opBinary(T rhs)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
bool opBinary(Self rhs)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
Self opBinary(T rhs)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
Self opBinary(Self rhs)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinaryRight
bool opBinaryRight(T lhs)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinaryRight
Self opBinaryRight(T lhs)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinaryRight
bool opBinaryRight(T lhs)
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

all
Self all()

Constructs a new parameter set from all possible values.

Examples

enum MyConfig : string
{
    someOption = "do something cool, like a barrel roll",
    lazyProcessing = "be as lazy as possible"
}

alias MyParams = Params!MyConfig;

struct SomeStruct( MyParams params = MyParams.init )
{
    static if( params.someOption )
    {
        // do something cool...
    }

    static if( params.lazyProcessing )
    {
        // ...
    }
}

See Also

Meta

Authors

Tony J. Hudgins