1

In order to call a constructor on an already allocated memory, we use placement new:

new(pMemory) Widget;

However, destructors seem to be directly callable:

pWidget->~Widget();

Soctt Meyars More Effective C++ item 8

Is this still valid with current C++ standard? What is the reason for this asymmetry?

Vorac
  • 8,726
  • 11
  • 58
  • 101
  • 1
    What asymmetry? What would you propose as a 'symmetrical' version? – M.M Mar 04 '15 at 12:47
  • To be either able to directly call a constructor on some uninitiolized memory `static_cast(pMemory)->Widget();` OR need a trick to call any destructor as well. – Vorac Mar 04 '15 at 13:35
  • Here's the reasoning: [link](http://www.stroustrup.com/bs_faq2.html#placement-delete) – Brian Rodriguez Oct 17 '15 at 01:13

0 Answers0