I have a Currency data type,based on a struct.
I want to divide a Currency value by a scalar to return a Currency and
I want to divide a Currency value by another Currency value to return
a scalar. This below is my attempt but fails to compile. How does one
do this?
// ------------------------
real opDiv(Currency pFactor)
// ------------------------
{
return mData / pFactor.mData;
}
// ------------------------
Currency opDiv(T)(T pFactor)
// ------------------------
{
Currency temp;
temp = this.mData / pFactor;
return temp;
}
I get the message ...
template Currency.opDiv(T) conflicts with function Currency.opDiv

I have a Currency data type,based on a struct.
I want to divide a Currency value by a scalar to return a Currency and
I want to divide a Currency value by another Currency value to return
a scalar. This below is my attempt but fails to compile. How does one
do this?
// ------------------------
real opDiv(Currency pFactor)
// ------------------------
{
return mData / pFactor.mData;
}
// ------------------------
Currency opDiv(T)(T pFactor)
// ------------------------
{
Currency temp;
temp = this.mData / pFactor;
return temp;
}
I get the message ...
template Currency.opDiv(T) conflicts with function Currency.opDiv

Turning the plain opDiv into a template with a different number of
arguments might work too:
// ------------------------
real opDiv(T=void,S=void)(Currency pFactor)
// ------------------------
{
return mData / pFactor.mData;
}
// ------------------------
Currency opDiv(T)(T pFactor)
// ------------------------
{
Currency temp;
temp = this.mData / pFactor;
return temp;
}
I say might because I'm not really sure when that trick works and when
it doesn't. I posted a question about it a while back but it seems no
one else knows exactly how it works either. (Or, more likely, they just
found the question too boring. ;-)
--bb

I have a Currency data type,based on a struct.
I want to divide a Currency value by a scalar to return a Currency and
I want to divide a Currency value by another Currency value to return
a scalar. This below is my attempt but fails to compile. How does one
do this?
// ------------------------
real opDiv(Currency pFactor)
// ------------------------
{
return mData / pFactor.mData;
}
// ------------------------
Currency opDiv(T)(T pFactor)
// ------------------------
{
Currency temp;
temp = this.mData / pFactor;
return temp;
}
I get the message ...
template Currency.opDiv(T) conflicts with function Currency.opDiv

Turning the plain opDiv into a template with a different number of
arguments might work too:
// ------------------------
real opDiv(T=void,S=void)(Currency pFactor)
// ------------------------
{
return mData / pFactor.mData;
}
// ------------------------
Currency opDiv(T)(T pFactor)
// ------------------------
{
Currency temp;
temp = this.mData / pFactor;
return temp;
}
I say might because I'm not really sure when that trick works and when
it doesn't. I posted a question about it a while back but it seems no
one else knows exactly how it works either. (Or, more likely, they just
found the question too boring. ;-)
--bb

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

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

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

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

I have a Currency data type,based on a struct.
I want to divide a Currency value by a scalar to return a Currency and
I want to divide a Currency value by another Currency value to return
a scalar. This below is my attempt but fails to compile. How does one
do this?
// ------------------------
real opDiv(Currency pFactor)
// ------------------------
{
return mData / pFactor.mData;
}
// ------------------------
Currency opDiv(T)(T pFactor)
// ------------------------
{
Currency temp;
temp = this.mData / pFactor;
return temp;
}
I get the message ...
template Currency.opDiv(T) conflicts with function Currency.opDiv