Topic: Clarification in 1745


Author: Maciej Sobczak <no.spam@no.spam.com>
Date: Wed, 2 Feb 2005 11:04:07 CST
Raw View
Hi,

In the N1745 document, in the 2.2.3.1/7 and other definitions of the
shared_ptr constructors, there is:

"Throws: bad_alloc, or an implementation-defined exception when a
resource other than memory could not be obtained."


1. What kind of resource *other than memory* may be needed to construct
a shared_ptr object?

1a. Is the use of bad_alloc blessed for reporting failures with
resources other than memory, anyway (see 18.4.2.1/1 in '98 std)?

2. Does it mean that the constructor does *not* throw if it is the
memory that cannot be obtained? What the constructor is supposed to do,
then?


Shouldn't it be instead:

"Throws: bad_alloc, or an implementation-defined exception when a
sufficient resources could not be obtained."

--
Maciej Sobczak : http://www.msobczak.com/
Programming    : http://www.msobczak.com/prog/

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: "msalters" <Michiel.Salters@logicacmg.com>
Date: Wed, 2 Feb 2005 13:06:58 CST
Raw View
Maciej Sobczak wrote:
> Hi,
>
> In the N1745 document, in the 2.2.3.1/7 and other definitions of the
> shared_ptr constructors, there is:
>
> "Throws: bad_alloc, or an implementation-defined exception when a
> resource other than memory could not be obtained."
>
>
> 1. What kind of resource *other than memory* may be needed to
construct
> a shared_ptr object?

Mutex?

> 1a. Is the use of bad_alloc blessed for reporting failures with
> resources other than memory, anyway (see 18.4.2.1/1 in '98 std)?

It's also allowed anywhere UB is encountered, of course.

> 2. Does it mean that the constructor does *not* throw if it is the
> memory that cannot be obtained? What the constructor is supposed to
do,
> then?

Throw bad_alloc, of course.

> Shouldn't it be instead:
>
> "Throws: bad_alloc, or an implementation-defined exception when a
> sufficient resources could not be obtained."

I think you're misreading it. I'm pretty sure it means
"Throws: bad_alloc when memory could not be obtained, or an
implementation-defined exception when a resource other than
memory could not be obtained." but that's a bit verbose.
HTH,
Michiel Salters

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]