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

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.
Version: GnuPG v1.4.9 (GNU/Linux)


Boost list run by bdawes at, gregod at, cpdaniel at, john at