Conversation started Jul 10, 2013 at 13:49.
Jul 10, 2013 13:49
Can I ask a question about Jonathan’s post? Jonathan says that operator new simply does return ptr; – but if so, where/when is the object’s constructor invoked? Who’s responsible for that?
Xeo
Xeo
@KonradRudolph operator new != new operator
operator new is malloc.
@Xeo Yes, that’s clear.
Xeo
Xeo
Then where's the question?
Placement new calls the ctor.
Jul 10, 2013 13:50
placement-new invokes an object’s constructor
Xeo
Xeo
operator new gets memory, new operator constructs
Isnt it the other way around?
@KonradRudolph compiler invokes operator new and then ctor
So new T is T* x = operator new(sizeof(T)); new (x) T(...);
Xeo
Xeo
@Borgleader no
Jul 10, 2013 13:51
okay, so placement-new internally invokes operator new(…)?
@KonradRudolph No.
@CatPlusPlus and try-catch block
Placement-new doesn't allocate.
@CatPlusPlus Yes, but I’m not concerned with new T, I’m concerned with new (x) T(…).
Jul 10, 2013 13:51
It wouldn't be very placement otherwise.
@CatPlusPlus Yes, of course. You guys confused me. :p
I always thought operator new was the one you could was the class one and new operator was the global one
Oh gosh waht a fucking mess.
All new operator new.
 
Conversation ended Jul 10, 2013 at 13:52.