From d443ddb053141510311e002c59746a2dd9ba8b16 Mon Sep 17 00:00:00 2001
From: David Robillard <d@drobilla.net>
Date: Fri, 11 Jan 2013 05:40:18 +0000
Subject: Use range-based for loops where possible.

Mmm, shiny.


git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4919 a436a847-0d15-0410-975c-d299462d15a1
---
 src/AtomWriter.cpp                  | 13 ++++-----
 src/Builder.cpp                     |  5 ++--
 src/Configuration.cpp               | 22 +++++++--------
 src/LV2Features.cpp                 |  4 +--
 src/Resource.cpp                    | 28 +++++++++----------
 src/World.cpp                       | 16 +++++------
 src/client/BlockModel.cpp           |  6 ++--
 src/client/ClientStore.cpp          | 32 ++++++++++-----------
 src/client/ObjectModel.cpp          |  7 ++---
 src/client/PluginModel.cpp          |  8 ++----
 src/client/PortModel.cpp            |  7 ++---
 src/gui/BreadCrumbs.cpp             | 38 ++++++++++++-------------
 src/gui/GraphBox.cpp                | 10 +++----
 src/gui/GraphCanvas.cpp             | 37 ++++++++++---------------
 src/gui/GraphPortModule.cpp         |  5 ++--
 src/gui/GraphView.cpp               |  5 ++--
 src/gui/LoadGraphWindow.cpp         |  6 ++--
 src/gui/LoadPluginWindow.cpp        | 12 ++++----
 src/gui/NodeMenu.cpp                | 12 ++++----
 src/gui/NodeModule.cpp              | 19 ++++++-------
 src/gui/Port.cpp                    | 10 +++----
 src/gui/PortPropertiesWindow.cpp    |  4 +--
 src/gui/PropertiesWindow.cpp        | 36 ++++++++++++------------
 src/gui/RDFS.cpp                    |  8 +++---
 src/gui/WindowFactory.cpp           | 15 ++++------
 src/serialisation/Parser.cpp        | 12 ++++----
 src/serialisation/Serialiser.cpp    | 11 ++++----
 src/server/BlockFactory.cpp         |  8 +++---
 src/server/Broadcaster.cpp          |  8 +++---
 src/server/Broadcaster.hpp          |  4 +--
 src/server/CompiledGraph.hpp        |  8 +++---
 src/server/Engine.cpp               | 10 +++----
 src/server/GraphImpl.cpp            | 55 ++++++++++++++++++-------------------
 src/server/InputPort.cpp            |  4 +--
 src/server/JackDriver.cpp           | 22 +++++++--------
 src/server/events/CreateBlock.cpp   |  4 +--
 src/server/events/Delta.cpp         | 38 ++++++++++++-------------
 src/server/events/DisconnectAll.cpp | 32 ++++++++++-----------
 src/server/events/Get.cpp           | 10 +++----
 src/server/ingen_lv2.cpp            | 20 +++++++-------
 40 files changed, 286 insertions(+), 325 deletions(-)

(limited to 'src')

diff --git a/src/AtomWriter.cpp b/src/AtomWriter.cpp
index b0cb2f27..1b4a1ca5 100644
--- a/src/AtomWriter.cpp
+++ b/src/AtomWriter.cpp
@@ -95,14 +95,13 @@ AtomWriter::forge_uri(const Raul::URI& uri)
 void
 AtomWriter::forge_properties(const Resource::Properties& properties)
 {
-	for (Resource::Properties::const_iterator i = properties.begin();
-	     i != properties.end(); ++i) {
-		lv2_atom_forge_property_head(&_forge, _map.map_uri(i->first.c_str()), 0);
-		if (i->second.type() == _forge.URI) {
-			forge_uri(Raul::URI(i->second.get_uri()));
+	for (auto p : properties) {
+		lv2_atom_forge_property_head(&_forge, _map.map_uri(p.first.c_str()), 0);
+		if (p.second.type() == _forge.URI) {
+			forge_uri(Raul::URI(p.second.get_uri()));
 		} else {
-			lv2_atom_forge_atom(&_forge, i->second.size(), i->second.type());
-			lv2_atom_forge_write(&_forge, i->second.get_body(), i->second.size());
+			lv2_atom_forge_atom(&_forge, p.second.size(), p.second.type());
+			lv2_atom_forge_write(&_forge, p.second.get_body(), p.second.size());
 		}
 	}
 }
diff --git a/src/Builder.cpp b/src/Builder.cpp
index b4bd2b3a..a4a519b4 100644
--- a/src/Builder.cpp
+++ b/src/Builder.cpp
@@ -42,9 +42,8 @@ void
 Builder::connect(SharedPtr<const Node> object)
 {
 	if (object->graph_type() == Node::GraphType::GRAPH) {
-		for (Node::Arcs::const_iterator i = object->arcs().begin();
-		     i != object->arcs().end(); ++i) {
-			_interface.connect(i->second->tail_path(), i->second->head_path());
+		for (auto a : object->arcs()) {
+			_interface.connect(a.second->tail_path(), a.second->head_path());
 		}
 		return;
 	}
diff --git a/src/Configuration.cpp b/src/Configuration.cpp
index 60f41597..2776d560 100644
--- a/src/Configuration.cpp
+++ b/src/Configuration.cpp
@@ -96,15 +96,15 @@ Configuration::print_usage(const std::string& program, std::ostream& os)
 	os << _shortdesc << std::endl << std::endl;
 	os << _desc << std::endl << std::endl;
 	os << "Options:" << std::endl;
-	for (Options::iterator o = _options.begin(); o != _options.end(); ++o) {
-		Option& option = o->second;
+	for (auto o : _options) {
+		Option& option = o.second;
 			os << "  ";
 		if (option.letter != '\0')
 			os << "-" << option.letter << ", ";
 		else
 			os << "    ";
 		os.width(_max_name_length + 4);
-		os << std::left << (std::string("--") + o->first);
+		os << std::left << (std::string("--") + o.first);
 		os << option.desc << std::endl;
 	}
 }
@@ -281,15 +281,15 @@ Configuration::save(URIMap&            uri_map,
 	                writer);
 
 	// Write a statement for each valid option
-	for (Options::iterator o = _options.begin(); o != _options.end(); ++o) {
-		const Raul::Atom& value = o->second.value;
-		if (!(o->second.scope & scopes) ||
-			o->second.key.empty() ||
+	for (auto o : _options) {
+		const Raul::Atom& value = o.second.value;
+		if (!(o.second.scope & scopes) ||
+			o.second.key.empty() ||
 		    !value.is_valid()) {
 			continue;
 		}
 
-		const std::string key(std::string("ingen:") + o->second.key);
+		const std::string key(std::string("ingen:") + o.second.key);
 		SerdNode pred = serd_node_from_string(
 			SERD_CURIE, (const uint8_t*)key.c_str());
 		sratom_write(sratom, &uri_map.urid_unmap_feature()->urid_unmap, 0,
@@ -312,10 +312,8 @@ Configuration::load_default(const std::string& app,
 	std::list<std::string> loaded;
 
 	const std::vector<std::string> dirs = Glib::get_system_config_dirs();
-	for (std::vector<std::string>::const_iterator i = dirs.begin();
-	     i != dirs.end();
-	     ++i) {
-		const std::string path = Glib::build_filename(*i, app, filename);
+	for (auto d : dirs) {
+		const std::string path = Glib::build_filename(d, app, filename);
 		if (load(path)) {
 			loaded.push_back(path);
 		}
diff --git a/src/LV2Features.cpp b/src/LV2Features.cpp
index 612cd9f7..a7069a75 100644
--- a/src/LV2Features.cpp
+++ b/src/LV2Features.cpp
@@ -57,8 +57,8 @@ SharedPtr<LV2Features::FeatureArray>
 LV2Features::lv2_features(World* world, Node* node) const
 {
 	FeatureArray::FeatureVector vec;
-	for (Features::const_iterator f = _features.begin(); f != _features.end(); ++f) {
-		SharedPtr<LV2_Feature> fptr = (*f)->feature(world, node);
+	for (const auto& f : _features) {
+		SharedPtr<LV2_Feature> fptr = f->feature(world, node);
 		if (fptr) {
 			vec.push_back(fptr);
 		}
diff --git a/src/Resource.cpp b/src/Resource.cpp
index 38c00248..1a701eca 100644
--- a/src/Resource.cpp
+++ b/src/Resource.cpp
@@ -152,35 +152,35 @@ Resource::type(const URIs&       uris,
 }
 
 void
-Resource::set_properties(const Properties& p)
+Resource::set_properties(const Properties& props)
 {
 	/* Note a simple loop that calls set_property is inappropriate here since
 	   it will not correctly set multiple properties in p (notably rdf:type)
 	*/
 
 	// Erase existing properties with matching keys
-	for (Properties::const_iterator i = p.begin(); i != p.end(); ++i) {
-		_properties.erase(i->first);
+	for (const auto& p : props) {
+		_properties.erase(p.first);
 	}
 
 	// Set new properties
-	add_properties(p);
+	add_properties(props);
 }
 
 void
-Resource::add_properties(const Properties& p)
+Resource::add_properties(const Properties& props)
 {
 	typedef Resource::Properties::const_iterator iterator;
-	for (iterator i = p.begin(); i != p.end(); ++i)
-		add_property(i->first, i->second, i->second.context());
+	for (const auto& p : props)
+		add_property(p.first, p.second, p.second.context());
 }
 
 void
-Resource::remove_properties(const Properties& p)
+Resource::remove_properties(const Properties& props)
 {
 	typedef Resource::Properties::const_iterator iterator;
-	for (iterator i = p.begin(); i != p.end(); ++i)
-		remove_property(i->first, i->second);
+	for (const auto& p : props)
+		remove_property(p.first, p.second);
 }
 
 Resource::Properties
@@ -193,10 +193,10 @@ Resource::properties(Resource::Graph ctx) const
 	typedef Resource::Properties::const_iterator iterator;
 
 	Properties props;
-	for (iterator i = _properties.begin(); i != _properties.end(); ++i) {
-		if (i->second.context() == Resource::Graph::DEFAULT
-		    || i->second.context() == ctx) {
-			props.insert(make_pair(i->first, i->second));
+	for (const auto& p : _properties) {
+		if (p.second.context() == Resource::Graph::DEFAULT
+		    || p.second.context() == ctx) {
+			props.insert(make_pair(p.first, p.second));
 		}
 	}
 
diff --git a/src/World.cpp b/src/World.cpp
index 8b6a58ea..0b56262c 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -110,10 +110,8 @@ public:
 	{
 		// Parse default configuration files
 		std::list<std::string> files = conf.load_default("ingen", "options.ttl");
-		for (std::list<std::string>::const_iterator f = files.begin();
-		     f != files.end();
-		     ++f) {
-			log.info(Raul::fmt("Loaded configuration %1%\n") % *f);
+		for (const auto& f : files) {
+			log.info(Raul::fmt("Loaded configuration %1%\n") % f);
 		}
 
 		// Parse command line options, overriding configuration file values
@@ -164,9 +162,9 @@ public:
 		// Delete module objects but save pointers to libraries
 		typedef std::list<Glib::Module*> Libs;
 		Libs libs;
-		for (Modules::iterator i = modules.begin(); i != modules.end(); ++i) {
-			libs.push_back(i->second->library);
-			delete i->second;
+		for (auto& m : modules) {
+			libs.push_back(m.second->library);
+			delete m.second;
 		}
 
 		delete rdf_world;
@@ -178,8 +176,8 @@ public:
 		lilv_world_free(lilv_world);
 
 		// Close module libraries
-		for (Libs::iterator l = libs.begin(); l != libs.end(); ++l) {
-			delete *l;
+		for (auto& l : libs) {
+			delete l;
 		}
 	}
 
diff --git a/src/client/BlockModel.cpp b/src/client/BlockModel.cpp
index cacba04c..eb982f0d 100644
--- a/src/client/BlockModel.cpp
+++ b/src/client/BlockModel.cpp
@@ -143,9 +143,9 @@ BlockModel::add_port(SharedPtr<PortModel> pm)
 SharedPtr<const PortModel>
 BlockModel::get_port(const Raul::Symbol& symbol) const
 {
-	for (Ports::const_iterator i = _ports.begin(); i != _ports.end(); ++i)
-		if ((*i)->symbol() == symbol)
-			return (*i);
+	for (auto p : _ports)
+		if (p->symbol() == symbol)
+			return p;
 	return SharedPtr<PortModel>();
 }
 
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp
index a6b011a4..318d31a5 100644
--- a/src/client/ClientStore.cpp
+++ b/src/client/ClientStore.cpp
@@ -93,9 +93,8 @@ ClientStore::add_object(SharedPtr<ObjectModel> object)
 	}
 
 	typedef Resource::Properties::const_iterator Iterator;
-	for (Iterator i = object->properties().begin();
-	     i != object->properties().end(); ++i)
-		object->signal_property().emit(i->first, i->second);
+	for (auto p : object->properties())
+		object->signal_property().emit(p.first, p.second);
 }
 
 SharedPtr<ObjectModel>
@@ -217,9 +216,9 @@ ClientStore::put(const Raul::URI&            uri,
 	typedef Resource::Properties::const_iterator Iterator;
 #ifdef INGEN_CLIENT_STORE_DUMP
 	std::cerr << "Put " << uri << " {" << endl;
-	for (Iterator i = properties.begin(); i != properties.end(); ++i)
-		std::cerr << '\t' << i->first << " = " << _uris.forge.str(i->second)
-		          << " :: " << i->second.type() << endl;
+	for (auto p : properties)
+		std::cerr << '\t' << p.first << " = " << _uris.forge.str(p.second)
+		          << " :: " << p.second.type() << endl;
 	std::cerr << "}" << endl;
 #endif
 
@@ -313,14 +312,14 @@ ClientStore::delta(const Raul::URI&            uri,
 	typedef Resource::Properties::const_iterator iterator;
 #ifdef INGEN_CLIENT_STORE_DUMP
 	std::cerr << "Delta " << uri << " {" << endl;
-	for (iterator i = remove.begin(); i != remove.end(); ++i)
-		std::cerr << "    - " << i->first
-		          << " = " << _uris.forge.str(i->second)
-		          << " :: " << i->second.type() << endl;
-	for (iterator i = add.begin(); i != add.end(); ++i)
-		std::cerr << "    + " << i->first
-		          << " = " << _uris.forge.str(i->second)
-		          << " :: " << i->second.type() << endl;
+	for (auto r : remove)
+		std::cerr << "    - " << r.first
+		          << " = " << _uris.forge.str(r.second)
+		          << " :: " << r.second.type() << endl;
+	for (auto a : add)
+		std::cerr << "    + " << a.first
+		          << " = " << _uris.forge.str(a.second)
+		          << " :: " << a.second.type() << endl;
 	std::cerr << "}" << endl;
 #endif
 
@@ -459,9 +458,8 @@ ClientStore::disconnect_all(const Raul::Path& parent_graph,
 	}
 
 	const GraphModel::Arcs arcs = graph->arcs();
-	for (GraphModel::Arcs::const_iterator i = arcs.begin();
-	     i != arcs.end(); ++i) {
-		SharedPtr<ArcModel> arc = PtrCast<ArcModel>(i->second);
+	for (auto a : arcs) {
+		SharedPtr<ArcModel> arc = PtrCast<ArcModel>(a.second);
 		if (arc->tail()->parent() == object
 		    || arc->head()->parent() == object
 		    || arc->tail()->path() == path
diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp
index 5c2bae00..51427f90 100644
--- a/src/client/ObjectModel.cpp
+++ b/src/client/ObjectModel.cpp
@@ -79,10 +79,9 @@ ObjectModel::set(SharedPtr<ObjectModel> o)
 	if (o->_parent)
 		_parent = o->_parent;
 
-	for (Properties::const_iterator v = o->properties().begin();
-	     v != o->properties().end(); ++v) {
-		Resource::set_property(v->first, v->second);
-		_signal_property.emit(v->first, v->second);
+	for (auto v : o->properties()) {
+		Resource::set_property(v.first, v.second);
+		_signal_property.emit(v.first, v.second);
 	}
 }
 
diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp
index 63113e54..8bf7aead 100644
--- a/src/client/PluginModel.cpp
+++ b/src/client/PluginModel.cpp
@@ -159,11 +159,9 @@ PluginModel::set(SharedPtr<PluginModel> p)
 	if (p->_lilv_plugin)
 		_lilv_plugin = p->_lilv_plugin;
 
-	for (Properties::const_iterator v = p->properties().begin();
-	     v != p->properties().end();
-	     ++v) {
-		Resource::set_property(v->first, v->second);
-		_signal_property.emit(v->first, v->second);
+	for (auto v : p->properties()) {
+		Resource::set_property(v.first, v.second);
+		_signal_property.emit(v.first, v.second);
 	}
 
 	_signal_changed.emit();
diff --git a/src/client/PortModel.cpp b/src/client/PortModel.cpp
index e936a1e2..a4261202 100644
--- a/src/client/PortModel.cpp
+++ b/src/client/PortModel.cpp
@@ -54,10 +54,9 @@ bool
 PortModel::is_uri() const
 {
 	// FIXME: Resource::has_property doesn't work, URI != URID
-	for (Resource::Properties::const_iterator i = properties().begin();
-	     i != properties().end(); ++i) {
-		if (i->second.type() == _uris.atom_URID &&
-		    static_cast<LV2_URID>(i->second.get_int32()) == _uris.atom_URID) {
+	for (auto p : properties()) {
+		if (p.second.type() == _uris.atom_URID &&
+		    static_cast<LV2_URID>(p.second.get_int32()) == _uris.atom_URID) {
 			return true;
 		}
 	}
diff --git a/src/gui/BreadCrumbs.cpp b/src/gui/BreadCrumbs.cpp
index bc6fc756..22142285 100644
--- a/src/gui/BreadCrumbs.cpp
+++ b/src/gui/BreadCrumbs.cpp
@@ -42,9 +42,9 @@ BreadCrumbs::BreadCrumbs(App& app)
 SharedPtr<GraphView>
 BreadCrumbs::view(const Raul::Path& path)
 {
-	for (std::list<BreadCrumb*>::const_iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i)
-		if ((*i)->path() == path)
-			return (*i)->view();
+	for (const auto& b : _breadcrumbs)
+		if (b->path() == path)
+			return b->view();
 
 	return SharedPtr<GraphView>();
 }
@@ -62,17 +62,17 @@ BreadCrumbs::build(Raul::Path path, SharedPtr<GraphView> view)
 
 	// Moving to a path we already contain, just switch the active button
 	if (!_breadcrumbs.empty() && (path.is_parent_of(_full_path) || path == _full_path)) {
-		for (std::list<BreadCrumb*>::iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i) {
-			if ((*i)->path() == path) {
-				(*i)->set_active(true);
-				if (!(*i)->view())
-					(*i)->set_view(view);
+		for (const auto& b : _breadcrumbs) {
+			if (b->path() == path) {
+				b->set_active(true);
+				if (!b->view())
+					b->set_view(view);
 
 				// views are expensive, having two around for the same graph is a bug
-				assert((*i)->view() == view);
+				assert(b->view() == view);
 
 			} else {
-				(*i)->set_active(false);
+				b->set_active(false);
 			}
 		}
 
@@ -98,8 +98,8 @@ BreadCrumbs::build(Raul::Path path, SharedPtr<GraphView> view)
 				suffix = suffix.substr(suffix.find("/")+1);
 		}
 
-		for (std::list<BreadCrumb*>::iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i)
-			(*i)->set_active(false);
+		for (const auto& b : _breadcrumbs)
+			b->set_active(false);
 		_breadcrumbs.back()->set_active(true);
 
 	// Rebuild from scratch
@@ -110,8 +110,8 @@ BreadCrumbs::build(Raul::Path path, SharedPtr<GraphView> view)
 		_active_path = path;
 
 		// Empty existing breadcrumbs
-		for (std::list<BreadCrumb*>::iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i)
-			remove(**i);
+		for (const auto& b : _breadcrumbs)
+			remove(*b);
 		_breadcrumbs.clear();
 
 		// Add root
@@ -179,10 +179,10 @@ BreadCrumbs::breadcrumb_clicked(BreadCrumb* crumb)
 void
 BreadCrumbs::object_destroyed(const Raul::URI& uri)
 {
-	for (std::list<BreadCrumb*>::iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i) {
+	for (auto i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i) {
 		if ((*i)->path() == uri.c_str()) {
 			// Remove all crumbs after the removed one (inclusive)
-			for (std::list<BreadCrumb*>::iterator j = i; j != _breadcrumbs.end(); ) {
+			for (auto j = i; j != _breadcrumbs.end(); ) {
 				BreadCrumb* bc = *j;
 				j = _breadcrumbs.erase(j);
 				remove(*bc);
@@ -195,9 +195,9 @@ BreadCrumbs::object_destroyed(const Raul::URI& uri)
 void
 BreadCrumbs::object_moved(const Raul::Path& old_path, const Raul::Path& new_path)
 {
-	for (std::list<BreadCrumb*>::iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i) {
-		if ((*i)->path() == old_path)
-			(*i)->set_path(new_path);
+	for (const auto& b : _breadcrumbs) {
+		if (b->path() == old_path)
+			b->set_path(new_path);
 	}
 }
 
diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp
index 1440bc1a..fd47ee26 100644
--- a/src/gui/GraphBox.cpp
+++ b/src/gui/GraphBox.cpp
@@ -258,9 +258,8 @@ GraphBox::set_graph(SharedPtr<const GraphModel> graph,
 
 	_menu_view_control_window->property_sensitive() = false;
 
-	for (BlockModel::Ports::const_iterator p = graph->ports().begin();
-	     p != graph->ports().end(); ++p) {
-		if (_app->can_control(p->get())) {
+	for (const auto& p : graph->ports()) {
+		if (_app->can_control(p.get())) {
 			_menu_view_control_window->property_sensitive() = true;
 			break;
 		}
@@ -301,9 +300,8 @@ GraphBox::graph_port_removed(SharedPtr<const PortModel> port)
 	if (!(port->is_input() && _app->can_control(port.get())))
 		return;
 
-	for (BlockModel::Ports::const_iterator i = _graph->ports().begin();
-	     i != _graph->ports().end(); ++i) {
-		if ((*i)->is_input() && _app->can_control(i->get())) {
+	for (const auto& p : _graph->ports()) {
+		if (p->is_input() && _app->can_control(p.get())) {
 			_menu_view_control_window->property_sensitive() = true;
 			return;
 		}
diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp
index d8ba7b2e..371f7444 100644
--- a/src/gui/GraphCanvas.cpp
+++ b/src/gui/GraphCanvas.cpp
@@ -51,10 +51,6 @@
 #include "WidgetFactory.hpp"
 #include "WindowFactory.hpp"
 
-#define FOREACH_ITEM(iter, coll) \
-	for (Items::const_iterator (iter) = coll.begin(); \
-	     (iter) != coll.end(); ++(iter))
-
 using namespace std;
 
 namespace Ingen {
@@ -212,8 +208,8 @@ GraphCanvas::build_menus()
 
 	// Add known plugins to menu heirarchy
 	SharedPtr<const ClientStore::Plugins> plugins = _app.store()->plugins();
-	for (ClientStore::Plugins::const_iterator i = plugins->begin(); i != plugins->end(); ++i)
-		add_plugin(i->second);
+	for (const auto& p : *plugins.get())
+		add_plugin(p.second);
 }
 
 /** Recursively build the plugin class menu heirarchy rooted at
@@ -316,15 +312,13 @@ GraphCanvas::build()
 	}
 
 	// Create pseudo modules for ports (ports on this canvas, not on our module)
-	for (BlockModel::Ports::const_iterator i = _graph->ports().begin();
-	     i != _graph->ports().end(); ++i) {
-		add_port(*i);
+	for (const auto& p : _graph->ports()) {
+		add_port(p);
 	}
 
 	// Create arcs
-	for (GraphModel::Arcs::const_iterator i = _graph->arcs().begin();
-	     i != _graph->arcs().end(); ++i) {
-		connection(PtrCast<ArcModel>(i->second));
+	for (const auto& a : _graph->arcs()) {
+		connection(PtrCast<ArcModel>(a.second));
 	}
 }
 
@@ -487,9 +481,8 @@ GraphCanvas::get_port_view(SharedPtr<PortModel> port)
 	} else {
 		module = dynamic_cast<NodeModule*>(_views[port->parent()]);
 		if (module) {
-			for (Ganv::Module::iterator p = module->begin();
-			     p != module->end(); ++p) {
-				GUI::Port* pv = dynamic_cast<GUI::Port*>(*p);
+			for (const auto& p : *module) {
+				GUI::Port* pv = dynamic_cast<GUI::Port*>(p);
 				if (pv && pv->model() == port)
 					return pv;
 			}
@@ -769,24 +762,24 @@ GraphCanvas::paste()
 	parser->parse_string(_app.world(), &avoider, str, base_uri,
 	                     parent, symbol);
 
-	for (Store::iterator i = clipboard.begin(); i != clipboard.end(); ++i) {
-		if (_graph->path().is_root() && i->first.is_root())
+	for (const auto& c : clipboard) {
+		if (_graph->path().is_root() && c.first.is_root())
 			continue;
 
-		Node::Properties& props = i->second->properties();
+		Node::Properties& props = c.second->properties();
 
 		Node::Properties::iterator x = props.find(uris.ingen_canvasX);
-		if (x != i->second->properties().end())
+		if (x != c.second->properties().end())
 			x->second = _app.forge().make(
 				x->second.get_float() + (20.0f * _paste_count));
 
 		Node::Properties::iterator y = props.find(uris.ingen_canvasY);
-		if (y != i->second->properties().end())
+		if (y != c.second->properties().end())
 			y->second = _app.forge().make(
 				y->second.get_float() + (20.0f * _paste_count));
 
-		builder.build(i->second);
-		_pastees.insert(i->first);
+		builder.build(c.second);
+		_pastees.insert(c.first);
 	}
 
 	builder.connect(PtrCast<const GraphModel>(clipboard.object(_graph->path())));
diff --git a/src/gui/GraphPortModule.cpp b/src/gui/GraphPortModule.cpp
index 6d8ac465..d495cbe4 100644
--- a/src/gui/GraphPortModule.cpp
+++ b/src/gui/GraphPortModule.cpp
@@ -75,9 +75,8 @@ GraphPortModule::create(GraphCanvas&               canvas,
 
 	ret->set_port(port);
 
-	for (Resource::Properties::const_iterator m = model->properties().begin();
-	     m != model->properties().end(); ++m)
-		ret->property_changed(m->first, m->second);
+	for (const auto& p : model->properties())
+		ret->property_changed(p.first, p.second);
 
 	return ret;
 }
diff --git a/src/gui/GraphView.cpp b/src/gui/GraphView.cpp
index 9a755ffe..c795861d 100644
--- a/src/gui/GraphView.cpp
+++ b/src/gui/GraphView.cpp
@@ -83,9 +83,8 @@ GraphView::set_graph(SharedPtr<const GraphModel> graph)
 	_poly_spin->set_increments(1, 4);
 	_poly_spin->set_value(graph->internal_poly());
 
-	for (Node::Properties::const_iterator i = graph->properties().begin();
-			i != graph->properties().end(); ++i)
-		property_changed(i->first, i->second);
+	for (const auto& p : graph->properties())
+		property_changed(p.first, p.second);
 
 	// Connect model signals to track state
 	graph->signal_property().connect(
diff --git a/src/gui/LoadGraphWindow.cpp b/src/gui/LoadGraphWindow.cpp
index a547c279..c7e94a0e 100644
--- a/src/gui/LoadGraphWindow.cpp
+++ b/src/gui/LoadGraphWindow.cpp
@@ -177,20 +177,20 @@ LoadGraphWindow::ok_clicked()
 
 	} else {
 		std::list<Glib::ustring> uri_list = get_filenames();
-		for (std::list<Glib::ustring>::iterator i = uri_list.begin(); i != uri_list.end(); ++i) {
+		for (auto u : uri_list) {
 			// Cascade
 			Raul::Atom& x = _initial_data.find(uris.ingen_canvasX)->second;
 			x = _app->forge().make(x.get_float() + 20.0f);
 			Raul::Atom& y = _initial_data.find(uris.ingen_canvasY)->second;
 			y = _app->forge().make(y.get_float() + 20.0f);
 
-			Raul::Symbol symbol(symbol_from_filename(*i));
+			Raul::Symbol symbol(symbol_from_filename(u));
 			if (uri_list.size() == 1 && _symbol_entry->get_text() != "")
 				symbol = Raul::Symbol::symbolify(_symbol_entry->get_text());
 
 			symbol = avoid_symbol_clash(symbol);
 
-			_app->loader()->load_graph(false, *i,
+			_app->loader()->load_graph(false, u,
 					_graph->path(), symbol, _initial_data);
 		}
 	}
diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp
index b7e12281..7e61d48d 100644
--- a/src/gui/LoadPluginWindow.cpp
+++ b/src/gui/LoadPluginWindow.cpp
@@ -205,13 +205,13 @@ LoadPluginWindow::on_show()
 }
 
 void
-LoadPluginWindow::set_plugins(SharedPtr<const ClientStore::Plugins> m)
+LoadPluginWindow::set_plugins(SharedPtr<const ClientStore::Plugins> plugins)
 {
 	_rows.clear();
 	_plugins_liststore->clear();
 
-	for (ClientStore::Plugins::const_iterator i = m->begin(); i != m->end(); ++i) {
-		add_plugin(i->second);
+	for (const auto& p : *plugins.get()) {
+		add_plugin(p.second);
 	}
 
 	_plugins_liststore->set_sort_column(1, Gtk::SORT_ASCENDING);
@@ -445,10 +445,8 @@ LoadPluginWindow::filter_changed()
 	size_t                   num_visible = 0;
 	const URIs&              uris        = _app->uris();
 
-	for (ClientStore::Plugins::const_iterator i = _app->store()->plugins()->begin();
-	     i != _app->store()->plugins()->end(); ++i) {
-
-		const SharedPtr<PluginModel> plugin = (*i).second;
+	for (const auto& p : *_app->store()->plugins().get()) {
+		const SharedPtr<PluginModel> plugin = p.second;
 		const Raul::Atom& name = plugin->get_property(uris.doap_name);
 
 		switch (criteria) {
diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp
index 484a8af7..548aa68a 100644
--- a/src/gui/NodeMenu.cpp
+++ b/src/gui/NodeMenu.cpp
@@ -151,13 +151,13 @@ NodeMenu::on_menu_randomize()
 	_app->interface()->bundle_begin();
 
 	const BlockModel* const bm = (const BlockModel*)_object.get();
-	for (BlockModel::Ports::const_iterator i = bm->ports().begin(); i != bm->ports().end(); ++i) {
-		if ((*i)->is_input() && _app->can_control(i->get())) {
+	for (const auto& p : bm->ports()) {
+		if (p->is_input() && _app->can_control(p.get())) {
 			float min = 0.0f, max = 1.0f;
-			bm->port_value_range(*i, min, max, _app->sample_rate());
+			bm->port_value_range(p, min, max, _app->sample_rate());
 			const float val = g_random_double_range(0.0, 1.0) * (max - min) + min;
 			_app->interface()->set_property(
-				(*i)->uri(),
+				p->uri(),
 				_app->uris().ingen_value,
 				_app->forge().make(val));
 		}
@@ -225,8 +225,8 @@ bool
 NodeMenu::has_control_inputs()
 {
 	const BlockModel* const bm = (const BlockModel*)_object.get();
-	for (BlockModel::Ports::const_iterator i = bm->ports().begin(); i != bm->ports().end(); ++i)
-		if ((*i)->is_input() && (*i)->is_numeric())
+	for (const auto& p : bm->ports())
+		if (p->is_input() && p->is_numeric())
 			return true;
 
 	return false;
diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp
index f7333fec..3a73e67e 100644
--- a/src/gui/NodeModule.cpp
+++ b/src/gui/NodeModule.cpp
@@ -113,13 +113,11 @@ NodeModule::create(GraphCanvas&                canvas,
 		? new SubgraphModule(canvas, graph)
 		: new NodeModule(canvas, block);
 
-	for (Resource::Properties::const_iterator m = block->properties().begin();
-	     m != block->properties().end(); ++m)
-		ret->property_changed(m->first, m->second);
-
-	for (BlockModel::Ports::const_iterator p = block->ports().begin();
-	     p != block->ports().end(); ++p)
-		ret->new_port_view(*p);
+	for (const auto& p : block->properties())
+		ret->property_changed(p.first, p.second);
+	
+	for (const auto& p : block->ports()) 
+		ret->new_port_view(p);
 
 	ret->set_stacked(block->polyphonic());
 
@@ -355,10 +353,9 @@ void
 NodeModule::set_control_values()
 {
 	uint32_t index = 0;
-	for (BlockModel::Ports::const_iterator p = _block->ports().begin();
-	     p != _block->ports().end(); ++p) {
-		if (app().can_control(p->get())) {
-			value_changed(index, (*p)->value());
+	for (const auto& p : _block->ports()) {
+		if (app().can_control(p.get())) {
+			value_changed(index, p->value());
 		}
 		++index;
 	}
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp
index 6a6cdfe2..6bb96b78 100644
--- a/src/gui/Port.cpp
+++ b/src/gui/Port.cpp
@@ -249,15 +249,15 @@ Port::build_uri_menu()
 	RDFS::Objects values = RDFS::instances(world, ranges);
 
 	// Add a menu item for each such class
-	for (RDFS::Objects::const_iterator i = values.begin(); i != values.end(); ++i) {
-		if (!i->second.empty()) {
-			Glib::ustring label = world->rdf_world()->prefixes().qualify(i->first)
-				+ " - " + i->second;
+	for (const auto& v : values) {
+		if (!v.second.empty()) {
+			Glib::ustring label = world->rdf_world()->prefixes().qualify(v.first)
+				+ " - " + v.second;
 			menu->items().push_back(Gtk::Menu_Helpers::MenuElem(label));
 			Gtk::MenuItem* menu_item = &(menu->items().back());
 			menu_item->signal_activate().connect(
 				sigc::bind(sigc::mem_fun(this, &Port::on_uri_activated),
-				           i->first));
+				           v.first));
 		}
 	}
 
diff --git a/src/gui/PortPropertiesWindow.cpp b/src/gui/PortPropertiesWindow.cpp
index a4b2d5fc..a0162fba 100644
--- a/src/gui/PortPropertiesWindow.cpp
+++ b/src/gui/PortPropertiesWindow.cpp
@@ -56,8 +56,8 @@ PortPropertiesWindow::present(SharedPtr<const PortModel> pm)
 {
 	assert(pm);
 
-	for (list<sigc::connection>::iterator i = _connections.begin(); i != _connections.end(); ++i)
-		(*i).disconnect();
+	for (auto& c : _connections)
+		c.disconnect();
 
 	_connections.clear();
 
diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp
index ea4e6683..548fe8ec 100644
--- a/src/gui/PropertiesWindow.cpp
+++ b/src/gui/PropertiesWindow.cpp
@@ -156,8 +156,8 @@ PropertiesWindow::set_object(SharedPtr<const ObjectModel> model)
 
 	// Populate key combo
 	const URISet props = RDFS::properties(world, model);
-	for (URISet::const_iterator p = props.begin(); p != props.end(); ++p) {
-		LilvNode*           prop  = lilv_new_uri(world->lilv_world(), p->c_str());
+	for (const auto& p : props) {
+		LilvNode*           prop  = lilv_new_uri(world->lilv_world(), p.c_str());
 		const Glib::ustring label = RDFS::label(world, prop);
 		if (label.empty()) {
 			continue;
@@ -173,8 +173,8 @@ PropertiesWindow::set_object(SharedPtr<const ObjectModel> model)
 		RDFS::classes(world, ranges, false);
 
 		bool show = false;
-		for (URISet::const_iterator i = ranges.begin(); i != ranges.end(); ++i) {
-			LilvNode*  range   = lilv_new_uri(world->lilv_world(), i->c_str());
+		for (const auto& r : ranges) {
+			LilvNode*  range   = lilv_new_uri(world->lilv_world(), r.c_str());
 			LilvNodes* objects = lilv_world_find_nodes(
 				world->lilv_world(), NULL, rdf_type, range);
 
@@ -190,7 +190,7 @@ PropertiesWindow::set_object(SharedPtr<const ObjectModel> model)
 		if (show || ranges.empty()) {
 			Gtk::ListStore::iterator ki  = _key_store->append();
 			Gtk::ListStore::Row      row = *ki;
-			row[_combo_columns.uri_col]   = *p;
+			row[_combo_columns.uri_col]   = p;
 			row[_combo_columns.label_col] = label;
 		}
 
@@ -200,9 +200,8 @@ PropertiesWindow::set_object(SharedPtr<const ObjectModel> model)
 	lilv_node_free(rdfs_range);
 	lilv_node_free(rdf_type);
 
-	for (ObjectModel::Properties::const_iterator i = model->properties().begin();
-			i != model->properties().end(); ++i) {
-		add_property(i->first, i->second);
+	for (const auto& p : model->properties()) {
+		add_property(p.first, p.second);
 	}
 
 	_table->show_all();
@@ -284,9 +283,9 @@ PropertiesWindow::on_show()
 	Gtk::Requisition req;
 
 	typedef Gtk::Box_Helpers::BoxList Children;
-	for (Children::const_iterator i = _vbox->children().begin(); i != _vbox->children().end(); ++i) {
-		req = (*i).get_widget()->size_request();
-		if ((*i).get_widget() != _scrolledwindow) {
+	for (const auto& c : _vbox->children()) {
+		req = c.get_widget()->size_request();
+		if (c.get_widget() != _scrolledwindow) {
 			width = std::max(width, req.width);
 			height += req.height + VBOX_PAD;
 		}
@@ -402,12 +401,13 @@ PropertiesWindow::key_changed()
 	RDFS::Objects values = RDFS::instances(world, ranges);
 
 	// Fill value selector with suitable objects
-	for (RDFS::Objects::const_iterator i = values.begin(); i != values.end(); ++i) {
-		if (!i->second.empty()) {
+	for (const auto& v : values) {
+		if (!v.second.empty()) {
 			Gtk::ListStore::iterator vi   = _value_store->append();
 			Gtk::ListStore::Row      vrow = *vi;
-			vrow[_combo_columns.uri_col]   = i->first;
-			vrow[_combo_columns.label_col] = i->second;
+
+			vrow[_combo_columns.uri_col]   = v.first;
+			vrow[_combo_columns.label_col] = v.second;
 		}
 	}
 
@@ -446,9 +446,9 @@ void
 PropertiesWindow::apply_clicked()
 {
 	Resource::Properties properties;
-	for (Records::const_iterator r = _records.begin(); r != _records.end(); ++r) {
-		const Raul::URI& uri    = r->first;
-		const Record&    record = r->second;
+	for (const auto& r : _records) {
+		const Raul::URI& uri    = r.first;
+		const Record&    record = r.second;
 		if (!_model->has_property(uri, record.value)) {
 			properties.insert(make_pair(uri, record.value));
 		}
diff --git a/src/gui/RDFS.cpp b/src/gui/RDFS.cpp
index 0420d4dd..bec69cee 100644
--- a/src/gui/RDFS.cpp
+++ b/src/gui/RDFS.cpp
@@ -51,8 +51,8 @@ classes(World* world, URISet& types, bool super)
 	do {
 		added = 0;
 		URISet klasses;
-		for (URISet::iterator t = types.begin(); t != types.end(); ++t) {
-			LilvNode*  type    = lilv_new_uri(world->lilv_world(), t->c_str());
+		for (const auto& t : types) {
+			LilvNode*  type    = lilv_new_uri(world->lilv_world(), t.c_str());
 			LilvNodes* matches = (super)
 				? lilv_world_find_nodes(
 					world->lilv_world(), type, rdfs_subClassOf, NULL)
@@ -153,8 +153,8 @@ instances(World* world, const URISet& types)
 		world->lilv_world(), LILV_NS_RDF "type");
 
 	Objects result;
-	for (URISet::const_iterator i = types.begin(); i != types.end(); ++i) {
-		LilvNode*  type    = lilv_new_uri(world->lilv_world(), i->c_str());
+	for (const auto& t : types) {
+		LilvNode*  type    = lilv_new_uri(world->lilv_world(), t.c_str());
 		LilvNodes* objects = lilv_world_find_nodes(
 			world->lilv_world(), NULL, rdf_type, type);
 		LILV_FOREACH(nodes, o, objects) {
diff --git a/src/gui/WindowFactory.cpp b/src/gui/WindowFactory.cpp
index 57a21536..983e246b 100644
--- a/src/gui/WindowFactory.cpp
+++ b/src/gui/WindowFactory.cpp
@@ -60,17 +60,15 @@ WindowFactory::WindowFactory(App& app)
 
 WindowFactory::~WindowFactory()
 {
-	for (GraphWindowMap::iterator i = _graph_windows.begin();
-	     i != _graph_windows.end(); ++i)
-		delete i->second;
+	for (const auto& w : _graph_windows)
+		delete w.second;
 }
 
 void
 WindowFactory::clear()
 {
-	for (GraphWindowMap::iterator i = _graph_windows.begin();
-	     i != _graph_windows.end(); ++i)
-		delete i->second;
+	for (const auto& w : _graph_windows)
+		delete w.second;
 
 	_graph_windows.clear();
 }
@@ -81,9 +79,8 @@ size_t
 WindowFactory::num_open_graph_windows()
 {
 	size_t ret = 0;
-	for (GraphWindowMap::iterator i = _graph_windows.begin();
-	     i != _graph_windows.end(); ++i)
-		if (i->second->is_visible())
+	for (const auto& w : _graph_windows)
+		if (w.second->is_visible())
 			++ret;
 
 	return ret;
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp
index 5feb8e06..1cea22d6 100644
--- a/src/serialisation/Parser.cpp
+++ b/src/serialisation/Parser.cpp
@@ -375,9 +375,9 @@ parse_graph(Ingen::World*                     world,
 	}
 
 	// Create ports in order by index
-	for (PortRecords::const_iterator i = ports.begin(); i != ports.end(); ++i) {
-		target->put(Node::path_to_uri(i->second.first),
-		            i->second.second);
+	for (const auto& p : ports) {
+		target->put(Node::path_to_uri(p.second.first),
+		            p.second.second);
 	}
 
 	parse_arcs(world, target, model, subject_node, graph_path);
@@ -528,9 +528,9 @@ parse(Ingen::World*                     world,
 	}
 
 	// Parse and create each subject
-	for (Subjects::const_iterator i = subjects.begin(); i != subjects.end(); ++i) {
-		const Sord::Node&           s     = i->first;
-		const std::set<Sord::Node>& types = i->second;
+	for (const auto& i : subjects) {
+		const Sord::Node&           s     = i.first;
+		const std::set<Sord::Node>& types = i.second;
 		boost::optional<Raul::Path> ret;
 		const Raul::Path path(
 			relative_uri( model.base_uri().to_string(), s.to_string(), true));
diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp
index e371151a..0bd6b49b 100644
--- a/src/serialisation/Serialiser.cpp
+++ b/src/serialisation/Serialiser.cpp
@@ -413,9 +413,8 @@ Serialiser::Impl::serialise_graph(SharedPtr<const Node> graph,
 		serialise_port(p, Resource::Graph::INTERNAL, port_id);
 	}
 
-	for (Node::Arcs::const_iterator a = graph->arcs().begin();
-	     a != graph->arcs().end(); ++a) {
-		serialise_arc(graph_id, a->second);
+	for (const auto& a : graph->arcs()) {
+		serialise_arc(graph_id, a.second);
 	}
 }
 
@@ -544,13 +543,13 @@ Serialiser::Impl::serialise_properties(Sord::Node              id,
 	sratom_set_pretty_numbers(_sratom, true);
 
 	typedef Node::Properties::const_iterator iterator;
-	for (iterator v = props.begin(); v != props.end(); ++v) {
-		const Sord::URI key(_model->world(), v->first);
+	for (const auto& p : props) {
+		const Sord::URI key(_model->world(), p.first);
 		if (!skip_property(key)) {
 			sratom_write(_sratom, unmap, 0,
 			             sord_node_to_serd_node(id.c_obj()),
 			             sord_node_to_serd_node(key.c_obj()),
-			             v->second.type(), v->second.size(), v->second.get_body());
+			             p.second.type(), p.second.size(), p.second.get_body());
 		}
 	}
 
diff --git a/src/server/BlockFactory.cpp b/src/server/BlockFactory.cpp
index 9f5b93d8..61237ee4 100644
--- a/src/server/BlockFactory.cpp
+++ b/src/server/BlockFactory.cpp
@@ -49,8 +49,8 @@ BlockFactory::BlockFactory(Ingen::World* world)
 
 BlockFactory::~BlockFactory()
 {
-	for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i)
-		delete i->second;
+	for (auto& p : _plugins)
+		delete p.second;
 
 	_plugins.clear();
 }
@@ -162,8 +162,8 @@ BlockFactory::load_lv2_plugins()
 		for (uint32_t p = 0; p < n_ports; ++p) {
 			const LilvPort* port = lilv_plugin_get_port_by_index(lv2_plug, p);
 			supported = false;
-			for (Types::const_iterator t = types.begin(); t != types.end(); ++t) {
-				if (lilv_port_is_a(lv2_plug, port, t->get())) {
+			for (const auto& t : types) {
+				if (lilv_port_is_a(lv2_plug, port, t.get())) {
 					supported = true;
 					break;
 				}
diff --git a/src/server/Broadcaster.cpp b/src/server/Broadcaster.cpp
index 6c111a1c..49bc68ae 100644
--- a/src/server/Broadcaster.cpp
+++ b/src/server/Broadcaster.cpp
@@ -73,8 +73,8 @@ void
 Broadcaster::send_plugins(const BlockFactory::Plugins& plugins)
 {
 	Glib::Mutex::Lock lock(_clients_mutex);
-	for (Clients::const_iterator c = _clients.begin(); c != _clients.end(); ++c) {
-		send_plugins_to((*c).second.get(), plugins);
+	for (const auto& c : _clients) {
+		send_plugins_to(c.second.get(), plugins);
 	}
 }
 
@@ -84,8 +84,8 @@ Broadcaster::send_plugins_to(Interface*                   client,
 {
 	client->bundle_begin();
 
-	for (BlockFactory::Plugins::const_iterator i = plugins.begin(); i != plugins.end(); ++i) {
-		const PluginImpl* const plugin = i->second;
+	for (const auto& p : plugins) {
+		const PluginImpl* const plugin = p.second;
 		client->put(plugin->uri(), plugin->properties());
 	}
 
diff --git a/src/server/Broadcaster.hpp b/src/server/Broadcaster.hpp
index 78419991..559bf709 100644
--- a/src/server/Broadcaster.hpp
+++ b/src/server/Broadcaster.hpp
@@ -75,8 +75,8 @@ public:
 
 #define BROADCAST(msg, ...) \
 	Glib::Mutex::Lock lock(_clients_mutex); \
-	for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) \
-		(*i).second->msg(__VA_ARGS__)
+	for (const auto& c : _clients) \
+		c.second->msg(__VA_ARGS__)
 
 	void bundle_begin() { BROADCAST(bundle_begin); }
 	void bundle_end()   { BROADCAST(bundle_end); }
diff --git a/src/server/CompiledGraph.hpp b/src/server/CompiledGraph.hpp
index 024aa919..ee02a24e 100644
--- a/src/server/CompiledGraph.hpp
+++ b/src/server/CompiledGraph.hpp
@@ -33,15 +33,15 @@ class BlockImpl;
  */
 class CompiledBlock {
 public:
-	CompiledBlock(BlockImpl* b, size_t np, const std::list<BlockImpl*>& d)
+	CompiledBlock(BlockImpl* b, size_t np, const std::list<BlockImpl*>& deps)
 		: _block(b), _n_providers(np)
 	{
 		// Copy to a vector for maximum iteration speed and cache optimization
 		// (Need to take a copy anyway)
 
-		_dependants.reserve(d.size());
-		for (std::list<BlockImpl*>::const_iterator i = d.begin(); i != d.end(); ++i)
-			_dependants.push_back(*i);
+		_dependants.reserve(deps.size());
+		for (const auto& d : deps)
+			_dependants.push_back(d);
 	}
 
 	BlockImpl*                     block()       const { return _block; }
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index ce84de4d..5002feca 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -82,11 +82,11 @@ Engine::~Engine()
 	_root_graph = NULL;
 	deactivate();
 
-	const SharedPtr<Store> s = this->store();
-	if (s) {
-		for (Store::iterator i = s->begin(); i != s->end(); ++i) {
-			if (!PtrCast<NodeImpl>(i->second)->parent()) {
-				i->second.reset();
+	const SharedPtr<Store> store = this->store();
+	if (store) {
+		for (auto& s : *store.get()) {
+			if (!PtrCast<NodeImpl>(s.second)->parent()) {
+				s.second.reset();
 			}
 		}
 	}
diff --git a/src/server/GraphImpl.cpp b/src/server/GraphImpl.cpp
index 5859d071..14af654c 100644
--- a/src/server/GraphImpl.cpp
+++ b/src/server/GraphImpl.cpp
@@ -68,8 +68,8 @@ GraphImpl::activate(BufferFactory& bufs)
 {
 	BlockImpl::activate(bufs);
 
-	for (Blocks::iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
-		i->activate(bufs);
+	for (auto& b : _blocks) {
+		b.activate(bufs);
 	}
 
 	assert(_activated);
@@ -81,9 +81,9 @@ GraphImpl::deactivate()
 	if (_activated) {
 		BlockImpl::deactivate();
 
-		for (Blocks::iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
-			if (i->activated()) {
-				i->deactivate();
+		for (auto& b : _blocks) {
+			if (b.activated()) {
+				b.deactivate();
 			}
 		}
 	}
@@ -93,8 +93,8 @@ void
 GraphImpl::disable(ProcessContext& context)
 {
 	_process = false;
-	for (Ports::iterator i = _outputs.begin(); i != _outputs.end(); ++i) {
-		i->clear_buffers();
+	for (auto& o : _outputs) {
+		o.clear_buffers();
 	}
 }
 
@@ -105,8 +105,8 @@ GraphImpl::prepare_internal_poly(BufferFactory& bufs, uint32_t poly)
 
 	// TODO: Subgraph dynamic polyphony (i.e. changing port polyphony)
 
-	for (Blocks::iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
-		i->prepare_poly(bufs, poly);
+	for (auto& b : _blocks) {
+		b.prepare_poly(bufs, poly);
 	}
 
 	_poly_pre = poly;
@@ -121,13 +121,13 @@ GraphImpl::apply_internal_poly(ProcessContext& context,
 {
 	// TODO: Subgraph dynamic polyphony (i.e. changing port polyphony)
 
-	for (Blocks::iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
-		i->apply_poly(context, maid, poly);
+	for (auto& b : _blocks) {
+		b.apply_poly(context, maid, poly);
 	}
 
-	for (Blocks::iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
-		for (uint32_t j = 0; j < i->num_ports(); ++j) {
-			PortImpl* const port = i->port_impl(j);
+	for (auto& b : _blocks) {
+		for (uint32_t j = 0; j < b.num_ports(); ++j) {
+			PortImpl* const port = b.port_impl(j);
 			if (port->is_input() && dynamic_cast<InputPort*>(port)->direct_connect())
 				port->setup_buffers(bufs, port->poly(), true);
 			port->connect_buffers();
@@ -135,8 +135,8 @@ GraphImpl::apply_internal_poly(ProcessContext& context,
 	}
 
 	const bool polyphonic = parent_graph() && (poly == parent_graph()->internal_poly_process());
-	for (Ports::iterator i = _outputs.begin(); i != _outputs.end(); ++i)
-		i->setup_buffers(bufs, polyphonic ? poly : 1, true);
+	for (auto& o : _outputs)
+		o.setup_buffers(bufs, polyphonic ? poly : 1, true);
 
 	_poly_process = poly;
 	return true;
@@ -331,10 +331,9 @@ compile_recursive(BlockImpl* n, CompiledGraph* output)
 	n->traversed(true);
 	assert(output != NULL);
 
-	for (std::list<BlockImpl*>::iterator i = n->providers().begin();
-	     i != n->providers().end(); ++i)
-		if (!(*i)->traversed())
-			compile_recursive(*i, output);
+	for (auto& p : n->providers())
+		if (!p->traversed())
+			compile_recursive(p, output);
 
 	output->push_back(CompiledBlock(n, n->providers().size(), n->dependants()));
 }
@@ -356,21 +355,21 @@ GraphImpl::compile()
 
 	CompiledGraph* const compiled_graph = new CompiledGraph();
 
-	for (Blocks::iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
-		i->traversed(false);
+	for (auto& b : _blocks) {
+		b.traversed(false);
 	}
 
-	for (Blocks::iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
+	for (auto& b : _blocks) {
 		// Either a sink or connected to our output ports:
-		if (!i->traversed() && i->dependants().empty()) {
-			compile_recursive(&*i, compiled_graph);
+		if (!b.traversed() && b.dependants().empty()) {
+			compile_recursive(&b, compiled_graph);
 		}
 	}
 
 	// Traverse any blocks we didn't hit yet
-	for (Blocks::iterator i = _blocks.begin(); i != _blocks.end(); ++i) {
-		if (!i->traversed()) {
-			compile_recursive(&*i, compiled_graph);
+	for (auto& b : _blocks) {
+		if (!b.traversed()) {
+			compile_recursive(&b, compiled_graph);
 		}
 	}
 
diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp
index fe534eb0..94e451c0 100644
--- a/src/server/InputPort.cpp
+++ b/src/server/InputPort.cpp
@@ -211,8 +211,8 @@ InputPort::pre_process(Context& context)
 		for (uint32_t v = 0; v < _poly; ++v) {
 			// Get all the sources for this voice
 			uint32_t num_srcs = 0;
-			for (Arcs::iterator e = _arcs.begin(); e != _arcs.end(); ++e) {
-				get_sources(context, *e, v, srcs, max_num_srcs, num_srcs);
+			for (const auto& a : _arcs) {
+				get_sources(context, a, v, srcs, max_num_srcs, num_srcs);
 			}
 
 			// Then mix them into out buffer for this voice
diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp
index 3afbd51c..33d11e92 100644
--- a/src/server/JackDriver.cpp
+++ b/src/server/JackDriver.cpp
@@ -134,8 +134,8 @@ JackDriver::attach(const std::string& server_name,
 	jack_set_session_callback(_client, session_cb, this);
 #endif
 
-	for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
-		register_port(*i);
+	for (auto& p : _ports) {
+		register_port(p);
 	}
 
 	return true;
@@ -176,8 +176,8 @@ JackDriver::deactivate()
 		_is_activated = false;
 		_sem.wait();
 
-		for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
-			unregister_port(*i);
+		for (auto& p : _ports) {
+			unregister_port(p);
 		}
 
 		if (_client) {
@@ -193,9 +193,9 @@ JackDriver::deactivate()
 EnginePort*
 JackDriver::get_port(const Raul::Path& path)
 {
-	for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
-		if (i->graph_port()->path() == path) {
-			return &*i;
+	for (auto& p : _ports) {
+		if (p.graph_port()->path() == path) {
+			return &p;
 		}
 	}
 
@@ -417,15 +417,15 @@ JackDriver::_process_cb(jack_nframes_t nframes)
 	_engine.process_context().locate(start_of_current_cycle, nframes);
 
 	// Read input
-	for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
-		pre_process_port(_engine.process_context(), &*i);
+	for (auto& p : _ports) {
+		pre_process_port(_engine.process_context(), &p);
 	}
 
 	_engine.run(nframes);
 
 	// Write output
-	for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
-		post_process_port(_engine.process_context(), &*i);
+	for (auto& p : _ports) {
+		post_process_port(_engine.process_context(), &p);
 	}
 
 	// Update expected transport frame for next cycle to detect changes
diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp
index 65e24bfd..90a76c1d 100644
--- a/src/server/events/CreateBlock.cpp
+++ b/src/server/events/CreateBlock.cpp
@@ -140,8 +140,8 @@ CreateBlock::post_process()
 {
 	Broadcaster::Transfer t(*_engine.broadcaster());
 	if (respond() == Status::SUCCESS) {
-		for (Update::const_iterator i = _update.begin(); i != _update.end(); ++i) {
-			_engine.broadcaster()->put(i->first, i->second);
+		for (const auto& u : _update) {
+			_engine.broadcaster()->put(u.first, u.second);
 		}
 	}
 }
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index 0f854096..352aa56c 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -65,10 +65,8 @@ Delta::Delta(Engine&              engine,
 	, _create(create)
 {
 	if (context != Resource::Graph::DEFAULT) {
-		for (Properties::iterator i = _properties.begin();
-		     i != _properties.end();
-		     ++i) {
-			i->second.set_context(context);
+		for (auto& p : _properties) {
+			p.second.set_context(context);
 		}
 	}
 
@@ -94,8 +92,8 @@ Delta::Delta(Engine&              engine,
 
 Delta::~Delta()
 {
-	for (SetEvents::iterator i = _set_events.begin(); i != _set_events.end(); ++i)
-		delete *i;
+	for (auto& s : _set_events)
+		delete s;
 
 	delete _create_event;
 }
@@ -149,9 +147,9 @@ Delta::pre_process()
 
 	NodeImpl* obj = dynamic_cast<NodeImpl*>(_object);
 
-	for (Properties::const_iterator p = _remove.begin(); p != _remove.end(); ++p) {
-		const Raul::URI&  key   = p->first;
-		const Raul::Atom& value = p->second;
+	for (const auto& r : _remove) {
+		const Raul::URI&  key   = r.first;
+		const Raul::Atom& value = r.second;
 		if (key == uris.ingen_controlBinding && value == uris.wildcard) {
 			PortImpl* port = dynamic_cast<PortImpl*>(_object);
 			if (port)
@@ -160,9 +158,9 @@ Delta::pre_process()
 		_object->remove_property(key, value);
 	}
 
-	for (Properties::const_iterator p = _properties.begin(); p != _properties.end(); ++p) {
-		const Raul::URI&          key   = p->first;
-		const Resource::Property& value = p->second;
+	for (const auto& p : _properties) {
+		const Raul::URI&          key   = p.first;
+		const Resource::Property& value = p.second;
 		SpecialType               op    = SpecialType::NONE;
 		if (obj) {
 			Resource& resource = *obj;
@@ -273,9 +271,9 @@ Delta::execute(ProcessContext& context)
 		_create_event->execute(context);
 	}
 
-	for (SetEvents::iterator i = _set_events.begin(); i != _set_events.end(); ++i) {
-		(*i)->set_time(_time);
-		(*i)->execute(context);
+	for (auto& s : _set_events) {
+		s->set_time(_time);
+		s->execute(context);
 	}
 
 	NodeImpl* const  object = dynamic_cast<NodeImpl*>(_object);
@@ -283,9 +281,9 @@ Delta::execute(ProcessContext& context)
 	PortImpl* const  port   = dynamic_cast<PortImpl*>(_object);
 
 	std::vector<SpecialType>::const_iterator t = _types.begin();
-	for (Properties::const_iterator p = _properties.begin(); p != _properties.end(); ++p, ++t) {
-		const Raul::URI&  key   = p->first;
-		const Raul::Atom& value = p->second;
+	for (const auto& p : _properties) {
+		const Raul::URI&  key   = p.first;
+		const Raul::Atom& value = p.second;
 		switch (*t) {
 		case SpecialType::ENABLE_BROADCAST:
 			if (port) {
@@ -346,8 +344,8 @@ Delta::post_process()
 {
 	Broadcaster::Transfer t(*_engine.broadcaster());
 
-	for (SetEvents::iterator i = _set_events.begin(); i != _set_events.end(); ++i)
-		(*i)->post_process();
+	for (auto& s : _set_events)
+		s->post_process();
 
 	if (_status == Status::SUCCESS) {
 		if (_create_event) {
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp
index a6022410..a3df4e77 100644
--- a/src/server/events/DisconnectAll.cpp
+++ b/src/server/events/DisconnectAll.cpp
@@ -75,8 +75,8 @@ DisconnectAll::DisconnectAll(Engine&    engine,
 
 DisconnectAll::~DisconnectAll()
 {
-	for (Impls::iterator i = _impls.begin(); i != _impls.end(); ++i)
-		delete (*i);
+	for (auto& i : _impls)
+		delete i;
 }
 
 bool
@@ -116,28 +116,26 @@ DisconnectAll::pre_process()
 
 	// Find set of arcs to remove
 	std::set<ArcImpl*> to_remove;
-	for (Node::Arcs::const_iterator i = _parent->arcs().begin();
-	     i != _parent->arcs().end(); ++i) {
-		ArcImpl* const c = (ArcImpl*)i->second.get();
+	for (const auto& a : _parent->arcs()) {
+		ArcImpl* const arc = (ArcImpl*)a.second.get();
 		if (_block) {
-			if (c->tail()->parent_block() == _block
-			    || c->head()->parent_block() == _block) {
-				to_remove.insert(c);
+			if (arc->tail()->parent_block() == _block
+			    || arc->head()->parent_block() == _block) {
+				to_remove.insert(arc);
 			}
 		} else if (_port) {
-			if (c->tail() == _port || c->head() == _port) {
-				to_remove.insert(c);
+			if (arc->tail() == _port || arc->head() == _port) {
+				to_remove.insert(arc);
 			}
 		}
 	}
 
 	// Create disconnect events (which erases from _parent->arcs())
-	for (std::set<ArcImpl*>::const_iterator i = to_remove.begin();
-	     i != to_remove.end(); ++i) {
+	for (const auto& a : to_remove) {
 		_impls.push_back(new Disconnect::Impl(
 			                 _engine, _parent,
-			                 dynamic_cast<OutputPort*>((*i)->tail()),
-			                 dynamic_cast<InputPort*>((*i)->head())));
+			                 dynamic_cast<OutputPort*>(a->tail()),
+			                 dynamic_cast<InputPort*>(a->head())));
 	}
 
 	if (!_deleting && _parent->enabled())
@@ -150,9 +148,9 @@ void
 DisconnectAll::execute(ProcessContext& context)
 {
 	if (_status == Status::SUCCESS) {
-		for (Impls::iterator i = _impls.begin(); i != _impls.end(); ++i) {
-			(*i)->execute(context,
-			              !_deleting || ((*i)->head()->parent_block() != _block));
+		for (auto& i : _impls) {
+			i->execute(context,
+			           !_deleting || (i->head()->parent_block() != _block));
 		}
 	}
 
diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp
index 67b68de9..f16654f7 100644
--- a/src/server/events/Get.cpp
+++ b/src/server/events/Get.cpp
@@ -111,9 +111,8 @@ send_graph(Interface* client, const GraphImpl* graph)
 	            Resource::Graph::EXTERNAL);
 
 	// Send blocks
-	for (GraphImpl::Blocks::const_iterator j = graph->blocks().begin();
-	     j != graph->blocks().end(); ++j) {
-		send_block(client, &*j);
+	for (const auto& b : graph->blocks()) {
+		send_block(client, &b);
 	}
 
 	// Send ports
@@ -122,9 +121,8 @@ send_graph(Interface* client, const GraphImpl* graph)
 	}
 
 	// Send arcs
-	for (GraphImpl::Arcs::const_iterator j = graph->arcs().begin();
-	     j != graph->arcs().end(); ++j) {
-		client->connect(j->second->tail_path(), j->second->head_path());
+	for (const auto& a : graph->arcs()) {
+		client->connect(a.second->tail_path(), a.second->head_path());
 	}
 }
 
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index f8f4b7c3..e866ea0e 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -183,8 +183,8 @@ public:
 		// Notify buffer is a Chunk with size set to the available space
 		_notify_capacity = ((LV2_Atom_Sequence*)_ports[1]->buffer())->atom.size;
 
-		for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
-			pre_process_port(_engine.process_context(), *i);
+		for (auto& p : _ports) {
+			pre_process_port(_engine.process_context(), p);
 		}
 
 		_engine.run(nframes);
@@ -194,8 +194,8 @@ public:
 
 		flush_to_ui(_engine.process_context());
 
-		for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
-			post_process_port(_engine.process_context(), *i);
+		for (auto& p : _ports) {
+			post_process_port(_engine.process_context(), p);
 		}
 
 		_frame_time += nframes;
@@ -210,9 +210,9 @@ public:
 	virtual GraphImpl* root_graph()                     { return _root_graph; }
 
 	virtual EnginePort* get_port(const Raul::Path& path) {
-		for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
-			if ((*i)->graph_port()->path() == path) {
-				return *i;
+		for (auto& p : _ports) {
+			if (p->graph_port()->path() == path) {
+				return p;
 			}
 		}
 
@@ -508,9 +508,9 @@ ingen_instantiate(const LV2_Descriptor*    descriptor,
 		Glib::filename_to_uri(Ingen::bundle_file_path("manifest.ttl")));
 
 	const LV2Graph* graph = NULL;
-	for (Lib::Graphs::iterator i = graphs.begin(); i != graphs.end(); ++i) {
-		if ((*i)->uri == descriptor->URI) {
-			graph = (*i).get();
+	for (const auto& g : graphs) {
+		if (g->uri == descriptor->URI) {
+			graph = g.get();
 			break;
 		}
 	}
-- 
cgit v1.2.1