Fwd: STL black magic, was Re: GTK--: Gtk_Notebook::append_page question



I agree! It looks nicer thought it's fully equivalent.

(quoting from stl_vector.h):
  reference back() { return *(end() - 1); }



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]