Mixing shared_ptr and regular pointers in containers

Hi, This feels like a stupid question, but is there an easy/clean way of mixing shared_ptr<A> and regular A* pointers in one STL container? Boost.Variant comes to mind, but I somehow have the idea that there's a more obvious way and that I'm missing it. thanks, Remko

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday 11 June 2009, Remko Tronçon wrote:
This feels like a stupid question, but is there an easy/clean way of mixing shared_ptr<A> and regular A* pointers in one STL container? Boost.Variant comes to mind, but I somehow have the idea that there's a more obvious way and that I'm missing it.
You could put the regular pointers into shared_ptr with null deleters. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkoxb+cACgkQ5vihyNWuA4U9gQCeNS6ZRJ/RrnHUictWojBPvc4W w9MAn1M7WTuNv5M3aOQVzvUFzh3+X7aV =wMso -----END PGP SIGNATURE-----

AMDG Remko Tronçon wrote:
This feels like a stupid question, but is there an easy/clean way of mixing shared_ptr<A> and regular A* pointers in one STL container? Boost.Variant comes to mind, but I somehow have the idea that there's a more obvious way and that I'm missing it.
Can you use shared_ptr with a no-op deleter? In Christ, Steven Watanabe
participants (3)
-
Frank Mori Hess
-
Remko Tronçon
-
Steven Watanabe