Re: gtkmm 3.0.



On Fri, Mar 26, 2010 at 12:20 AM, Chris Vine
<chris cvine freeserve co uk> wrote:
> On Thu, 25 Mar 2010 23:45:24 +0100
> Murray Cumming <murrayc murrayc com> wrote:
>> On Thu, 2010-03-25 at 14:58 -0500, Jonathon Jongsma wrote:
>> > For example, the following commonly-used one-liner:
>> > tree_view.get_selection()->set_mode(...);
>> >
>> > would become (without validity-checking):
>> > tree_view.get_selection().lock()->set_mode(...);
>>

BTW

tree_view.get_selection().lock()->set_mode(...);

would be the same as

ptr = tree_view.get_selection().lock();
assert(ptr != NULL);
ptr->set_mode(...);

The assertion is actually included in the operator->() of the boost
smart pointer.

This is somewhat safer than using "simple" pointers, because in this
case you are guaranteed that your program will halt with a failed
assertion, instead of randomly access to an invalid memory area.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]