diff --git a/libs/ardour/analysis_graph.cc b/libs/ardour/analysis_graph.cc index c5c3a3c66a8..a3ce17d4177 100644 --- a/libs/ardour/analysis_graph.cc +++ b/libs/ardour/analysis_graph.cc @@ -131,7 +131,7 @@ AnalysisGraph::analyze_range (std::shared_ptr route, std::shared_ptr::const_iterator j = range.begin(); j != range.end(); ++j) { + for (const TimelineRange& j : range) { interleaver.reset (new Interleaver ()); interleaver->init (n_audio, _max_chunksize); @@ -139,14 +139,14 @@ AnalysisGraph::analyze_range (std::shared_ptr route, std::shared_ptr (n_samples)); analyser.reset (new Analyser ( _session->nominal_sample_rate(), - n_audio, n_samples, (*j).length_samples())); + n_audio, n_samples, j.length_samples())); interleaver->add_output(chunker); chunker->add_output (analyser); samplecnt_t x = 0; - const samplecnt_t rlen = j->length().samples(); - const samplepos_t rpos = j->start().samples(); + const samplecnt_t rlen = j.length().samples(); + const samplepos_t rpos = j.start().samples(); while (x < rlen) { samplecnt_t chunk = std::min (_max_chunksize, rlen - x); @@ -175,7 +175,7 @@ AnalysisGraph::analyze_range (std::shared_ptr route, std::shared_ptrnominal_sample_rate(), 100, false), Timecode::timecode_format_sampletime ( - (*j).end().samples(), + j.end().samples(), _session->nominal_sample_rate(), 100, false) ); diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc index 35e9386c5a9..49604039387 100644 --- a/libs/ardour/control_protocol_manager.cc +++ b/libs/ardour/control_protocol_manager.cc @@ -583,21 +583,20 @@ ControlProtocolManager::get_state () const XMLNode* root = new XMLNode (state_node_name); Glib::Threads::RWLock::ReaderLock lm (protocols_lock); - for (list::const_iterator i = control_protocol_info.begin(); i != control_protocol_info.end(); ++i) { - - if ((*i)->protocol) { - XMLNode& child_state ((*i)->protocol->get_state()); - child_state.set_property (X_("active"), !(*i)->automatic); - delete ((*i)->state); - (*i)->state = new XMLNode (child_state); + for (ControlProtocolInfo* const& i : control_protocol_info) { + if (i->protocol) { + XMLNode& child_state (i->protocol->get_state()); + child_state.set_property (X_("active"), !i->automatic); + delete (i->state); + i->state = new XMLNode (child_state); root->add_child_nocopy (child_state); - } else if ((*i)->state) { - XMLNode* child_state = new XMLNode (*(*i)->state); + } else if (i->state) { + XMLNode* child_state = new XMLNode (*i->state); child_state->set_property (X_("active"), false); root->add_child_nocopy (*child_state); } else { XMLNode* child_state = new XMLNode (X_("Protocol")); - child_state->set_property (X_("name"), (*i)->name); + child_state->set_property (X_("name"), i->name); child_state->set_property (X_("active"), false); root->add_child_nocopy (*child_state); } diff --git a/libs/ardour/export_graph_builder.cc b/libs/ardour/export_graph_builder.cc index 82706337b02..b38e1cabb23 100644 --- a/libs/ardour/export_graph_builder.cc +++ b/libs/ardour/export_graph_builder.cc @@ -221,8 +221,8 @@ unsigned ExportGraphBuilder::get_postprocessing_cycle_count() const { unsigned max = 0; - for (std::list::const_iterator it = intermediates.begin(); it != intermediates.end(); ++it) { - max = std::max(max, (*it)->get_postprocessing_cycle_count()); + for (Intermediate * const& it : intermediates) { + max = std::max(max, it->get_postprocessing_cycle_count()); } return max; } diff --git a/libs/ardour/export_profile_manager.cc b/libs/ardour/export_profile_manager.cc index c007be75bbb..b7b12dfda5d 100644 --- a/libs/ardour/export_profile_manager.cc +++ b/libs/ardour/export_profile_manager.cc @@ -1004,9 +1004,7 @@ ExportProfileManager::check_config (std::shared_ptr warnings, std::list paths; build_filenames (paths, filename, timespans, channel_config, format); - for (std::list::const_iterator path_it = paths.begin (); path_it != paths.end (); ++path_it) { - string path = *path_it; - + for (const string& path : paths) { if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) { warnings->conflicting_filenames.push_back (path); } diff --git a/libs/ardour/monitor_port.cc b/libs/ardour/monitor_port.cc index 6dd65881552..7caa4a2400f 100644 --- a/libs/ardour/monitor_port.cc +++ b/libs/ardour/monitor_port.cc @@ -236,22 +236,22 @@ MonitorPort::set_active_monitors (std::list const& pl) removals.push_back (i->first); } /* add ports */ - for (std::list::const_iterator i = pl.begin (); i != pl.end (); ++i) { - std::pair it = mp->insert (make_pair (*i, std::shared_ptr (new MonitorInfo ()))); + for (const std::string& i : pl) { + std::pair it = mp->insert (make_pair (i, std::shared_ptr (new MonitorInfo ()))); if (!it.second && !it.first->second->remove) { /* already present */ continue; } it.first->second->remove = false; - additions.push_back (*i); + additions.push_back (i); } } - for (std::list::const_iterator i = removals.begin (); i != removals.end (); ++i) { - MonitorInputChanged (*i, false); /* EMIT SIGNAL */ + for (const std::string& i : removals) { + MonitorInputChanged (i, false); /* EMIT SIGNAL */ } - for (std::list::const_iterator i = additions.begin (); i != additions.end (); ++i) { - MonitorInputChanged (*i, true); /* EMIT SIGNAL */ + for (const std::string& i : additions) { + MonitorInputChanged (i, true); /* EMIT SIGNAL */ } if (!removals.empty () || !additions.empty ()) { AudioEngine::instance()->session ()->SoloChanged (); /* EMIT SIGNAL */ diff --git a/libs/ardour/panner_manager.cc b/libs/ardour/panner_manager.cc index c93a48f53eb..6c9845cb6db 100644 --- a/libs/ardour/panner_manager.cc +++ b/libs/ardour/panner_manager.cc @@ -258,13 +258,11 @@ PannerManager::select_panner (ChanCount in, ChanCount out, std::string const uri PannerInfo* PannerManager::get_by_uri (std::string uri) const { - PannerInfo* pi = NULL; - for (list::const_iterator p = panner_info.begin(); p != panner_info.end(); ++p) { - if ((*p)->descriptor.panner_uri != uri) continue; - pi = (*p); - break; + for (PannerInfo* const& pi : panner_info) { + if (pi->descriptor.panner_uri != uri) continue; + return pi; } - return pi; + return nullptr; } PannerUriMap @@ -279,8 +277,8 @@ PannerManager::get_available_panners(uint32_t const a_in, uint32_t const a_out) } /* get available panners for current configuration. */ - for (list::const_iterator p = panner_info.begin(); p != panner_info.end(); ++p) { - PanPluginDescriptor const& d ((*p)->descriptor); + for (PannerInfo* const& p : panner_info) { + PanPluginDescriptor const& d (p->descriptor); if (d.in != -1 && d.in != in) continue; if (d.out != -1 && d.out != out) continue; if (d.in == -1 && d.out == -1 && out <= 2) continue; diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 51e2e943a72..891f1496824 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -1426,11 +1426,9 @@ Playlist::duplicate_ranges (std::list& ranges, float times) timepos_t min_pos = timepos_t::max (ranges.front().start().time_domain()); timepos_t max_pos = timepos_t (min_pos.time_domain()); - for (std::list::const_iterator i = ranges.begin(); - i != ranges.end(); - ++i) { - min_pos = min (min_pos, (*i).start()); - max_pos = max (max_pos, (*i).end()); + for (const TimelineRange& i : ranges) { + min_pos = min (min_pos, i.start()); + max_pos = max (max_pos, i.end()); } timecnt_t offset = min_pos.distance (max_pos); @@ -2403,9 +2401,8 @@ Playlist::state (bool full_state) const node->set_property (X_("pgroup-id"), _pgroup_id); string shared_ids; - list::const_iterator it = _shared_with_ids.begin (); - for (; it != _shared_with_ids.end (); ++it) { - shared_ids += "," + (*it).to_s (); + for (const PBD::ID& it : _shared_with_ids) { + shared_ids += "," + it.to_s (); } if (!shared_ids.empty ()) { shared_ids.erase (0, 1); diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 195bdf9c2af..529c79456b0 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -845,9 +845,8 @@ static void dump_processors(const string& name, const list >& procs) { cerr << name << " {" << endl; - for (list >::const_iterator p = procs.begin(); - p != procs.end(); ++p) { - cerr << "\t" << (*p)->name() << " ID = " << (*p)->id() << " @ " << (*p) << endl; + for (const std::shared_ptr & p : procs) { + cerr << "\t" << p->name() << " ID = " << p->id() << " @ " << p << endl; } cerr << "}" << endl; } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 0b19970717f..d33ac6de889 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -4725,16 +4725,16 @@ Session::set_session_range_is_free (bool yn) void Session::playlist_ranges_moved (list const & ranges) { - for (list::const_iterator i = ranges.begin(); i != ranges.end(); ++i) { - maybe_update_session_range (i->from, i->to); + for (const Temporal::RangeMove& i : ranges) { + maybe_update_session_range (i.from, i.to); } } void Session::playlist_regions_extended (list const & ranges) { - for (list::const_iterator i = ranges.begin(); i != ranges.end(); ++i) { - maybe_update_session_range (i->start(), i->end()); + for (const Temporal::Range& i : ranges) { + maybe_update_session_range (i.start(), i.end()); } } @@ -4769,8 +4769,8 @@ Session::destroy_sources (list > const& srcs) { set > relevant_regions; - for (list >::const_iterator s = srcs.begin(); s != srcs.end(); ++s) { - RegionFactory::get_regions_using_source (*s, relevant_regions); + for (const std::shared_ptr & s : srcs) { + RegionFactory::get_regions_using_source (s, relevant_regions); } for (set >::iterator r = relevant_regions.begin(); r != relevant_regions.end();) { @@ -4783,17 +4783,16 @@ Session::destroy_sources (list > const& srcs) r = relevant_regions.erase (r); } - for (list >::const_iterator s = srcs.begin(); s != srcs.end(); ++s) { - + for (const std::shared_ptr & s : srcs) { { Glib::Threads::Mutex::Lock ls (source_lock); /* remove from the main source list */ - sources.erase ((*s)->id()); + sources.erase (s->id()); } - (*s)->mark_for_remove (); - (*s)->drop_references (); - SourceRemoved (std::weak_ptr (*s)); /* EMIT SIGNAL */ + s->mark_for_remove (); + s->drop_references (); + SourceRemoved (std::weak_ptr (s)); /* EMIT SIGNAL */ } return 0; diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 48b93eb782a..919efcc029d 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1297,8 +1297,8 @@ Session::state (bool save_template, snapshot_t snapshot_type, bool for_archive, list midi_port_nodes = _midi_ports->get_midi_port_states(); if (!midi_port_nodes.empty()) { XMLNode* midi_port_stuff = new XMLNode ("MIDIPorts"); - for (list::const_iterator n = midi_port_nodes.begin(); n != midi_port_nodes.end(); ++n) { - midi_port_stuff->add_child_nocopy (**n); + for (XMLNode* const& n : midi_port_nodes) { + midi_port_stuff->add_child_nocopy (*n); } node->add_child_nocopy (*midi_port_stuff); } @@ -1535,8 +1535,8 @@ Session::state (bool save_template, snapshot_t snapshot_type, bool for_archive, _playlists->add_state (node, save_template, !only_used_assets); child = node->add_child ("RouteGroups"); - for (list::const_iterator i = _route_groups.begin(); i != _route_groups.end(); ++i) { - child->add_child_nocopy ((*i)->get_state()); + for (RouteGroup * const& i : _route_groups) { + child->add_child_nocopy (i->get_state()); } if (_click_io) { @@ -3261,19 +3261,14 @@ Session::possible_states () const RouteGroup* Session::new_route_group (const std::string& name) { - RouteGroup* rg = NULL; - - for (std::list::const_iterator i = _route_groups.begin (); i != _route_groups.end (); ++i) { - if ((*i)->name () == name) { - rg = *i; - break; + for (RouteGroup* const& rg : _route_groups) { + if (rg->name () == name) { + return rg; } } - if (!rg) { - rg = new RouteGroup (*this, name); - add_route_group (rg); - } + RouteGroup* rg = new RouteGroup (*this, name); + add_route_group (rg); return (rg); } diff --git a/libs/ardour/transform.cc b/libs/ardour/transform.cc index 4a89afcb158..7f7ff1e1761 100644 --- a/libs/ardour/transform.cc +++ b/libs/ardour/transform.cc @@ -137,10 +137,8 @@ Transform::operator()(std::shared_ptr model, // Clear stack and run program ctx.stack = std::stack(); ctx.this_note = note; - for (std::list::const_iterator o = _prog.ops.begin(); - o != _prog.ops.end(); - ++o) { - (*o).eval(ctx); + for (const Operation& o : _prog.ops) { + o.eval(ctx); } // Result is on top of the stack diff --git a/libs/canvas/benchmark/render_from_log.cc b/libs/canvas/benchmark/render_from_log.cc index 0a2af8b7bcb..dedd1ddb851 100644 --- a/libs/canvas/benchmark/render_from_log.cc +++ b/libs/canvas/benchmark/render_from_log.cc @@ -28,8 +28,8 @@ class RenderFromLog : public Benchmark list const & renders = canvas.renders (); - for (list::const_iterator i = renders.begin(); i != renders.end(); ++i) { - canvas.render_to_image (*i); + for (const Rect& i : renders) { + canvas.render_to_image (i); } } diff --git a/libs/canvas/box.cc b/libs/canvas/box.cc index 7060b9bb7c1..558fae760af 100644 --- a/libs/canvas/box.cc +++ b/libs/canvas/box.cc @@ -177,9 +177,9 @@ Box::size_request (Distance& w, Distance& h) const DEBUG_TRACE (DEBUG::CanvasBox|DEBUG::CanvasSizeAllocate, string_compose ("size request for %1\n", this)); if (homogenous) { - for (std::list::const_iterator i = _items.begin(); i != _items.end(); ++i) { + for (Item* const& i : _items) { Distance iw, ih; - (*i)->size_request (iw, ih); + i->size_request (iw, ih); largest_height = std::max (largest_height, ih); largest_width = std::max (largest_width, iw); diff --git a/libs/canvas/canvas.cc b/libs/canvas/canvas.cc index 884c753826f..479f90b97db 100644 --- a/libs/canvas/canvas.cc +++ b/libs/canvas/canvas.cc @@ -362,10 +362,10 @@ Canvas::window_to_canvas (Duple const & d) const in_window.y = 0; } - for (list::const_iterator s = scrollers.begin(); s != scrollers.end(); ++s) { + for (ScrollGroup* const& s : scrollers) { - if ((*s)->covers_window (in_window)) { - sg = *s; + if (s->covers_window (in_window)) { + sg = s; /* XXX January 22nd 2015: leaving this in place for now * but I think it fixes a bug that really should be @@ -408,8 +408,8 @@ Canvas::canvas_to_window (Duple const & d, bool rounded) const ScrollGroup* sg = 0; Duple wd; - for (std::list::const_iterator i = root_children.begin(); i != root_children.end(); ++i) { - if (((sg = dynamic_cast(*i)) != 0) && sg->covers_canvas (d)) { + for (Item* const& i : root_children) { + if (((sg = dynamic_cast(i)) != 0) && sg->covers_canvas (d)) { break; } } diff --git a/libs/gtkmm2ext/bindings.cc b/libs/gtkmm2ext/bindings.cc index a1ce6b9fa55..210d8d4e971 100644 --- a/libs/gtkmm2ext/bindings.cc +++ b/libs/gtkmm2ext/bindings.cc @@ -790,15 +790,15 @@ Bindings::save_all_bindings_as_html (ostream& ostr) /* first column: separate by group */ ostr << "\n\n"; - for (list::const_iterator b = bindings.begin(); b != bindings.end(); ++b) { - (*b)->save_as_html (ostr, true); + for (Bindings* const& b : bindings) { + b->save_as_html (ostr, true); } ostr << "\n\n"; //second column ostr << "\n\n"; - for (list::const_iterator b = bindings.begin(); b != bindings.end(); ++b) { - (*b)->save_as_html (ostr, false); + for (Bindings* const& b : bindings) { + b->save_as_html (ostr, false); } ostr << "\n\n"; diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc index 2459fa32aed..212a54edcc2 100644 --- a/libs/gtkmm2ext/gtk_ui.cc +++ b/libs/gtkmm2ext/gtk_ui.cc @@ -536,12 +536,12 @@ UI::dump_errors (std::ostream& ostr, size_t limit) } if (first) { - for (list::const_iterator i = error_stack.begin(); i != error_stack.end(); ++i) { + for (const string& i : error_stack) { if (first) { ostr << endl << X_("Log Messages:") << endl; first = false; } - ostr << *i << endl; + ostr << i << endl; if (limit > 0) { if (--limit == 0) { ostr << "..." << endl; diff --git a/libs/gtkmm2ext/gtkmm2ext/dndtreeview.h b/libs/gtkmm2ext/gtkmm2ext/dndtreeview.h index e7a5cbf7621..50088fe1455 100644 --- a/libs/gtkmm2ext/gtkmm2ext/dndtreeview.h +++ b/libs/gtkmm2ext/gtkmm2ext/dndtreeview.h @@ -163,8 +163,8 @@ class /*LIBGTKMM2EXT_API*/ DnDTreeView : public DnDTreeViewBase } else { /* some kind of target type, usually 'object_type' added by the app, * which will be handled by a signal handler */ - for (std::list::const_iterator i = draggable.begin(); i != draggable.end (); ++i) { - if (selection_data.get_target() == (*i).get_target()) { + for (const Gtk::TargetEntry& i : draggable) { + if (selection_data.get_target() == i.get_target()) { signal_drop (context, selection_data); context->drag_finish (true, false, time); break; diff --git a/libs/gtkmm2ext/gtkmm2ext/dndvbox.h b/libs/gtkmm2ext/gtkmm2ext/dndvbox.h index 9a2f9afdc36..e41a3b67129 100644 --- a/libs/gtkmm2ext/gtkmm2ext/dndvbox.h +++ b/libs/gtkmm2ext/gtkmm2ext/dndvbox.h @@ -140,9 +140,9 @@ class /*LIBGTKMM2EXT_API*/ DnDVBox : public Gtk::EventBox } else { /* simple insertion-sort */ std::list rv; - for (typename std::list::const_iterator i = _children.begin(); i != _children.end(); ++i) { - if (selected (*i)) { - rv.push_back (*i); + for (T* const& i : _children) { + if (selected (i)) { + rv.push_back (i); } } return rv; @@ -556,23 +556,22 @@ class /*LIBGTKMM2EXT_API*/ DnDVBox : public Gtk::EventBox bool selecting = false; bool done = false; - for (typename std::list::const_iterator i = _children.begin(); i != _children.end(); ++i) { - - bool const was_selected = selected (*i); + for (T* const& i : _children) { + bool const was_selected = selected (i); if (selecting && !was_selected) { - add_to_selection (*i); + add_to_selection (i); } if (!selecting && !done) { - if (selected (*i)) { + if (selected (i)) { selecting = true; - } else if (*i == child) { + } else if (i == child) { selecting = true; add_to_selection (child); } } else if (selecting) { - if (was_selected || *i == child) { + if (was_selected || i == child) { selecting = false; done = true; } @@ -659,16 +658,11 @@ class /*LIBGTKMM2EXT_API*/ DnDVBox : public Gtk::EventBox T* child_from_widget (Gtk::Widget const * w) const { - typename std::list::const_iterator i = _children.begin(); - while (i != _children.end() && &(*i)->widget() != w) { - ++i; - } - - if (i == _children.end()) { - return 0; + for (T* const& i : _children) { + if (&i->widget() == w) return i; } - return *i; + return 0; } Gtk::VBox _internal_vbox; diff --git a/libs/gtkmm2ext/keyboard.cc b/libs/gtkmm2ext/keyboard.cc index 5345124c4a1..1d0b7ed54cd 100644 --- a/libs/gtkmm2ext/keyboard.cc +++ b/libs/gtkmm2ext/keyboard.cc @@ -825,10 +825,10 @@ Keyboard::store_keybindings (string const& path) DEBUG_TRACE (DEBUG::Bindings, string_compose ("save bindings to %1\n", path)); - for (list::const_iterator b = Bindings::bindings.begin (); b != Bindings::bindings.end (); ++b) { + for (Bindings* const& b : Bindings::bindings) { bnode = new XMLNode (X_("Bindings")); - bnode->set_property (X_("name"), (*b)->name ()); - (*b)->save (*bnode); + bnode->set_property (X_("name"), b->name ()); + b->save (*bnode); node->add_child_nocopy (*bnode); } diff --git a/libs/midi++2/test/MidnamTest.cpp b/libs/midi++2/test/MidnamTest.cpp index 840bc02c7bf..b77bbbe360d 100644 --- a/libs/midi++2/test/MidnamTest.cpp +++ b/libs/midi++2/test/MidnamTest.cpp @@ -134,11 +134,11 @@ MidnamTest::yamaha_PSRS900_patchfile_test() modename = modes.back(); CPPUNIT_ASSERT_EQUAL(string("GM2"), modename); - for (list::const_iterator modename = modes.begin(); modename != modes.end(); ++modename) { + for (const string& modename : modes) { std::shared_ptr mode = - masterDeviceNames->custom_device_mode_by_name(*modename); + masterDeviceNames->custom_device_mode_by_name(modename); - CPPUNIT_ASSERT_EQUAL(*modename, mode->name()); + CPPUNIT_ASSERT_EQUAL(modename, mode->name()); string ns = mode->name(); diff --git a/libs/pbd/undo.cc b/libs/pbd/undo.cc index 7b3fc301866..eb47778aa98 100644 --- a/libs/pbd/undo.cc +++ b/libs/pbd/undo.cc @@ -149,9 +149,8 @@ UndoTransaction::get_state () const node->set_property ("tv-usec", (int64_t)_timestamp.tv_usec); node->set_property ("name", _name); - list::const_iterator it; - for (it = actions.begin (); it != actions.end (); it++) { - node->add_child_nocopy ((*it)->get_state ()); + for (Command* const& it : actions) { + node->add_child_nocopy (it->get_state ()); } return *node;