Template constraints: opCmp and opUnary!"++"
Philippe Sigaud
philippe.sigaud at gmail.com
Fri Dec 20 08:32:28 PST 2013
> fails to compile for both integers and my defined types.
> I read the "D Templates: A Tutorial" book and as far as I can tell
> "++B.init" and "B.init < E.init" doesn't look too much wrong, but I've not
> seen any constraint of this kind in phobos (using variables instead of
> types) so I was wondering if doing something like this is actually bad or
> even really bad. (And I also wonder how to properly setting those
> constraints directly on types)
You could put the target code inside a anonymous block and use
__traits(compiles, ...), like this:
if (__traits(compiles, {
B begin;
E end;
++begin;
bool stop = begin < end;
}))
I never hade any problem by using Type.init, that's strange.
More information about the Digitalmars-d-learn
mailing list