D2.0 const this methods
Walter Bright
newshound1 at digitalmars.com
Mon Jun 18 02:21:36 PDT 2007
Bill Baxter wrote:
> From the const page docs
> class Foo {
> invariant int foo() {
> ...
> }
> }
>
> makes 'this' and the return value invariant.
No. invariant as a storage class on a member function only makes the
member function invariant, it does not affect the return type.
> So what if I want to make a method that returns a const ptr/ref but
> modifies 'this'?
const(int)* foo() { ... }
More information about the Digitalmars-d
mailing list