void TfDiagnosticMgr::_SpliceErrors(ErrorList &src) { if (!HasActiveErrorMark()) { for (ErrorList::const_iterator i = src.begin(), end = src.end(); i != end; ++i) { _ReportError(*i); } } else { // Reassign new serial numbers to the errors. size_t serial = _nextSerial.fetch_and_add(src.size()); for (auto& error : src) { error._data->_serial = serial++; } // Now splice them into the main list. ErrorList &errorList = _errorList.local(); // We store the begin iterator from the new list. This iterator remains // valid *after the splice*, and iterates the spliced elements from src // in errorList. ErrorList::iterator newErrorsBegin = src.begin(); errorList.splice(errorList.end(), src); _AppendErrorsToLogText(newErrorsBegin); } }