Resolving conflicting functions

Bill Baxter dnewsgroup at billbaxter.com
Tue Dec 4 10:06:23 PST 2007


BCS wrote:
> Reply to Daniel,
> 
>> Derek Parnell wrote:
>>
>>> On Tue, 04 Dec 2007 11:18:56 +0900, Bill Baxter wrote:
>>>
>>>> You'll have to make it. A little static if template like
>>>>
>>>> template Ret(T) {
>>>> static if (is(T==Currency)) { alias real Ret; }
>>>> else { alias Currency Ret; }
>>>> }
>>> I almost go it right. Yes this works. There has got to be a better
>>> way!
>>>
>> You think that's bad; try doing it for a matrix library where the
>> return type depends on the input types which contain a mix of scalars,
>> vectors, matrices and transforms (special matrices which have an
>> implicit final row.)
>>
>> Hopefully the promised overloading upgrades will help with this.
>>
>> -- Daniel
>>
> 
> this would be a nice place to have auto:
> 
> 
> auto Fn(A, B, C)(A a, B b, C c)
> {
> /// lots-o-logic
> 
>   return ret; // return type defined here.
> }

Yeh, that does look more in line with D than sticking a typeof(return) 
out front.

--bb


More information about the Digitalmars-d-learn mailing list