On Sun, 11 May 2008 20:13:18 CST, "Alf P. Steinbach" wrote:
>I just coded this up, and hopefully by mentioning it here I'll get
>some useful feedback, like, bugs, shortcomings, improvements...
>
>http://code.google.com/p/alfps/source/browse/trunk/alfs/pointers/AutoNewPtr.hpp
>(http://preview.tinyurl.com/3puorr)
Disclaimer: Haven't looked into all the intricacy of the code in
detail.
>AutoNewPtr ("new" Berkeley open source license)
>
> * Is not initialized with a raw pointer, but with constructor
> arguments for the to-be referent: AutoNewPtr takes responsibility
> for 'new'.
AFAICS, you need to sup****t const and non-const arguments.
> * By doing that, it has the ability to add a notifier to the created
> object, so that the smart pointer gets notified when referred
> object self-destructs, if it does (e.g., a window or file closing,
> or a non-correctable error).
Why? You are the owner/creator of the object. Self-destruction seems
to contradict the main point of the design.
> * After referred object destroyed, pointer re****ts that it's void
> and throws on access via ->.
Ok
> * Also, the default constructor sets the pointer to void state.
Hmm, a semantic anomaly.
> * Otherwise much like shared_ptr, except customization of deleter is
> per type (via c++0x-like std::default_delete) rather than per
> instance.
So it's a SharedNewPtr rather than a AutoNewPtr. I fail to see where
you can configure a deleter in 'template<typename T> class
AutoNewPtr'. Moreover, the main point of the design seems to be that
construction and destruction happen inside AutoNewPtr which
contradicts the customization of a deleter.
--
Roland Pibinger
"The best software is simple, elegant, and full of drama" - Grady Booch
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


|