On Tuesday, 21 August 2018 at 21:29:38 UTC, Andrey wrote:
Hello,
This is a code:
(...)
test.handler =
That's an internal pointer, and internal pointers are not allowed
in structs precisely because of the issues you're running into:
the pointer will be invalid after a move.
On Wednesday, 22 August 2018 at 07:03:02 UTC, Andrey wrote:
but it is ugly...
You can write a type that will hide it.
On Wednesday, 22 August 2018 at 07:03:02 UTC, Andrey wrote:
On Tuesday, 21 August 2018 at 22:52:31 UTC, Alex wrote:
Maybe, like this:
Thank you but here you use heap to create ab object. I want
only on stack.
I know that one can do this:
test_handler.ptr = null;
and in place of call this:
On Tuesday, 21 August 2018 at 22:52:31 UTC, Alex wrote:
Maybe, like this:
Thank you but here you use heap to create ab object. I want only
on stack.
I know that one can do this:
test_handler.ptr = null;
and in place of call this:
handler.ptr = cast(void*)
but it is ugly...
Hmm, any
On Tuesday, 21 August 2018 at 21:29:38 UTC, Andrey wrote:
Hello,
This is a code:
import std.stdio;
struct Test
{
static Test opCall()
{
Test test;
test.handler =
return test;
}
void one() const { writeln("In handler: Address = ", ,
"; Text = ", text); }
Hello,
This is a code:
import std.stdio;
struct Test
{
static Test opCall()
{
Test test;
test.handler =
return test;
}
void one() const { writeln("In handler: Address = ", ,
"; Text = ", text); }
void execute()
{
text = "Inited!";