By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,081 Members | 862 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,081 IT Pros & Developers. It's quick & easy.

new, delete and nothrow

P: n/a
Foo* p = new (nothrow) Foo;

Should we use
operator delete (p, nothrow) ?
Or can we use
delete p; ?

If we use
operator delete (p, nothrow)
how to replace it by operator style?

delete (nothrow) p; // Compiler rejects that
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

Nov 23 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
* Alex Vinokur:
Foo* p = new (nothrow) Foo;

Should we use
operator delete (p, nothrow) ?
No.

Or can we use
delete p; ?
Yes.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Nov 23 '06 #2

P: n/a

Alf P. Steinbach wrote:
* Alex Vinokur:
Foo* p = new (nothrow) Foo;

Should we use
operator delete (p, nothrow) ?

No.
Can we use
operator delete (p, nothrow) ?

[snip]

Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

Nov 23 '06 #3

P: n/a

Alex Vinokur wrote:
Alf P. Steinbach wrote:
* Alex Vinokur:
Foo* p = new (nothrow) Foo;
>
Should we use
operator delete (p, nothrow) ?
No.

Can we use
operator delete (p, nothrow) ?
not like that, you must call it in a normal function call way

if Foo has a delete operator like this
void operator delete(void *, std::nothrow_t)

Foo * p = new (std::nothrow) Foo;
p->operator delete(p, std::nothrow);

Nov 23 '06 #4

P: n/a

dasjotre wrote:
Alex Vinokur wrote:
Alf P. Steinbach wrote:
* Alex Vinokur:
Foo* p = new (nothrow) Foo;

Should we use
operator delete (p, nothrow) ?
>
No.
Can we use
operator delete (p, nothrow) ?

not like that, you must call it in a normal function call way

if Foo has a delete operator like this
void operator delete(void *, std::nothrow_t)

Foo * p = new (std::nothrow) Foo;
p->operator delete(p, std::nothrow);
ups, sorry, I didn't wake up yet

Nov 23 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.