stuck on opDiv / opBinary
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Aug 31 15:07:26 PDT 2015
On 8/30/15 3:45 PM, Spacen Jasset wrote:
> On Sunday, 30 August 2015 at 18:12:40 UTC, BBasile wrote:
>> On Sunday, 30 August 2015 at 17:02:58 UTC, Spacen Jasset wrote:
>>> [...]
>>
>> try
>>
>> ---
>> Vector3 opBinary(string op)(Vector3 rhs)
>> {
>> static if (op =="/"){}
>> else static assert(0, op ~ " not implemented");
>> }
>> ---
>>
>> you used the char litteral delims ('') instead of the strings ones ("").
>
> Ah yes, it's didnt' complain.
Actually, that sounds like a bug to me. Trying to compare a string
against a character should be an error, even in compile time constraint
I would think.
> But anyway that was the wrong funciton I
> implemented.
Yes, but still you should use opBinary, even though the D1 versions will
likely exist forever. It can tremendously cut down on your code size,
and reduce your exposure to simple copy/paste bugs.
-Steve
More information about the Digitalmars-d-learn
mailing list