Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-04-06 06:06:14


----- Original Message -----
From: "Gary Powell" <Gary.Powell_at_[hidden]>

> Ok, I now have a "need" for auto_ptr_new as described by the above.
> Specifically I have
>
> std::pair<boost::any, boost::any>
>
> and in this particular case I have a pair of shared_ptr<string>'s, as a
> member of my class. And as I was trying to write the constructor, I
realized
> that
>
> my_any_pair(shared_ptr<string>(auto_ptr<string>(new string("text") ),
> auto_ptr<string>(new string("text2") );
>
> where I don't really want to have default construction, and then do the
> assignment the "safe" way.
>
> So the issue brought up by gotw/056 isn't as weird a case as I had first
> imagined, or am I being overly cautious here?

No, it is not a corner case; stuff like this happens all the time.
I might even start using Peter's non-const reference idiom.

auto_ptr_new is one of those cases where you need an overloaded family of
forwarding constructors, which (if you believe that a constructor ought to
be allowed to modify its arguments) will have the combinatorial explosion
problem I mentioned earlier.

-Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk