[OT] Generative C++

Kagamin via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 29 02:06:34 PDT 2017


On Friday, 28 July 2017 at 19:20:31 UTC, 12345swordy wrote:
> Reading through the dlang documentation, I can't find a way to 
> enforce a certain code standard using mixins _traits ctfe.
>
> Imo it's very beneficial to have coding standards enforce by 
> compile time.

Typical way to enforce patterns are traits like isInputRange.
You do something like
static assert(isInputRange!MyRange);
and it checks whether the type follows the pattern.
It can't see inside function body though, only member 
declarations. P0707 works with declarations too, it uses 
declarative macros to generate code because it doesn't propose to 
reflect on function body.


More information about the Digitalmars-d mailing list