Resolving conflicting functions
Bill Baxter
dnewsgroup at billbaxter.com
Mon Dec 3 23:26:26 PST 2007
Daniel Keep wrote:
>
> 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
Here's my take:
http://www.dsource.org/projects/openmeshd/browser/trunk/OpenMeshD/OpenMesh/Core/Geometry/MatrixT.d
Look for "MultReturnType". :-)
I could try to make it more generic but just getting it to work with a
specific vector type and matrix type was annoying enough for me.
--bb
More information about the Digitalmars-d-learn
mailing list