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
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
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.
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
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
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
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.
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
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
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
10 matches
Mail list logo