3

The following statement is from WebKit. I am not 100% sure what it means. Any clues?

new ((void*)&nullAtom) AtomicString;
l.thee.a
  • 3,231
  • 6
  • 25
  • 28

2 Answers2

8

It's a placement-new. It means that the AtomicString object will be constructed at the memory location pointed to inside the parentheses (&nullAtom), rather than the usual behavior (constructed on top of a bit of memory taken off of the heap).

Jeremy Friesner
  • 70,199
  • 15
  • 131
  • 234
  • 1
    Strictly speaking, you have no idea what it does, because you don't know the class definition of `AtomicString`. What you *do* know is the behaviour of `::new (addr) AtomicString;`. – Kerrek SB Sep 27 '11 at 23:13
4

That's a "placement new".

Keith Thompson
  • 254,901
  • 44
  • 429
  • 631