Hmm - about manifest/enum

Steven Schveighoffer schveiguy at yahoo.com
Mon Dec 31 11:29:20 PST 2007


"Janice Caron" wrote
> On 12/31/07, Steven Schveighoffer wrote:
>> Except in the case of class references, right?  I find this to be the 
>> most
>> unacceptable ommision.
>
> But when are you /ever/ going to need such a thing in a real-life use
> case, that you couldn't just code differently?

How about doing an in-place sort of an array of const classes?

const(C)[] myarray;

...
// swap two items i and j
auto tmp = myarray[i];
myarray[i] = myarray[j]; // error
myarray[j] = tmp; // error
...

Before you answer, building another array isn't acceptable, because that is 
a waste of resources and adds runtime.

Tell me how you do this without having tail-const for class references.  I 
couldn't care less about tail-const for structs, or tail-const for class 
instances (being defined as a state where the members of the class/struct 
are mutable, but any objects pointed to by its members are const).  This 
feature of being able to swap two references to const data is a very common 
algorithmic requirement.

-Steve 





More information about the Digitalmars-d mailing list