Skip to content

Instantly share code, notes, and snippets.

module e;
struct Date
{
//Make sure this is not a POD
this(this){}
short _year = 2;
ubyte _month = 1;
ubyte _day = 1;
}
module e;
struct Date
{
//Make sure this is not a POD
this(this){}
short _year = 2;
ubyte _month = 1;
ubyte _day = 1;
}
Dump of assembler code for function _Dmain:
0x0805c35c <+0>: push %ebp
0x0805c35d <+1>: mov %esp,%ebp
0x0805c35f <+3>: sub $0x8,%esp
0x0805c362 <+6>: mov 0x806f65c,%eax ;d = Date()
0x0805c367 <+11>: mov %eax,-0x8(%ebp) ;
0x0805c36a <+14>: lea -0x8(%ebp),%ecx ;ecx = &d
0x0805c36d <+17>: push %ecx
0x0805c36e <+18>: lea -0x4(%ebp),%eax ;eax = &copy
0x0805c371 <+21>: call 0x805c2dc <_D1e4Date8__cpctorMxFKxS1e4DateZv> ;copy = d, __postblit(copy)
struct Date
{
uint data;
~this(){data = 10;} //non-POD
this(this) {data = 42;}
}
void func(Date d) {d.data++;}
void main()
; AT&T syntax
Dump of assembler code for function _Dmain:
0x0805c3ac <+0>: push %ebp
0x0805c3ad <+1>: mov %esp,%ebp
0x0805c3af <+3>: sub $0x8,%esp
0x0805c3b2 <+6>: push %ebx
0x0805c3b3 <+7>: push %esi
0x0805c3b4 <+8>: push %edi
0x0805c3b5 <+9>: movl $0x2a,-0x8(%ebp) ;d = Date(42)
import std.string;
struct Date
{
this(int)
{
}
short _year = 2;
ubyte _month = 1;
ubyte _day = 1;
import std.string;
struct Date
{
this(int)
{
}
short _year = 2;
ubyte _month = 1;
ubyte _day = 1;
class RedBlackTree(alias less)
{
int a;
int nested()
{
return a;
}
struct Range
{
class RedBlackTree(alias less)
{
int a;
struct Range
{
auto @property empty()
{
return a;
}
}
class RedBlackTree(alias less)
{
int a;
struct Range
{
auto @property empty()
{
return a;
}
}