Commit 442675b9 authored by Murray Cumming's avatar Murray Cumming

C++11: Use range-based for loops.

parent 9b0554e2
......@@ -60,8 +60,8 @@ void on_dbus_proxy_available(Glib::RefPtr<Gio::AsyncResult>& result)
std::cout << "The names on the message bus are:" << std::endl;
for(unsigned i = 0; i < names.size(); i++)
std::cout << names[i] << "." << std::endl;
for(const auto& i : names)
std::cout << i << "." << std::endl;
}
catch(const Glib::Error& error)
{
......
......@@ -68,8 +68,8 @@ int main(int, char**)
{
const auto values = keyfile.get_integer_list("Another Group", "Numbers");
for(auto p = values.begin(); p != values.end(); ++p)
std::cout << "Number list value: item=" << *p << std::endl;
for(const auto& p : values)
std::cout << "Number list value: item=" << p << std::endl;
}
catch(const Glib::KeyFileError& ex)
{
......
......@@ -84,9 +84,9 @@ void DumpParser::on_start_element(Glib::Markup::ParseContext&,
indent();
std::cout << '<' << element_name;
for(auto p = attributes.begin(); p != attributes.end(); ++p)
for(const auto& p : attributes)
{
std::cout << ' ' << p->first << "=\"" << p->second << '"';
std::cout << ' ' << p.first << "=\"" << p.second << '"';
}
std::cout << ">\n";
......
......@@ -95,10 +95,9 @@ print_resolved_addresses (const Glib::ustring& name,
{
G_LOCK (response);
std::cout << Glib::ustring::compose ("Name: %1\n", name);
for (auto iter = addresses.begin ();
iter != addresses.end (); ++iter)
for (const auto& i : addresses)
{
std::cout << Glib::ustring::compose ("Address: %1\n", (*iter)->to_string ());
std::cout << Glib::ustring::compose ("Address: %1\n", i->to_string ());
}
std::cout << std::endl;
......@@ -112,15 +111,14 @@ print_resolved_service (const Glib::ustring& service,
{
G_LOCK (response);
std::cout << Glib::ustring::compose ("Service: %1\n", service);
for (auto iter = targets.begin ();
iter != targets.end (); ++iter)
for (const auto& i : targets)
{
std::cout <<
Glib::ustring::compose ("%1:%2 (pri %3, weight %4)\n",
iter->get_hostname (),
iter->get_port (),
iter->get_priority (),
iter->get_weight ());
i.get_hostname (),
i.get_port (),
i.get_priority (),
i.get_weight ());
}
std::cout << std::endl;
......
......@@ -222,17 +222,17 @@ 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(auto iter = group.m_arg_list.begin(); iter != group.m_arg_list.end(); ++iter)
for(const auto& i : group.m_arg_list)
{
std::cout << *iter << ", ";
std::cout << i << ", ";
}
std::cout << std::endl;
//This one shows the remaining arguments on the command line, which had no name= form:
std::cout << " remaining = ";
for(auto iter = group.m_remaining_list.begin(); iter != group.m_remaining_list.end(); ++iter)
for(const auto& i : group.m_remaining_list)
{
std::cout << *iter << ", ";
std::cout << i << ", ";
}
std::cout << std::endl;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment