|
Boost : |
Subject: Re: [boost] [ptr_container] new_clone overload
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2009-08-20 10:36:43
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thursday 20 August 2009, Thorsten Ottosen wrote:
> Frank Mori Hess skrev:
> > I've noticed that ptr_container/clone_allocator.hpp contains an
> > undocumented overload of new_clone that accepts a pointer-to-const:
> >
> > template< class T >
> > inline T* new_clone( const T* r );
> >
> > It is annoying because it doesn't support a pointer-to-non-const
> > argument, resulting in a compile error if you try. Any chance one of the
> > following could be done?
>
> Yes, which do you prefer?
1,2, or 4 are all equally fine to me. Actually, I'm currently in the process
of moving away from new_clone to a "placement" version of it for
generic_ptr::cloning (a cloning smart pointer class). That will let me avoid
having to do two allocations for every copy of generic_ptr::cloning, by using
a boost::aligned_storage inside the clone allocator. Also, my versions of
new_clone and CloneAllocator will have to be generalized slightly to support
generic pointer-like objects in addition to plain old pointers.
> > 1) remove it
> >
> > 2) add a pointer-to-non-const overload
> >
> > 3) change it to
> > template< class T >
> > T* new_clone( T* r );
> >
> > 4) or if you care about always returning a pointer-to-non-const change it
> > to template< class T >
> > typename remove_const<T>::type * new_clone( T* r );
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEARECAAYFAkqNX3sACgkQ5vihyNWuA4WFWQCgiF3PL2ZHlGNRh2ikzzgG01UA
VlMAnj77HCwpGUpfHtBa6DGFGOfPo+EU
=s1M0
-----END PGP SIGNATURE-----
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk