-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday 27 May 2009, Dominique Devienne wrote:
I was thinking of using the new make_shared, but I'm already using a custom deleter (shared instances have private destructora and declare the custom deleter as a friend, and new instances are returned wrapped in shared_ptr, thus no explicit new or delete should be possible).
Looking at make_shared, I can't see a way to use both at the same time. Am I out of luck? Thanks, --DD
You can't, not even with boost::allocate_shared since it doesn't use the allocator for in-place construction. See ticket #2481: https://svn.boost.org/trac/boost/ticket/2481 In theory you should be able to use std::allocate_shared in c++0x mode if your compiler provides it. Define your own allocator (a bit of a pain) and make it a friend of your class. Then add a static factory function to your class with calls allocate_shared with your friend allocator. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkoepDYACgkQ5vihyNWuA4VxnQCdH8IKhh6XnLqZbx+H1fZ4mBXh +voAn12BSApivL5uv3kIZes9vLAJZYpv =5dK9 -----END PGP SIGNATURE-----