Template Prerequisite proposal
Robert Fraser
fraserofthenight at gmail.com
Mon Sep 17 23:40:48 PDT 2007
DavidL Wrote:
> For common case:
>
> template k(T)
> {
> static assert(T.max==int.max);
> }
To test types, you could just use the "is" expression (unless there was a special reason you were comparing to int.max?):
static assert(is(T == int)); // Compilation will fail if T is not int
static assert(is(U : Lion)); // Compilation will fail if U is not implicitly castable to Lion
>
> template a(T)
> {
> void func(T t)
> in
> {
> mixin k!(T);
> }
> body
> {
> }
> }
>
> mixin a!(int);
>
>
> so there's a unified way of mixin template for prerequisite checking.
>
> I hope if there's any way of restrict template writer write code which only uses things which are checked in the prerequisite checking.
I'm not sure exactly what you mean. Example?
More information about the Digitalmars-d
mailing list