mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 05:00:16 +03:00
36 lines
390 B
D
36 lines
390 B
D
struct Thing
|
|
{
|
|
this(int* i)
|
|
{
|
|
ptr = i;
|
|
(*ptr)++;
|
|
}
|
|
|
|
~this()
|
|
{
|
|
(*ptr)--;
|
|
}
|
|
|
|
T opCast(T : bool)()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
int* ptr;
|
|
}
|
|
|
|
Thing makeThing(int* p)
|
|
{
|
|
return Thing(p);
|
|
}
|
|
|
|
void main()
|
|
{
|
|
int i;
|
|
{
|
|
if (auto t = makeThing(&i)) // destructor not called
|
|
{
|
|
}
|
|
}
|
|
assert(i == 0);
|
|
}
|