"Error: address of variable this assigned to this with longer lifetime"
Nathan S.
no.public.email at example.com
Tue Mar 13 20:49:16 UTC 2018
What is this malarky?
https://run.dlang.io/is/S42EBb
"onlineapp.d(16): Error: address of variable this assigned to
this with longer lifetime"
```d
import std.stdio;
struct SmallString
{
char[24] small;
char[] data;
@disable this();
this(scope const(char)[] s) @safe
{
if (s.length < small.length)
{
small[0 .. s.length] = s[];
small[s.length] = 0;
data = small[0 .. s.length];
}
else
{
assert(0, "Compilation failed before I wrote this.");
}
}
}
void main()
{
writeln("Hello D");
}
```
More information about the Digitalmars-d-learn
mailing list