Re: How to copy an object to separate allocated memory?

2014-07-24 Thread Justin Whear via Digitalmars-d-learn
On Thu, 24 Jul 2014 17:05:17 +, Gary Willoughby wrote:

 I was reading Ali's book (http://ddili.org/ders/d.en/index.html)
 and saw this piece of code on how to get the true size of an object:
 
 MyClass* buffer = cast(MyClass*)GC.calloc(__traits(classInstanceSize,
 MyClass) * 10);
 
 That got me thinking, how would i actually 'fill' this memory with
 instances of that class?

std.conv.emplace: http://dlang.org/phobos/std_conv.html#.emplace


How to copy an object to separate allocated memory?

2014-07-24 Thread Gary Willoughby via Digitalmars-d-learn
I was reading Ali's book (http://ddili.org/ders/d.en/index.html) 
and saw this piece of code on how to get the true size of an 
object:


MyClass* buffer = 
cast(MyClass*)GC.calloc(__traits(classInstanceSize, MyClass) * 
10);


That got me thinking, how would i actually 'fill' this memory 
with instances of that class?


Re: How to copy an object to separate allocated memory?

2014-07-24 Thread Daniel Gibson via Digitalmars-d-learn

Am 24.07.2014 19:05, schrieb Gary Willoughby:

I was reading Ali's book (http://ddili.org/ders/d.en/index.html) and saw
this piece of code on how to get the true size of an object:

MyClass* buffer = cast(MyClass*)GC.calloc(__traits(classInstanceSize,
MyClass) * 10);

That got me thinking, how would i actually 'fill' this memory with
instances of that class?


std.conv.emplace()


Re: How to copy an object to separate allocated memory?

2014-07-24 Thread John Colvin via Digitalmars-d-learn

On Thursday, 24 July 2014 at 17:05:18 UTC, Gary Willoughby wrote:
I was reading Ali's book 
(http://ddili.org/ders/d.en/index.html) and saw this piece of 
code on how to get the true size of an object:


MyClass* buffer = 
cast(MyClass*)GC.calloc(__traits(classInstanceSize, MyClass) * 
10);


That got me thinking, how would i actually 'fill' this memory 
with instances of that class?


std.conv.emplace


Re: How to copy an object to separate allocated memory?

2014-07-24 Thread Justin Whear via Digitalmars-d-learn
On Thu, 24 Jul 2014 17:07:29 +, Justin Whear wrote:

 On Thu, 24 Jul 2014 17:05:17 +, Gary Willoughby wrote:
 
 I was reading Ali's book (http://ddili.org/ders/d.en/index.html)
 and saw this piece of code on how to get the true size of an object:
 
 MyClass* buffer = cast(MyClass*)GC.calloc(__traits(classInstanceSize,
 MyClass) * 10);
 
 That got me thinking, how would i actually 'fill' this memory with
 instances of that class?
 
 std.conv.emplace: http://dlang.org/phobos/std_conv.html#.emplace

Wow, the ninja'ing is strong today.