Boost logo

Boost :

From: Mathew Robertson (mathew.robertson_at_[hidden])
Date: 2004-08-25 18:30:17


> > Thus, in Java Swing-style C++, you can do something like:
> >
> > boost::gui::frame * main = new boost::gui::frame( "My GUI App" );
> > frame -> set_pane( new boost::gui::button( "PUSH" ));
> > frame -> set_size( 500, 400 );
> > frame -> show();
> >
> > boost::gui::message_loop msg;
> > return msg.execute();
>
> How does main get deallocated here?
> I am very surprised to see "new" and raw pointers in a library designed from
> scratch. Manual lifetime management is going to lead to a lot of clutter,
> memory leaks, and is incompatible with exception handling. A system based on
> smart pointers like boost::shared_ptr and reference-counted container types is
> essential IMO.

not necessarily - take the snippet of code above, to become:

boost::gui::frame frame( "My GUI App" );
frame . set_pane( new boost::gui::button( "PUSH" ));
frame . set_size( 500, 400 );
frame . show();
boost::gui::message_loop msg;
return msg.execute();

'frame' deletes all of its children when it goes out of scope (due to window heirachy property - as mentioned in other emails). Only frame needed now be new'ed.

Mathew


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