const functions in D 2.0

Jarrett Billingsley kb3ctd2 at yahoo.com
Mon Nov 5 17:07:29 PST 2007


"Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message 
news:fgoak7$24ao$1 at digitalmars.com...
> How does one declare const/invariant member functions in D 2.0 that don't 
> return void?  If it's just prefixing, how does one declare const/invariant 
> functions that return const/invariant references?
>
> The web site isn't very helpful on this matter.
>
> -Steve
>

const Bar foo()
{
    // returns a non-const Bar, but can't modify this.
}

const const(Bar) foo()
{
    // returns a const(Bar).
}

At least I'm pretty sure. 




More information about the Digitalmars-d-learn mailing list