transporting qualifier from parameter to the return value

Michel Fortin michel.fortin at michelf.com
Wed Dec 16 06:21:16 PST 2009


On 2009-12-16 08:54:03 -0500, "Denis Koroskin" <2korden at gmail.com> said:

>> I just realized that 'inout' could have a real use even for functions  
>> with no return value. Consider this:
>> 
>> 	void doSomething(inout(Object)[] a, inout(Object)[] b) {
>> 		a[0] = b[0]; // works only when objects in both arrays have the same  
>> constness.
>> 	}
> 
> Doesn't work.
> 
> doSomething("hello", "world");

Well, of course it doesn't...

Here's what I meant:

	void doSomething(inout(MyStruct)*[] a, inout(MyStruct)*[] b) {
		a[0] = b[0]; // works only when structs in both arrays have the same 
constness.
	}

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




More information about the Digitalmars-d mailing list