Verify tuple is a tuple of class objects?

Stewart Gordon smjg_1998 at yahoo.com
Fri Feb 18 18:27:36 PST 2011


On 18/02/2011 21:22, Steven Schveighoffer wrote:
<snip>
> template VerifyTuple(Types...)
> {
> static if(Types.length == 0)
> enum bool VerifyTuple = true;
> else
> enum bool VerifyTuple == is(Type : Object) && VerifyTuple!(Types[1..$]);
<snip>

You have two typos there.  Corrected version:

     enum bool VerifyTuple = is(Types[0] : Object) && VerifyTuple!(Types[1..$]);

But perhaps even nicer:

----------
template VerifyTuple() {
     enum bool VerifyTuple = true;
}

template VerifyTuple(T, Ypes...) {
     enum bool VerifyTuple = is(T : Object) && VerifyTuple!(Ypes);
}
----------

(Some of you will be able to guess what other language I've programmed in in my time from 
this.)

Stewart.


More information about the Digitalmars-d-learn mailing list