Struct reference returning function and const members

Michel Fortin michel.fortin at michelf.com
Thu Mar 3 04:19:14 PST 2011


On 2011-03-03 01:42:18 -0500, Tom <tom at nospam.com> said:

> I have...
> 
> int main(string[] args) {
> 	auto s1 = f(); // MH MH
> 	auto s2 = g(); // OK
> 	s2.c = null; // OK
> 	return 0;
> }

I think the compiler complains because the s1.c member is not 
assignable (since it is const), so you can't assign to s1 as a whole. 
That said, it should probably be allowed for an initialization 
assignment like this one. I suggest you add it to the bug tracker.
<http://d.puremagic.com/issues/>


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



More information about the Digitalmars-d-learn mailing list