Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 1999-12-05 14:47:32

From: Dave Abrahams <abrahams_at_[hidden]>
> Or you could have a family of template member function constructors which
> forward their arguments on to the type being constructed. That would
> *enforce* non-null initialization and deal with some nasty lurking
> sequence-point issues, e.g.:
> void f( smart_ptr<X>(new X), smart_ptr<X>(new X) ); // leak!!
> so the constructors might be:
> template <class X>
> class smart_ptr {
> smart_ptr() : px(new X) {}
> template <class A1>
> smart_ptr(const A1& a1) : px(new X(a1)) {}
> template <class A1, class A2>
> smart_ptr(const A1& a1, const A2& a2) : px(new X(a1, a2)) {}
> ... (pick a reasonable upper limit on args).

Nice. I'll point out again that we need to not break the
current shared_ptr and scoped_ptr interfaces, so this kind
of thing may work best as an adaptor.

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