const and non-const member function

Christian Kamm kamm.incasoftware at shift-at-left-and-remove-this.de
Thu Jul 26 01:37:43 PDT 2007


>> I'd probably disallow const Foo in parameter declarations, yet don't know
>> how to do make the method-const look different.
> 
> How about this for method-const:
> ---
> Foo const(func)(const Foo) {
>      // ...
> }
> ---
> Though I guess that may look too much like the const(Type) notation...

I thought the same thing: putting the const/invariant after the return type
might be okay

---
Foo const func(const(Foo))
---

but the current way of doing it has the merit of allowing

---
const {
 void func1();
 void func2();
}
---

which'd be odd to explain with the const being anywhere but in the very
front.



More information about the Digitalmars-d-learn mailing list