PROPOSAL: Operator overloading by static member function
BCS
ao at pathlink.com
Sun Oct 14 06:39:43 PDT 2007
Reply to Benjamin,
> Reply to Daniel,
>
>> struct Meters
>> {
>> real value;
>> }
>> struct m
>> {
>> static Meters opMul_r(real value)
>> {
>> return Meters(value);
>> }
>> }
>> auto distance = 20*m;
>> In your system, there's no way to have that since you can't have type
>> arguments. And *yes*, there are people who use this kind of thing.
>>
> struct SIUnit(int d, int t, int m, int c=0, int k=0, int l=0)
> {
> static Meters opMul_r(real value)
> {
> }
> }
> const m = SIUnit!(1,0,0)(1.0);
>
I think I misread that (and I know I mistyped it):
struct SIUnit(int d, int t, int m, int c=0, int k=0, int l=0)
{
}
SIUnit!(d, t, m, c, k, l) opMul(int d, int t, int m, int c, int k, int l)(real
value, SIUnit!(d, t, m, c, k, l) v2)
{
}
More information about the Digitalmars-d
mailing list