Re: Where are the template members?

2012-12-05 Thread Simen Kjaeraas
On 2012-39-05 09:12, Gor Gyolchanyan wrote: Consider this piece of code: struct Test { template member(Type) { Type member; } } unittest { Test test; test.member!int = 0; test.member!long = 0; test.member!short = 0; import std.stdio; writeln(test.sizeof); assert(test.sizeof == int.sizeof + lo

Re: Where are the template members?

2012-12-05 Thread Timon Gehr
On 12/05/2012 09:51 AM, Simen Kjaeraas wrote: On 2012-39-05 09:12, Gor Gyolchanyan wrote: Consider this piece of code: struct Test { template member(Type) { Type member; } } unittest { Test test; test.member!int = 0; test.member!long = 0; test.member!short = 0; import std

Re: Where are the template members?

2012-12-05 Thread Timon Gehr
On 12/05/2012 10:06 AM, Gor Gyolchanyan wrote: ... Is there any good reason why this feature wouldn't be a good idea? ... Determining the size of a struct instance would require knowledge about all the code that uses the struct declaration.

Re: Where are the template members?

2012-12-05 Thread Gor Gyolchanyan
Aren't the template instances generated at the place of the template? The external code would instantiate the template, adding the instance information to the structure. Then the sizeof would just read the set of instantiated templates. This wouldn't require knowing about the code which instantiate

Re: Where are the template members?

2012-12-05 Thread Simen Kjaeraas
On 2012-43-05 10:12, Gor Gyolchanyan wrote: Aren't the template instances generated at the place of the template? The external code would instantiate the template, adding the instance information to the structure. Then the sizeof would just read the set of instantiated templates. This wouldn't

Re: Where are the template members?

2012-12-05 Thread Simen Kjaeraas
On 2012-09-05 10:12, Timon Gehr wrote: The confusion is caused by implicitly marking fields static during template instantiation instead of failing compilation. That is certainly a valid complaint. -- Simen

Re: Where are the template members?

2012-12-05 Thread Dmitry Olshansky
12/5/2012 12:39 PM, Gor Gyolchanyan пишет: Consider this piece of code: struct Test { template member(Type) { Type member; } } unittest { Test test; test.member!int = 0; test.member!long = 0; test.member!short = 0; import std.stdio; writeln(test.sizeof); assert(test.sizeof == int.sizeof + long.

Re: Where are the template members?

2012-12-05 Thread Rene Zwanenburg
On Wednesday, 5 December 2012 at 08:39:12 UTC, Gor Gyolchanyan wrote: Consider this piece of code: struct Test { template member(Type) { Type member; } } unittest { Test test; test.member!int = 0; test.member!long = 0; test.member!short = 0; import std.stdio; writeln(test.sizeof); assert(test.s

Re: Where are the template members?

2012-12-05 Thread Ali Çehreli
On 12/05/2012 12:39 AM, Gor Gyolchanyan wrote: > Consider this piece of code: > > struct Test > { > template member(Type) > { > Type member; > } That is just a template definition. It is not instantiated in this struct for any type. > } > > unittest > { > Test test; That is an object of an em

Re: Where are the template members?

2012-12-05 Thread deadalnix
On Wednesday, 5 December 2012 at 08:39:12 UTC, Gor Gyolchanyan wrote: Consider this piece of code: struct Test { template member(Type) { Type member; } } unittest { Test test; test.member!int = 0; test.member!long = 0; test.member!short = 0; import std.stdio; writeln(test.sizeof); assert(test.s