Make all functions from std.typecons "Proxy" inout

sclytrack sclytrack at iq87.fr
Fri May 11 04:43:31 PDT 2012


On 05/11/2012 11:51 AM, sclytrack wrote:
>
>> struct S
>> {
>> void f() {}
>> void f() const{}
>> void f() immutable {}
>> void f() shared {}
>> void f() shared const {}
>> }
>> struct Proxy(T)
>> {
>> T o;
>>
>
>
> I'm new to the concept of "shared const". What is the difference when
> comparing to "immutable"?
>

And to answer myself.



import std.stdio;

void test1(shared const float [] p)
{
	writeln("works");
}


int main()
{
	writeln("--");

	shared(const(int)) a;
	const(shared(int)) b;
	immutable int c;
	writeln(typeof(a).stringof);
	writeln(typeof(b).stringof);
	writeln(typeof(c).stringof);
	
	writeln("--");
	shared(const(int []) []) aa;
	shared(immutable(int []) []) ab;
	writeln(typeof(aa).stringof);
	writeln(typeof(ab).stringof);
		
	writeln("--");
	const(shared(int []) []) ba;
	immutable(shared(int []) []) bb;
	writeln(typeof(ba).stringof);
	writeln(typeof(bb).stringof);
	
	writeln("--");
	
	shared float [] sm = new shared(float[10]);
	test1(sm);
	immutable float [] im = new immutable(float[10]);
	test1(im);	
		
	return 0;
}


--
shared(const(int))
shared(const(int))
immutable(int)
--
shared(const(int[])[])
shared(immutable(int[])[])
--
const(shared(int[])[])
immutable(int[][])
--
works
works


More information about the Digitalmars-d-learn mailing list