Q about template function overloads
Bill Baxter
dnewsgroup at billbaxter.com
Sun Dec 17 18:09:05 PST 2006
Gah, sorry to continue this monologue, but apparently my belief that the
dummy trick wouldn't work ALSO came from a manifestation of bug 688.
This *does* work:
FooStruct!(T) func(T)(FooStruct!(T) a) {
writefln("Calling FooStruct version");
return a;
}
FooStruct!(T) func(dumm=void,T)(T[] a) {
FooStruct!(T) ret;
writefln("Calling [] version");
return ret;
}
I think I'm going to have to put my blas/lapack array math module on
hold for a bit till this bug gets fixed. The errors and workarounds are
becoming a little too detrimental to productivity.
--bb
Bill Baxter wrote:
> Bill Baxter wrote:
>
>> Also how do I write the equivalent of this:
>>
>> static if( is( T S: S[]) ) {
>> alias Array!(S) _ArrayTForT;
>> }
>>
>> For the case where T is a user-defined array type:
>> /// doesn't work!
>> static if( is( T S: Array!(S)) ) {
>> alias Array!(S) _ArrayTForT;
>> }
>> It really shouldn't just be an "else" catch-all in the code above. It
>> should be checking for an instantiation of Array!().
>
> This second part of my question seems to be a result of bug 688[1]. That
> is, the check 'is(T S:Array!(S))' *does* work if Array is a struct, just
> not if it's a class.
>
> But I would still be interested in any suggestions for how to do the
> overloading in a more elegant way.
>
> [1] http://d.puremagic.com/issues/show_bug.cgi?id=688
>
> --bb
More information about the Digitalmars-d-learn
mailing list