+ int const c = (*i)->compare (section, with_bbt);
+
+ if (c < 0) {
+ /* this section is before the one to be added; go back round */
+ continue;
+ } else if (c > 0) {
+ /* this section is after the one to be added; there can't be any at the same time */
+ break;
+ }
+
+ /* hacky comparison of type */
+ bool const a = dynamic_cast<TempoSection*> (*i) != 0;
+ bool const b = dynamic_cast<TempoSection*> (section) != 0;
+
+ if (a == b) {
+ to_remove = i;
+ break;
+ }
+ }
+
+ if (to_remove != metrics->end()) {
+ /* remove the MetricSection at the same time as the one we are about to add */
+ metrics->erase (to_remove);
+ }
+
+ /* Add the given MetricSection */
+
+ for (i = metrics->begin(); i != metrics->end(); ++i) {
+
+ if ((*i)->compare (section, with_bbt) < 0) {
+ continue;