Boost logo

Boost :

From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2008-05-18 13:28:42


On Sun, May 18, 2008 at 3:52 PM, Maik Beckmann
<beckmann.maik_at_[hidden]> wrote:
> Am Sonntag 18 Mai 2008 14:08:16 schrieb Giuseppe Ottaviano:
>> On May 18, 2008, at 1:29 PM, Frank Birbacher wrote:
>> > Hi!
>> >
>> > Maik Beckmann schrieb:
>> >> Am Freitag 16 Mai 2008 21:32:56 schrieb Maik Beckmann:
>> >>> Hello,
>> >>>
>> >>> Does boost got something to do this
>> >>> struct node {
>> >>> std::vector<node> children; // node is incomplete
>> >>> };
>> >>> in a way which conform with the standard which disallows STL
>> >>> containers of
>> >>> incomplete types?
>> >
>> > Using boost::shared_ptr or boost pointer containers come to mind (
>> > http://www.boost.org/doc/libs/1_35_0/libs/ptr_container/doc/ptr_container
>> >.html ). But I don't know weather pointer containers allow incomplete
>> > types. I
>> > couldn't find it in the documentation.
>
> Aside both solutions might do the trick I'm curious about what a boost/c++
> guru would write into a STL-FAQ as a solution, since this problem isn't new.

I'm not a guru, but Instead of a vector<shared_ptrs<T> >, I'have used
a shared_ptr <vector<T> > to implement recursive data structures. A
clone pointer
would work even better.

>
> A possible answer might be: As matter of fact all common STL implementations
> have a vector/list class which works with incomplete types.

Not necessarily in debug builds.

HTH,

-- 
gpd

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