Const Ideas

Janice Caron caron800 at googlemail.com
Mon Dec 3 09:14:56 PST 2007


On 12/3/07, Craig Black <cblack at ara.com> wrote:
> Just to expound further, the pointer and reference syntax seems difference
> since the reference is implicit.  Just think of  "const X x;" as "const X&
> x;" and you will see that the same principle that applies to pointers should
> also apply to references.

Yes, I think we're on the same page here. Of course, only classes have
references. Structs don't, ints don't, etc., but for classes, my
preference would be for all four of the following to be exactly
equivalent:

    const C c;
    const(C) c;
    const C& c;
    const(C&) c;

(Which leaves open the possibility of "const(C)& c;" to mean mutable
ref to const data").

That's not the status quo, however



More information about the Digitalmars-d mailing list