www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/05/18/16:50:53

From: remove_this_mimo AT restoel DOT net_and_this (mimo)
Newsgroups: comp.os.msdos.djgpp
Subject: new and nothrow()
Date: Tue, 18 May 1999 20:34:16 GMT
Organization: MimoLand
Lines: 26
Message-ID: <3741c977.1974482@news.wanadoo.fr>
NNTP-Posting-Host: tntaub161-71.abo.wanadoo.fr
Mime-Version: 1.0
X-Trace: wanadoo.fr 927059454 29927 164.138.207.71 (18 May 1999 20:30:54 GMT)
X-Complaints-To: abuse AT wanadoo DOT fr
NNTP-Posting-Date: 18 May 1999 20:30:54 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

ok, this is rather a philosophical question, but maybe someone could
help me: i found in my code book a way to avoid try/throw/catch when
allocating memory using new which returns simply 0 instead. it says:
void *operator new(size_t,const nothrow &) throw(); (and the new[]
operator too)

so i tried to write the following:

int *tab = new (nothrow()) int[nb];

after including <memory> or <new> (i dont see a difference) the
compiler reported:

Error: no match for call to `(nothrow_t) ()'

than i replaced the line by:

int *tab = new (nothrow) int[nb];

and the compiler accepted it. 
first question: is this a fault in my codebook?
second: does this ever return 0 (NULL)?

thanx in advance

mimo

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019