|
Boost : |
From: Dave Harris (brangdon_at_[hidden])
Date: 2004-08-08 09:59:18
In-Reply-To: <200408061504.i76F4EW20044_at_[hidden]>
stewart_at_[hidden] (Rob Stewart) wrote (abridged):
> Note, however, that "rawptr" is rather terse for something you're
> trying to call attention to.
I liked the terseness. To be honest I am less likely to use new features
if they are verbose. "boost::raw_ptr()" is already 16 characters. Surely
the main benefit comes from being able to search for raw_ptr with tools
like grep, rather than with eyeballs?
The later suggestion of writing:
boost::shared_ptr<Widget> p = boost::shared_ptr_cast<Widget>(new
Widget);
is even more verbose and repetitive, the word "Widget" occurring 3 times.
The original proposal:
boost::shared_ptr<Widget> wp2 = boost::raw_ptr(new Widget(a, b));
at least fits into 80 columns.
Is it time to wrap operator new()? For example:
boost::shared_ptr<Widget> wp2 = boost::make<Widget>(a, b);
with something like:
template <typename R, typename A, typename B>
inline raw_ptr_t<R> make( A &a, B &b ) {
return raw_ptr_t<R>( new R( a, b ) );
}
Users being allowed to specialise make<> with their own factory code if
desired.
-- Dave Harris, Nottingham, UK
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk