|
Boost Users : |
From: Matt S Trentini (matt_s_trentini_at_[hidden])
Date: 2003-11-11 07:19:12
Heya Jon,
Ah, the smart_ptr example, I knew that would come back to bite me! ;) I
changed this example at the last minute in an effort to simplify but, as
your co-worker correctly points out, there are many errors in it.
The correct code is below though the graphic requires change (yes, I could
have change the list.push_front() to a push_back but I like to see the
variety!).
int main()
{
typedef boost::shared_ptr<Foo> FooPtr;
vector<FooPtr> foo_vector;
list<FooPtr> foo_list;
FooPtr foo_ptr( new Foo(1) );
foo_vector.push_back( foo_ptr );
foo_list .push_back( foo_ptr );
foo_vector.push_back ( FooPtr( new Foo(2) ) );
foo_list .push_front( FooPtr( new Foo(3) ) );
}
You'll notice that I left the typedef in there. I can't find anything in
the standard (or with google) about it being illegal in main, nor does my
compiler emit any warnings. Can anyone shed some light on this?
And I've got to disagree with your friend about the correct ordering - the
expected output is 3, 1, 2 (Remember that foo_ptr gets deleted first).
I'll endeavour to fix this example up and upload the changes over the next
couple of days.
As for these comments:
> > The rest of the pages have the classic boost downfall: they
> > don't discuss any of the pitfalls, performance problems, or
> > code bloat issues, which frankly, seem like the "crazy aunt
> > in the basement" of boost.
I'll defend myself on two fronts. First, it's an introductory
presentation - I was trying to generate interest in these libraries and thus
didn't want to focus too much on the negatives. Secondly, I _did_ cover
some of those points - like all good presentations not everything is
contained in the bullet points.
Thanks for the feedback though, it's helping to make this presentation
better!
Cheers,
Matt
PS If there are any other problems that you or your co-worker have found
please don't hesitate to report them!
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net