Boost logo

Boost Users :

Subject: Re: [Boost-users] Problem with enable_shared_from_this and shared_ptr
From: John Dlugosz (JDlugosz_at_[hidden])
Date: 2010-08-02 12:38:00

> Except that you lose the ability to write code like
> T t;
> shared_ptr<T> tp(&t, &nop_deleter);
> or simply code like
> T t;
> if you mandate that anything that inherits enable_shared_from_this
> should automagically conjure up a shared_ptr on demand.
> --
> Lars Viklund | zao_at_[hidden]

My class doesn't have a custom-supplied deleter as a feature. It was not necessary within the implementation to handle base/derived stuff; I guess I approached it in a different way.

A class that derives from the special base class is meant to be used as a pointer only. It can't (portably) tell that the instance is not on the heap, and can't tell in general if you aggregated it. Your point is that obtain-smart-pointer-from-this knows that no smart pointer was ever created and it should be an error instead?

Certainly, I could have a form that means "give me a smart pointer if it's already in the system, but null if it's not", but I've never needed that.


TradeStation Group, Inc. is a publicly-traded holding company (NASDAQ GS: TRAD) of three operating subsidiaries, TradeStation Securities, Inc. (Member NYSE, FINRA, SIPC and NFA), TradeStation Technologies, Inc., a trading software and subscription company, and TradeStation Europe Limited, a United Kingdom, FSA-authorized introducing brokerage firm. None of these companies provides trading or investment advice, recommendations or endorsements of any kind. The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at