[gtkmm] C++11: tests/demos: Some use of range-based for loops.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] C++11: tests/demos: Some use of range-based for loops.
- Date: Thu, 16 Jul 2015 20:07:22 +0000 (UTC)
commit fb37c13221ac5537bbf61629fdceb6d90224ec4c
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Jul 16 20:27:28 2015 +0200
C++11: tests/demos: Some use of range-based for loops.
demos/gtk-demo/example_change_display.cc | 14 ++++----------
demos/gtk-demo/example_sizegroup.cc | 4 ++--
demos/gtk-demo/example_treeview_treestore.cc | 10 +++-------
tests/main_with_options/main.cc | 4 ++--
4 files changed, 11 insertions(+), 21 deletions(-)
---
diff --git a/demos/gtk-demo/example_change_display.cc b/demos/gtk-demo/example_change_display.cc
index 4e1b571..e430042 100644
--- a/demos/gtk-demo/example_change_display.cc
+++ b/demos/gtk-demo/example_change_display.cc
@@ -179,13 +179,8 @@ void Example_ChangeDisplay::initialize_displays()
#ifndef G_OS_WIN32
Glib::RefPtr<Gdk::DisplayManager> refDisplayManager = Gdk::DisplayManager::get();
- typedef std::vector< Glib::RefPtr<Gdk::Display> > type_listDisplays;
- type_listDisplays listDisplays = refDisplayManager->list_displays();
-
- for(type_listDisplays::iterator iter = listDisplays.begin(); iter != listDisplays.end(); ++iter)
+ for(auto refDisplay : refDisplayManager->list_displays())
{
- Glib::RefPtr<Gdk::Display> refDisplay = *iter;
-
Gtk::TreeRow row = *(m_refListStore_Display->append());
row[m_columns_display.m_name] = refDisplay->get_name();;
row[m_columns_display.m_display] = refDisplay;
@@ -199,13 +194,12 @@ void Example_ChangeDisplay::initialize_displays()
void Example_ChangeDisplay::on_display_closed(bool /* is_error */, Glib::RefPtr<Gdk::Display> display)
{
- Gtk::TreeModel::Children children = m_refListStore_Display->children();
- for(Gtk::TreeModel::iterator iter = children.begin(); iter != children.end(); ++iter)
+ for(auto row : m_refListStore_Display->children())
{
- Glib::RefPtr<Gdk::Display> refDisplay = (*iter)[m_columns_display.m_display];
+ Glib::RefPtr<Gdk::Display> refDisplay = row[m_columns_display.m_display];
if(refDisplay == display)
{
- m_refListStore_Display->erase(iter);
+ m_refListStore_Display->erase(row);
}
}
}
diff --git a/demos/gtk-demo/example_sizegroup.cc b/demos/gtk-demo/example_sizegroup.cc
index 4bb14cb..be77930 100644
--- a/demos/gtk-demo/example_sizegroup.cc
+++ b/demos/gtk-demo/example_sizegroup.cc
@@ -151,9 +151,9 @@ Gtk::ComboBoxText* Example_SizeGroup::create_combobox(const std::list<Glib::ustr
{
Gtk::ComboBoxText* pCombo = Gtk::manage( new Gtk::ComboBoxText() );
- for(type_listStrings::const_iterator iter = strings.begin(); iter != strings.end(); iter++)
+ for(const auto& str : strings)
{
- pCombo->append(*iter);
+ pCombo->append(str);
}
return pCombo;
diff --git a/demos/gtk-demo/example_treeview_treestore.cc b/demos/gtk-demo/example_treeview_treestore.cc
index 6a4a2a1..bd2c62e 100644
--- a/demos/gtk-demo/example_treeview_treestore.cc
+++ b/demos/gtk-demo/example_treeview_treestore.cc
@@ -274,11 +274,11 @@ void Example_TreeView_TreeStore::create_model()
Gtk::TreeIterChildren children = m_refTreeStore->children();
- for(Gtk::TreeModel::iterarator node = children.begin(); node != children.end(); ++node)
+ for(auto node : children)
{
g_print("outer loop\n");
- for(Gtk::TreeModel::iterarator row = node.children().begin(); row != node.children().end(); )
+ for(auto row : node.children())
{
g_print("inner loop\n");
row = m_refTreeStore->erase(row);
@@ -302,12 +302,8 @@ void Example_TreeView_TreeStore::treestore_add_item(const CellItem_Holiday& foo)
row[m_columns.world] = foo.m_world_holiday;
//Add Children:
- for(std::vector<CellItem_Holiday>::const_iterator iterVec = foo.m_children.begin();
- iterVec != foo.m_children.end();
- ++iterVec)
+ for(const auto& child : foo.m_children)
{
- const CellItem_Holiday& child = *iterVec;
-
Gtk::TreeRow child_row = *(m_refTreeStore->append(row.children()));
child_row[m_columns.holiday_name] = child.m_label;
diff --git a/tests/main_with_options/main.cc b/tests/main_with_options/main.cc
index 81d4cc0..e5ee18a 100644
--- a/tests/main_with_options/main.cc
+++ b/tests/main_with_options/main.cc
@@ -116,9 +116,9 @@ int main(int argc, char *argv[])
//This one shows the results of multiple instance of the same option, such as --list=1 --list=a --list=b
std::cout << " list = ";
- for(Glib::OptionGroup::vecustrings::const_iterator iter = group.m_arg_list.begin(); iter !=
group.m_arg_list.end(); ++iter)
+ for(auto str : group.m_arg_list)
{
- std::cout << *iter << ", ";
+ std::cout << str << ", ";
}
std::cout << std::endl;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]