Fwd: STL black magic, was Re: GTK--: Gtk_Notebook::append_page question
- From: Christof Petig <christof petig wtal de>
- To: Gtk-List <gtk-list redhat com>
- Subject: Fwd: STL black magic, was Re: GTK--: Gtk_Notebook::append_page question
- Date: Wed, 15 Jul 1998 12:37:03 +0200
I agree! It looks nicer thought it's fully equivalent.
(quoting from stl_vector.h):
reference back() { return *(end() - 1); }
- From: David Hodson <david dfilm com au>
- To: Christof Petig <christof petig wtal de>
- Subject: Re: STL black magic
- Date: Wed, 15 Jul 1998 17:45:05 +1000
Christof Petig wrote:
> vector<Gtk_Label> labels;
> { labels.push_back(Gtk_Label("xyz"));
> Gtk_Label &recently_created_label=*--(labels.end());
> recently_created_label.set_alignment(...);
> }
>
Very black magic. Use:
labels.push_back(Gtk_Label("xyz"));
Gtk_Label& recently_created_label = labels.back();
Much nicer.
--
David Hodson -- david@dfilm.com.au -- this night wounds time
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]