Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2004-11-17 02:40:24

On 11/13/04 9:38 AM, "Peter Dimov" <pdimov_at_[hidden]> wrote:

> David Abrahams wrote:
>> "Pavel Vozenilek" <pavel_vozenilek_at_[hidden]> writes:
>>> 4. docs: the line
>>> window* w = new_window("alert2", movability); // error!
> Just a quick note, if I may. No "new_X" functions that returns a X* should
> be allowed into Boost, IMO. Including documentation and tutorials.

I guess you object since, from looks alone, you can neither determine the
allocation strategy nor provide a custom allocation procedure. And the
earlier fact implies that you can _not_ determine either the de-allocation
procedure or actor responsible for de-allocation.

If so, then I agree with you on all points. I'm just pointing out the
obvious (to you) since it was all implied, so the newbies among us may not
realize your (seemingly) mysterious assertions.

A hint of the proper solution would be having "new_window" return a
"std::auto_ptr<window>", which would be memory- and exception-safe. Of
course, you couldn't use that class if allocation doesn't always use the
unadorned single-new operator. In that case, something like
boost::shared_ptr would be better.

Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT hotmail DOT com

Boost list run by bdawes at, gregod at, cpdaniel at, john at