Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2006-01-14 09:20:41

Pooyan McSporran <duckfreezone_at_[hidden]> writes:

> I'm in the process of converting a large pile of legacy code which uses raw
> pointers to instead use boost::shared_ptr exclusively. I've got almost all
> of it converted and working, with one exception.
> Normally, given a type of Foo I define a smart pointer FooPtr, for example:
> class Foo;
> typedef boost::shared_ptr<Foo> FooPtr;
> But some code uses a templated type, for example:
> template<typename T> class Foo;
> Ideally, I'd use a templated typedef, for example:
> template<typename T> typedef boost::shared_ptr<Foo<T> > FooTPtr;
> but that is currently illegal in C++.
> Has anyone found a clean workaround?

How clean it is may be open to question, but:

    template <class T> class FooTPtr
      : boost::shared_ptr<Foo<T> >
       // forwarding ctors here...

should work.

Dave Abrahams
Boost Consulting

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