Boost logo

Boost :

From: Jani Kajala (jani_at_[hidden])
Date: 2002-02-03 08:17:43


> 20.4.5 para 3 of the C++ Standard

Thanks, you're right. I've been using too much MSVC...

Regards,
Jani

----- Original Message -----
From: "Alan Bellingham" <alan_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Sunday, February 03, 2002 2:23 PM
Subject: Re: [boost] auto_vector - vector with auto_ptr semantics

> "Jani Kajala" <jani_at_[hidden]>:
>
> >> Because auto_ptr<> doesn't satisfy the requirements for being a
> >> std::vector<> member?
> >
> >Which requirement? At least I've used vectors of auto ptrs before without
> >problems...
>
> 20.4.5 para 3 of the C++ Standard
>
> "auto_ptr does not meet the CopyConstructible and Assignable
> requirements for Standard Library container elements and thus
> instantiating a Standard Library container with an auto_ptr results in
> undefined behaviour."
>
> auto_ptr is a very weird object - the copy constructor and assignment
> operator take a non-const rhs. This means that the following should not
> compile:
>
> typedef std::auto_ptr<int> T ;
> std::vector<T > a ;
> T t ;
> a.push_back(t) ;
>
> whereas if the type T is just a plain pointer, there is no problem. Also
> consider just copying a vector of std::auto_ptr - which vector's
> elements own the pointed-to items?
>
>
> Info: http://www.boost.org Send unsubscribe requests to:
<mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>


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