Click here to Skip to main content
15,909,539 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Database question Pin
Tomasz Sowinski28-May-01 0:57
Tomasz Sowinski28-May-01 0:57 
GeneralRe: Database question Pin
Tomasz Sowinski28-May-01 1:09
Tomasz Sowinski28-May-01 1:09 
GeneralRe: Database question Pin
Christian Graus28-May-01 1:29
protectorChristian Graus28-May-01 1:29 
GeneralRe: Create the database? Pin
Masaaki Onishi28-May-01 6:46
Masaaki Onishi28-May-01 6:46 
GeneralWinsock Hooking Pin
Crocmort27-May-01 13:25
Crocmort27-May-01 13:25 
GeneralRe: Winsock Hooking Pin
Ghazi H. Wadi28-May-01 7:09
Ghazi H. Wadi28-May-01 7:09 
QuestionWhy does CSimpleArray do this?? Pin
Ben Burnett27-May-01 12:25
Ben Burnett27-May-01 12:25 
AnswerRe: Why does CSimpleArray do this?? Pin
Tim Deveaux28-May-01 10:17
Tim Deveaux28-May-01 10:17 
Hey Ben

This is a form of placement new. For example, the Add method makes space for the new object then calls SetAtIndex. Looks like the Wrapper class serves to provide the placement new, which allocates no space, and initialize the object by calling the ctor in the initialization list of the Wrapper constructor.

I think the basic idea behind placement new is efficiency - memory is allocated from a pool managed by the class, and new entries can be just added in and the count incremented. In this case, I guess things are additionally complicated by the templated type allocation, hence the need for the Wrapper.

There's probably a pattern here that some STL gurus would recognize - bet you could get a better explanation on comp.lang.cpp.moderated.

I'd like to understand this better myself - wonder if this kind of thing is standard practise in STL containers as well, or if there are other abtuse tricks afoot...

T


GeneralRe: Why does CSimpleArray do this?? Pin
Tomasz Sowinski28-May-01 10:25
Tomasz Sowinski28-May-01 10:25 
GeneralRe: Why does CSimpleArray do this?? Pin
Tim Deveaux28-May-01 10:36
Tim Deveaux28-May-01 10:36 
GeneralRe: Why does CSimpleArray do this?? Pin
Tomasz Sowinski28-May-01 10:41
Tomasz Sowinski28-May-01 10:41 
GeneralRe: Why does CSimpleArray do this?? Pin
Tomasz Sowinski29-May-01 1:01
Tomasz Sowinski29-May-01 1:01 
GeneralRe: Why does CSimpleArray do this?? Pin
Tim Deveaux29-May-01 4:36
Tim Deveaux29-May-01 4:36 
GeneralRe: Why does CSimpleArray do this?? Pin
Ben Burnett28-May-01 16:06
Ben Burnett28-May-01 16:06 
GeneralRe: Why does CSimpleArray do this?? Pin
Tomasz Sowinski29-May-01 1:10
Tomasz Sowinski29-May-01 1:10 
GeneralRe: Why does CSimpleArray do this?? Pin
Tim Deveaux29-May-01 7:48
Tim Deveaux29-May-01 7:48 
GeneralCataloguer Source PLZ Pin
BLaZe27-May-01 11:32
BLaZe27-May-01 11:32 
Generalc strcmp alternative Pin
27-May-01 11:24
suss27-May-01 11:24 
GeneralRe: c strcmp alternative Pin
Michael Dunn27-May-01 11:30
sitebuilderMichael Dunn27-May-01 11:30 
GeneralLoading Images & displaying on a CDC Pin
27-May-01 10:14
suss27-May-01 10:14 
GeneralRe: Loading Images & displaying on a CDC Pin
Michael Dunn27-May-01 11:31
sitebuilderMichael Dunn27-May-01 11:31 
GeneralThx! Still: Loading Images & displaying on a CDC? Pin
27-May-01 12:27
suss27-May-01 12:27 
GeneralRe: Thx! Still: Loading Images & displaying on a CDC? Pin
Christian Graus27-May-01 14:17
protectorChristian Graus27-May-01 14:17 
GeneralThank you both! Pin
27-May-01 22:07
suss27-May-01 22:07 
GeneralSerialazing in 'Dialog Based App' Pin
27-May-01 3:06
suss27-May-01 3:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.