Boost logo

Boost :

Subject: Re: [boost] [ptr_container] new_clone overload
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2009-08-04 08:50:12


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 04 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 );

> I really don't see the problem, but removing it entirely is certainly an
> option.
>
> Why do you get a compile error? Cloning is not supposed to require a
> mutable object. Is your problem with legacy code?

Because a pointer-to-nonconst argument binds to the new_clone overload that
accepts a const reference (T is deduced to be a pointer type):

template< class T >
inline T* new_clone( const T& r );

This came up, because in implementing generic_ptr::cloning I wanted to make
any wrapping pointer-like types available to the new_clone function, so I
call it by passing a generic pointer-like object (sometimes an actual
pointer) to new_clone (and provide suitable new_clone overloads) instead of
passing a reference directly. This, for example, lets me lock any
generic_ptr::monitor objects before their pointed-to object is cloned.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkp4LoUACgkQ5vihyNWuA4V2GgCfTfABLQOx27lZZgqQrVUCNLdn
TNwAn1VVEfDy8XzjU2igdlF4pZRqL1ni
=wDAd
-----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