| Thread overview | |||||
|---|---|---|---|---|---|
|
December 12, 2013 Creating a class at a specific address in memory. | ||||
|---|---|---|---|---|
| ||||
What i am looking for is something like the following.
class Foo
{
int a, b, c;
}
void main() {
void[] buffer = new void[1024];
auto foo = createAt!(Foo)(buffer.ptr);
}
Where the createAt!(Foo) creates a class of the type Foo at the
specified pointer.
| ||||
December 12, 2013 Re: Creating a class at a specific address in memory. | ||||
|---|---|---|---|---|
| ||||
Posted in reply to TheFlyingFiddle | On Thursday, 12 December 2013 at 22:54:26 UTC, TheFlyingFiddle wrote: > What i am looking for is something like the following. > > class Foo > { > int a, b, c; > } > > void main() { > void[] buffer = new void[1024]; > auto foo = createAt!(Foo)(buffer.ptr); > } > > > Where the createAt!(Foo) creates a class of the type Foo at the > specified pointer. emplace() is what you are looking for (found inexplicably in std.conv). http://dlang.org/phobos/std_conv.html#.emplace | |||
December 12, 2013 Re: Creating a class at a specific address in memory. | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Brad Anderson | > emplace() is what you are looking for (found inexplicably in std.conv).
>
> http://dlang.org/phobos/std_conv.html#.emplace
Exactly what i wanted :) Thanks for the quick answer!
And yeah... std.conv seems like a wierd place to have this functionallity.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply