From: Felipe Magno de Almeida (felipe.almeida_at_[hidden])
Date: 2005-03-10 17:09:21
What I was needing was a map of sets, then it wasnt compiling because of
the operator. I modified the ptr_set for my imediate need, but I think
Ill do as you said, use a pointer container. Now it really seems to me
more obvious why not allow copy construction.
The same as you cant push_front in a vector, I think it shouldnt be
possible to copy construct a pointer container.
Thorsten Ottosen wrote:
> "Felipe Magno de Almeida" <felipe.almeida_at_[hidden]> wrote in message
> | > yes, but this is no ordinary std::vector. std::vector is for
> | > value types; boost::ptr_vector is for pointers whose life-time
> | > must be managed.
> | >
> | > | boost::vector<A> vector1, vector2;
> | > | vector1 = vector2;
> | >
> | > boost::ptr_vector don't have an assignment operator; it is not Assignable
> | > CopyConstructible.
> | >
> | > you must clone or release the container:
> | >
> | > vector1 = vector2.clone();
> | > vector1 = vector2.release();
> | >
> | I see, but it makes impossible for use ptr_containers inside other
> | containers. Isnt this too restrictive?
> well, yes, you would have to use a pointer container.
> ptr_vector< ptr_list<Foo> > vec;
> vec.push_back( new ptr_list<Foo> );
> when move semantics enters the langauge, they can become movable.
> | Cant they be implemented in terms of these?
> | There were a discussion about this before? So that I can know the
> | reasons why?
> I can't remember any long discussion, but I know why I made the choice.
> The types stored in a pointer container need not be copyable; most
> uses will be non-copyable objects or clonable objects. Neither
> type of object can be copied and hence it seems wrong to
> allow a container of them to be copied; it kinda hides the true nature
> of the contained objects.
> Moreover, copying a whole container can be really expensive; it seems better
> that the distinction between copyable and clonable objects carries over to
> the containers as well so users are reminded of the distinction.
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Felipe Magno de Almeida UIN: 2113442 email: felipe.almeida at ic unicamp br, felipe.m.almeida at gmail com, felipe at synergy com I am a C, modern C++, MFC, ODBC, Windows Services, MAPI developer from synergy, and Computer Science student from State University of Campinas(UNICAMP). To know more about: Unicamp: http://www.ic.unicamp.br Synergy: http://www.synergy.com.br current work: http://www.mintercept.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk