opMul
Bill Baxter
dnewsgroup at billbaxter.com
Sun Mar 2 17:01:09 PST 2008
Simen Kjaeraas wrote:
> On Sun, 02 Mar 2008 20:10:23 +0100, Denton Cockburn <diboss at hotmail.com>
> wrote:
>
>> Is there a reason why opMul cannot be called on a constant object?
>>
>> This restriction is hardcoded (I clearly don't have a choice for my
>> object).
>
>
> That would be due to opMul not being defined as a const function.
>
>
> import std.stdio;
>
> struct Foo1
> {
> int bar;
>
> Foo1 opMul(int rhs)
> {
> bar *= rhs;
> return *this;
> }
> }
>
> struct Foo2
> {
> int bar;
>
> Foo2 opMul(int rhs) const // difference here
> {
> bar *= rhs;
> return *this;
> }
> }
I can't keep up here. Is a trailing 'const' legal D syntax now?
--bb
More information about the Digitalmars-d
mailing list