const(Object)ref is here!

Michel Fortin michel.fortin at michelf.com
Tue Dec 7 09:54:17 PST 2010


On 2010-12-07 11:15:33 -0500, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> On 12/7/10 7:05 AM, Michel Fortin wrote:
>> From my tests, templates work as they should. For instance, I can
>> easily call std.algorithm.sort on an array of const(Object)ref.
> 
> Does it work on a general random-access range?

It should. Let's try:

	auto array = new const(Object)ref[12];
    auto range = retro(array);
	sort!("cast(void*)a < cast(void*)b")(range);

Compiles and runs with no error. Also, if I put actual objects in the 
array, I can see they're properly sorted.


> Generally, does the feature have a solution for all issues discussed?

It fixes all issues about mutable references to const classes that I 
can think of. But it's hard to see if I missed something without a 
proper checklist.


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list