Boost logo

Boost :

From: Dave Abrahams (abrahams_at_[hidden])
Date: 2000-04-29 10:05:17

on 4/29/00 8:06 AM, Jeffrey D. Paquette at paquette_at_[hidden] wrote:

> I'm sure I'm going to get educated here :)

My only word of edjamacation (as we say in Massachussetts) is that I
wouldn't neccessarily want to prevent the writing of such generic code as:

template <class T>
void some_strange_algorithm(T x)
   boost::shared_ptr<T> p(new T(x));

   boost::shared_ptr<MyType> y;

> So, in the spirit of noncopyable, here is a first cut at nonallocatable:

The reason this application of the idea isn't analogous to the use of
noncopyable is that we use noncopyable where we know that copying would
definitely be an error... but it's not neccessarily an error to dynamically
allocate a shared_ptr. Furthermore, there is nothing (as far as I can tell)
which neccessarily makes a dynamic allocation of *any* object errorful
(since you could always manage the object with an auto_ptr). Again, this is
in contrast to copying.

That said, I have no objection to this class in principle, though I do
wonder a bit about whether preventing dynamic allocation is actually useful.


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