Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2007-07-01 21:13:34

on Tue Jun 19 2007, Tobias Schwinger <> wrote:

> David Abrahams wrote:
>> on Sun Jun 17 2007, Tobias Schwinger <> wrote:
>>> Interface draft:
>>> ================
>>> factory<T> // constructs X and returns it by value
>>> factory<T*> // uses operator new, returns a pointer
>> auto_ptr, please.
> Generic algorithms won't 'get' it.

You have generic algorithms that expect to get ownership of a
dynamically-allocated pointer?

> In this light, it seems better to have a separate template for pointers,
> so you clients can specify what they want, explicitly:
> new_< T* >
> new_< auto_ptr<T> >
> new_< special_smartie<T> >
> (Seems tricky to deduce T but it might be doable).


>>> Where operator() takes a variable number of arguments, forwarded to the
>>> constructor.
>> Isn't in-place construction the most general case?
> It sure is, but not necessarily the most handy. How to tell e.g.
> std::transform to allocate memory for the transformed elements?
> Not sure I really got your point, here.

Just that you might want to support the general case and build the
others on top... if possible.

Dave Abrahams
Boost Consulting
The Astoria Seminar ==>

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