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,101
  • 6
  • 24
  • 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
  • 63,706
  • 14
  • 113
  • 212
  • 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
  • 242,098
  • 41
  • 402
  • 602