Boost logo

Boost :

From: Jeffrey D. Paquette (paquette_at_[hidden])
Date: 2000-04-29 18:55:04


Edjamaction? In my part of Massachusetts we say learnin...

I see the point with respect to writing generic code; perhaps I shouldn't
have included shared_ptr and its ilk in the (brief) list of candidate
classes. I do think, however, that it would be an error to dynamically
allocate objects of the same type (and intent) of deferred_value as that
violates the intent of the class. While it is possible to write code that
allocates a deferred_value, it does not seem very useful. (Wrapping it in an
auto_ptr just adds a level of indirection - it preserves the semantics of
the class at the cost of overhead).

--
Jeff Paquette
paquette_at_[hidden], paquette_at_[hidden]
http://www.atnetsend.net
-----Original Message-----
From: Dave Abrahams [mailto:abrahams_at_[hidden]]
Sent: Saturday, April 29, 2000 11:05 AM
To: boost_at_[hidden]
Subject: Re: [boost] Proposal: class nonallocatable
Importance: High
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;
   some_strange_algorithm(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.
-Dave
------------------------------------------------------------------------
Accurate impartial advice on everything from laptops to table saws.
http://click.egroups.com/1/3020/2/_/9351/_/957017189/
------------------------------------------------------------------------

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk