Concepts for D

Package Information

Version 0.0.3 (2017-Jan-10)
License BSD
Copyright Copyright © 2016, atila
Authors Atila Neves
Registered by Atila Neves
Dependencies none


To use this package, put the following dependency into your project's dependencies section:



Concepts for D

Build Status

Right now there's only models, which can be used as a UDA or in a static assert:

    void checkFoo(T)()
        T t = T.init;;

    enum isFoo(T) = is(typeof(checkFoo!T));

    @models!(Foo, isFoo) //as a UDA
    struct Foo
        void foo() {}
        static assert(models!(Foo, isFoo)); //as a static assert

Here a template constraint isFoo is guaranteed to be true for type Foo. The difference between this and a regular static assert is that when the predicate fails the code for checkFoo is instantiated anyway so that the user knows why it failed to compile.

Available versions

0.0.3 0.0.2 0.0.1 ~master