From 8358f2a56575c7d194d77a6085349d41be990182 Mon Sep 17 00:00:00 2001 From: Edward Brown <edward.brown@stfc.ac.uk> Date: Fri, 23 Mar 2018 08:56:03 +0000 Subject: [PATCH] Re #22183: Applied fixes to Framework/ --- Framework/API/test/ExperimentInfoTest.h | 5 +- Framework/API/test/GroupingLoaderTest.h | 6 +- .../API/test/MatrixWorkspaceMDIteratorTest.h | 4 +- Framework/Algorithms/src/ConjoinXRuns.cpp | 4 +- .../Algorithms/src/DiffractionFocussing.cpp | 6 +- Framework/Algorithms/src/GetEiMonDet2.cpp | 3 +- .../src/MagFormFactorCorrection.cpp | 4 +- Framework/Algorithms/src/RingProfile.cpp | 4 +- .../SampleCorrections/SparseInstrument.cpp | 4 +- .../Algorithms/test/ChangeTimeZeroTest.h | 14 ++-- .../test/DetectorEfficiencyVariationTest.h | 4 +- Framework/Algorithms/test/FilterEventsTest.h | 49 ++++++----- .../Algorithms/test/GroupWorkspacesTest.h | 10 +-- .../Algorithms/test/MaskBinsFromTableTest.h | 4 +- .../Algorithms/test/MedianDetectorTestTest.h | 4 +- .../test/PDDetermineCharacterizationsTest.h | 4 +- .../Algorithms/test/RebinByTimeAtSampleTest.h | 3 +- Framework/Algorithms/test/RebinTest.h | 10 +-- .../Algorithms/test/RemoveBackgroundTest.h | 4 +- Framework/Algorithms/test/SassenaFFTTest.h | 10 +-- Framework/Algorithms/test/Stitch1DTest.h | 12 +-- .../Algorithms/test/UnGroupWorkspaceTest.h | 10 +-- Framework/Crystal/src/LoadIsawPeaks.cpp | 4 +- Framework/Crystal/src/SCDCalibratePanels.cpp | 12 +-- .../test/ConnectedComponentLabelingTest.h | 5 +- Framework/Crystal/test/PredictPeaksTest.h | 4 +- .../src/Algorithms/EstimateFitParameters.cpp | 4 +- .../FuncMinimizers/TrustRegionMinimizer.cpp | 7 +- .../test/Algorithms/LeBailFunctionTest.h | 10 +-- .../test/Algorithms/PlotPeakByLogValueTest.h | 4 +- .../RefinePowderInstrumentParametersTest.h | 12 +-- .../test/Functions/ChebfunBaseTest.h | 13 ++- .../test/Functions/ProcessBackgroundTest.h | 4 +- .../test/Functions/SimpleChebfunTest.h | 4 +- .../IPeakFunctionCentreParameterNameTest.h | 7 +- .../test/IPeakFunctionIntensityTest.h | 19 ++--- Framework/DataHandling/src/LoadMask.cpp | 14 ++-- .../DataHandling/src/LoadSpiceXML2DDet.cpp | 21 ++--- .../DataHandling/src/ParallelEventLoader.cpp | 4 +- Framework/DataHandling/src/SaveAscii2.cpp | 4 +- Framework/DataHandling/src/SaveGSS.cpp | 5 +- .../DataHandling/test/FindDetectorsParTest.h | 16 ++-- Framework/DataHandling/test/LoadCalFileTest.h | 4 +- .../DataHandling/test/LoadDetectorInfoTest.h | 4 +- .../DataHandling/test/LoadEventNexusTest.h | 6 +- .../test/LoadEventPreNexus2Test.h | 4 +- Framework/DataHandling/test/LoadMaskTest.h | 8 +- .../DataHandling/test/LoadNexusMonitorsTest.h | 8 +- Framework/DataHandling/test/LoadTest.h | 8 +- Framework/DataHandling/test/SaveAscii2Test.h | 24 +++--- Framework/DataHandling/test/SavePHXTest.h | 4 +- Framework/DataObjects/src/PeaksWorkspace.cpp | 4 +- Framework/DataObjects/src/Workspace2D.cpp | 8 +- Framework/DataObjects/test/EventListTest.h | 20 ++--- .../DataObjects/test/MDBoxFlatTreeTest.h | 4 +- .../DataObjects/test/MDBoxSaveableTest.h | 3 +- Framework/DataObjects/test/MDBoxTest.h | 12 +-- Framework/DataObjects/test/MDGridBoxTest.h | 83 +++++++++---------- .../test/MDHistoWorkspaceIteratorTest.h | 30 +++---- Framework/DataObjects/test/PeakTest.h | 3 +- .../src/Rendering/vtkGeometryCacheReader.cpp | 8 +- Framework/Geometry/test/CSGObjectTest.h | 8 +- Framework/Geometry/test/CenteringGroupTest.h | 7 +- .../test/CompositeBraggScattererTest.h | 4 +- .../Geometry/test/GroupTransformationTest.h | 4 +- Framework/Geometry/test/IndexingUtilsTest.h | 20 ++--- Framework/Geometry/test/PointGroupTest.h | 12 +-- .../Geometry/test/ReflectionConditionTest.h | 8 +- Framework/Geometry/test/SpaceGroupTest.h | 8 +- .../test/SymmetryOperationFactoryTest.h | 8 +- Framework/Kernel/test/ConfigServiceTest.h | 6 +- .../Kernel/test/DiskBufferISaveableTest.h | 40 ++++----- Framework/Kernel/test/DiskBufferTest.h | 30 +++---- Framework/Kernel/test/FileDescriptorTest.h | 8 +- Framework/Kernel/test/GlobTest.h | 10 +-- Framework/Kernel/test/InterpolationTest.h | 6 +- Framework/Kernel/test/MutexTest.h | 7 +- .../test/NDPseudoRandomNumberGeneratorTest.h | 4 +- Framework/Kernel/test/NexusDescriptorTest.h | 8 +- Framework/Kernel/test/PropertyManagerTest.h | 6 +- Framework/Kernel/test/PropertyWithValueTest.h | 4 +- Framework/Kernel/test/SobolSequenceTest.h | 4 +- Framework/Kernel/test/ThreadSchedulerTest.h | 4 +- Framework/Kernel/test/UsageServiceTest.h | 10 +-- .../private/Schema/flatbuffers/flatbuffers.h | 6 +- Framework/LiveData/test/LoadLiveDataTest.h | 8 +- Framework/MDAlgorithms/test/LoadMDTest.h | 4 +- .../MDAlgorithms/test/MDTransfModQTest.h | 4 +- Framework/MDAlgorithms/test/MDTransfQ3DTest.h | 4 +- .../MDAlgorithms/test/MergeMDFilesTest.h | 8 +- Framework/MDAlgorithms/test/ReplicateMDTest.h | 4 +- .../MDAlgorithms/test/TobyFitYVectorTest.h | 4 +- Framework/MDAlgorithms/test/TransformMDTest.h | 3 +- .../dataobjects/src/Exports/Workspace2D.cpp | 7 +- .../test/AbortRemoteJob2Test.h | 6 +- .../test/AbortRemoteJobTest.h | 6 +- .../RemoteAlgorithms/test/Authenticate2Test.h | 6 +- .../RemoteAlgorithms/test/AuthenticateTest.h | 6 +- .../test/DownloadRemoteFile2Test.h | 6 +- .../test/DownloadRemoteFileTest.h | 6 +- Framework/RemoteAlgorithms/test/Logout2Test.h | 6 +- .../test/QueryAllRemoteJobs2Test.h | 6 +- .../test/QueryAllRemoteJobsTest.h | 6 +- .../test/QueryRemoteFile2Test.h | 6 +- .../test/QueryRemoteFileTest.h | 6 +- .../test/QueryRemoteJob2Test.h | 6 +- .../test/QueryRemoteJobTest.h | 6 +- .../test/StartRemoteTransaction2Test.h | 6 +- .../test/StartRemoteTransactionTest.h | 6 +- .../test/StopRemoteTransaction2Test.h | 6 +- .../test/StopRemoteTransactionTest.h | 6 +- .../test/SubmitRemoteJob2Test.h | 6 +- .../test/SubmitRemoteJobTest.h | 6 +- .../test/UploadRemoteFile2Test.h | 6 +- .../test/UploadRemoteFileTest.h | 6 +- Framework/SINQ/test/PoldiFitPeaks1D2Test.h | 4 +- Framework/SINQ/test/PoldiFitPeaks1DTest.h | 4 +- .../SINQ/test/PoldiIndexKnownCompoundsTest.h | 8 +- Framework/SINQ/test/PoldiPeakSearchTest.h | 5 +- .../test/ScriptRepositoryTestImpl.h | 9 +- 120 files changed, 493 insertions(+), 537 deletions(-) diff --git a/Framework/API/test/ExperimentInfoTest.h b/Framework/API/test/ExperimentInfoTest.h index 8941eb1eb70..8af5b7e90a4 100644 --- a/Framework/API/test/ExperimentInfoTest.h +++ b/Framework/API/test/ExperimentInfoTest.h @@ -526,9 +526,8 @@ public: std::pair<std::unordered_multimap<std::string, fromToEntry>::iterator, std::unordered_multimap<std::string, fromToEntry>::iterator> ret; - for (auto setIt = idfIdentifiers.begin(); setIt != idfIdentifiers.end(); - setIt++) { - ret = idfFiles.equal_range(*setIt); + for (const auto & idfIdentifier : idfIdentifiers) { + ret = idfFiles.equal_range(idfIdentifier); for (it1 = ret.first; it1 != ret.second; ++it1) { for (it2 = ret.first; it2 != ret.second; ++it2) { if (it1 != it2) { diff --git a/Framework/API/test/GroupingLoaderTest.h b/Framework/API/test/GroupingLoaderTest.h index c6aa0e50d51..9d610c10fa3 100644 --- a/Framework/API/test/GroupingLoaderTest.h +++ b/Framework/API/test/GroupingLoaderTest.h @@ -25,11 +25,11 @@ public: auto dataPaths = ConfigService::Instance().getDataSearchDirs(); // Find the path of AutoTestData - for (auto it = dataPaths.begin(); it != dataPaths.end(); ++it) { - Poco::Path path(*it); + for (auto & dataPath : dataPaths) { + Poco::Path path(dataPath); if (path.directory(path.depth() - 1) == "UnitTest") { - m_testDataDir = *it; + m_testDataDir = dataPath; break; } } diff --git a/Framework/API/test/MatrixWorkspaceMDIteratorTest.h b/Framework/API/test/MatrixWorkspaceMDIteratorTest.h index 5d1f3979ffd..ffa3afcb5c6 100644 --- a/Framework/API/test/MatrixWorkspaceMDIteratorTest.h +++ b/Framework/API/test/MatrixWorkspaceMDIteratorTest.h @@ -92,8 +92,8 @@ public: // The number of output cannot be larger than the number of histograms std::vector<IMDIterator *> it = ws->createIterators(10, NULL); TS_ASSERT_EQUALS(it.size(), 4); - for (size_t i = 0; i < it.size(); ++i) - delete it[i]; + for (auto & i : it) + delete i; // Split in 4 iterators std::vector<IMDIterator *> iterators = ws->createIterators(4, NULL); diff --git a/Framework/Algorithms/src/ConjoinXRuns.cpp b/Framework/Algorithms/src/ConjoinXRuns.cpp index a19028d9bc8..9a92ef65657 100644 --- a/Framework/Algorithms/src/ConjoinXRuns.cpp +++ b/Framework/Algorithms/src/ConjoinXRuns.cpp @@ -254,8 +254,8 @@ void ConjoinXRuns::fillHistory() { if (!isChild()) { // Loop over the input workspaces, making the call that copies their // history to the output one - for (auto inWS = m_inputWS.begin(); inWS != m_inputWS.end(); ++inWS) { - m_outWS->history().addHistory((*inWS)->getHistory()); + for (auto & inWS : m_inputWS) { + m_outWS->history().addHistory(inWS->getHistory()); } // Add the history for the current algorithm to the output m_outWS->history().addHistory(m_history); diff --git a/Framework/Algorithms/src/DiffractionFocussing.cpp b/Framework/Algorithms/src/DiffractionFocussing.cpp index b4cac6232c9..8716e88b605 100644 --- a/Framework/Algorithms/src/DiffractionFocussing.cpp +++ b/Framework/Algorithms/src/DiffractionFocussing.cpp @@ -83,12 +83,12 @@ void DiffractionFocussing::exec() { if (iprogress_step == 0) iprogress_step = 1; std::vector<int64_t> resultIndeces; - for (auto g = groupNumbers.cbegin(); g != groupNumbers.end(); ++g) { + for (long groupNumber : groupNumbers) { if (iprogress++ % iprogress_step == 0) { progress(0.68 + double(iprogress) / iprogress_count / 3); } - auto from = detectorGroups.lower_bound(*g); - auto to = detectorGroups.upper_bound(*g); + auto from = detectorGroups.lower_bound(groupNumber); + auto to = detectorGroups.upper_bound(groupNumber); std::vector<detid_t> detectorList; for (auto d = from; d != to; ++d) detectorList.push_back(static_cast<detid_t>(d->second)); diff --git a/Framework/Algorithms/src/GetEiMonDet2.cpp b/Framework/Algorithms/src/GetEiMonDet2.cpp index 2039e3ac573..c66710b1bd4 100644 --- a/Framework/Algorithms/src/GetEiMonDet2.cpp +++ b/Framework/Algorithms/src/GetEiMonDet2.cpp @@ -213,9 +213,8 @@ void GetEiMonDet2::averageDetectorDistanceAndTOF( // cppcheck-suppress syntaxError PRAGMA_OMP(parallel for if ( m_detectorEPPTable->threadSafe()) reduction(+: n, distanceSum, eppSum)) - for (int i = 0; i < static_cast<int>(detectorIndices.size()); ++i) { + for (unsigned long index : detectorIndices) { PARALLEL_START_INTERUPT_REGION - const size_t index = detectorIndices[i]; interruption_point(); if (index >= peakPositionColumn->size()) { throw std::runtime_error("Invalid value in " + PropertyNames::DETECTORS); diff --git a/Framework/Algorithms/src/MagFormFactorCorrection.cpp b/Framework/Algorithms/src/MagFormFactorCorrection.cpp index ed5942f1207..cacd1d509d9 100644 --- a/Framework/Algorithms/src/MagFormFactorCorrection.cpp +++ b/Framework/Algorithms/src/MagFormFactorCorrection.cpp @@ -84,8 +84,8 @@ void MagFormFactorCorrection::exec() { // Gets the vector of form factor values std::vector<double> FF; FF.reserve(Qvals.size()); - for (int64_t iQ = 0; iQ < (int64_t)Qvals.size(); iQ++) { - FF.push_back(ion.analyticalFormFactor(Qvals[iQ] * Qvals[iQ])); + for (double Qval : Qvals) { + FF.push_back(ion.analyticalFormFactor(Qval * Qval)); } if (!ffwsStr.empty()) { MatrixWorkspace_sptr ffws = API::WorkspaceFactory::Instance().create( diff --git a/Framework/Algorithms/src/RingProfile.cpp b/Framework/Algorithms/src/RingProfile.cpp index b54b772a09f..8ffb30a6e90 100644 --- a/Framework/Algorithms/src/RingProfile.cpp +++ b/Framework/Algorithms/src/RingProfile.cpp @@ -418,8 +418,8 @@ void RingProfile::processInstrumentRingProfile( const MantidVec &refY = inputWS->getSpectrum(i).dataY(); // accumulate the values of this spectrum inside this bin - for (size_t sp_ind = 0; sp_ind < refY.size(); sp_ind++) - output_bins[bin_n] += refY[sp_ind]; + for (double sp_ind : refY) + output_bins[bin_n] += sp_ind; } } diff --git a/Framework/Algorithms/src/SampleCorrections/SparseInstrument.cpp b/Framework/Algorithms/src/SampleCorrections/SparseInstrument.cpp index 281a0c31ce8..6c2580cd1e8 100644 --- a/Framework/Algorithms/src/SampleCorrections/SparseInstrument.cpp +++ b/Framework/Algorithms/src/SampleCorrections/SparseInstrument.cpp @@ -286,8 +286,8 @@ createSparseWS(const API::MatrixWorkspace &modelWS, } const auto e = modelWS.getEFixed(detIDs[0]); const auto &sparseDetIDs = ws->detectorInfo().detectorIDs(); - for (size_t i = 0; i < sparseDetIDs.size(); ++i) { - ws->setEFixed(sparseDetIDs[i], e); + for (int sparseDetID : sparseDetIDs) { + ws->setEFixed(sparseDetID, e); } } return API::MatrixWorkspace_uptr(ws.release()); diff --git a/Framework/Algorithms/test/ChangeTimeZeroTest.h b/Framework/Algorithms/test/ChangeTimeZeroTest.h index 88520874edf..38975edc701 100644 --- a/Framework/Algorithms/test/ChangeTimeZeroTest.h +++ b/Framework/Algorithms/test/ChangeTimeZeroTest.h @@ -487,11 +487,11 @@ private: auto logs = ws->run().getLogData(); // Go over each log and check the times - for (auto iter = logs.begin(); iter != logs.end(); ++iter) { - if (dynamic_cast<Mantid::Kernel::ITimeSeriesProperty *>(*iter)) { - do_check_time_series(*iter, timeShift); - } else if (dynamic_cast<PropertyWithValue<std::string> *>(*iter)) { - do_check_property_with_string_value(*iter, timeShift); + for (auto & log : logs) { + if (dynamic_cast<Mantid::Kernel::ITimeSeriesProperty *>(log)) { + do_check_time_series(log, timeShift); + } else if (dynamic_cast<PropertyWithValue<std::string> *>(log)) { + do_check_property_with_string_value(log, timeShift); } } @@ -509,8 +509,8 @@ private: // Iterator over all entries of the time series and check if they are // altered double secondCounter = timeShift; - for (auto it = times.begin(); it != times.end(); ++it) { - double secs = DateAndTime::secondsFromDuration(*it - m_startTime); + for (auto & time : times) { + double secs = DateAndTime::secondsFromDuration(time - m_startTime); TSM_ASSERT_DELTA("Time series logs should have shifted times.", secs, secondCounter, 1e-5); ++secondCounter; diff --git a/Framework/Algorithms/test/DetectorEfficiencyVariationTest.h b/Framework/Algorithms/test/DetectorEfficiencyVariationTest.h index f91e385f02b..ebce68af25c 100644 --- a/Framework/Algorithms/test/DetectorEfficiencyVariationTest.h +++ b/Framework/Algorithms/test/DetectorEfficiencyVariationTest.h @@ -130,8 +130,8 @@ public: inputB->setBinEdges(j, x); std::vector<double> forInputA, forInputB; // the spectravalues will be multiples of the random numbers above - for (int l = 0; l < ySize; ++l) { - forInputA.push_back(yArray[l]); + for (double l : yArray) { + forInputA.push_back(l); // there is going to be a small difference between the workspaces that // will vary with histogram number forInputB.push_back(forInputA.back() * diff --git a/Framework/Algorithms/test/FilterEventsTest.h b/Framework/Algorithms/test/FilterEventsTest.h index 7cbc4ae3ecc..28a78ced563 100644 --- a/Framework/Algorithms/test/FilterEventsTest.h +++ b/Framework/Algorithms/test/FilterEventsTest.h @@ -254,8 +254,8 @@ public: AnalysisDataService::Instance().remove("Splitter02"); std::vector<std::string> outputwsnames = filter.getProperty("OutputWorkspaceNames"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { - AnalysisDataService::Instance().remove(outputwsnames[i]); + for (const auto & outputwsname : outputwsnames) { + AnalysisDataService::Instance().remove(outputwsname); } return; @@ -350,9 +350,9 @@ public: AnalysisDataService::Instance().remove("Splitter02"); std::vector<std::string> outputwsnames = filter.getProperty("OutputWorkspaceNames"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { - std::cout << "Delete output workspace name: " << outputwsnames[i] << "\n"; - AnalysisDataService::Instance().remove(outputwsnames[i]); + for (const auto & outputwsname : outputwsnames) { + std::cout << "Delete output workspace name: " << outputwsname << "\n"; + AnalysisDataService::Instance().remove(outputwsname); } return; @@ -435,8 +435,8 @@ public: std::vector<std::string> outputwsnames = filter.getProperty("OutputWorkspaceNames"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { - AnalysisDataService::Instance().remove(outputwsnames[i]); + for (const auto & outputwsname : outputwsnames) { + AnalysisDataService::Instance().remove(outputwsname); } return; @@ -493,8 +493,8 @@ public: // Delete all the workspaces generated here AnalysisDataService::Instance().remove("MockDirectEventWS"); AnalysisDataService::Instance().remove("SplitterTableX"); - for (size_t i = 0; i < vecwsname.size(); ++i) { - AnalysisDataService::Instance().remove(vecwsname[i]); + for (const auto & i : vecwsname) { + AnalysisDataService::Instance().remove(i); } return; @@ -544,8 +544,8 @@ public: AnalysisDataService::Instance().remove("SplitterTableX"); std::vector<std::string> outputwsnames = filter.getProperty("OutputWorkspaceNames"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { - AnalysisDataService::Instance().remove(outputwsnames[i]); + for (const auto & outputwsname : outputwsnames) { + AnalysisDataService::Instance().remove(outputwsname); } return; @@ -608,8 +608,8 @@ public: AnalysisDataService::Instance().remove("MockIndirectEventWS"); std::vector<std::string> outputwsnames = filter.getProperty("OutputWorkspaceNames"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { - AnalysisDataService::Instance().remove(outputwsnames[i]); + for (const auto & outputwsname : outputwsnames) { + AnalysisDataService::Instance().remove(outputwsname); } return; @@ -781,10 +781,10 @@ public: // Test the sample logs std::vector<std::string> outputwsnames = filter.getProperty("OutputWorkspaceNames"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { + for (const auto & outputwsname : outputwsnames) { EventWorkspace_sptr filtered_ws = boost::dynamic_pointer_cast<DataObjects::EventWorkspace>( - AnalysisDataService::Instance().retrieve(outputwsnames[i])); + AnalysisDataService::Instance().retrieve(outputwsname)); TS_ASSERT(filtered_ws->run().hasProperty("LogA")); TS_ASSERT(filtered_ws->run().hasProperty("LogB")); @@ -805,8 +805,8 @@ public: // clean up all the workspaces generated AnalysisDataService::Instance().remove("Test10"); AnalysisDataService::Instance().remove("Splitter10"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { - AnalysisDataService::Instance().remove(outputwsnames[i]); + for (const auto & outputwsname : outputwsnames) { + AnalysisDataService::Instance().remove(outputwsname); } return; @@ -977,8 +977,8 @@ public: AnalysisDataService::Instance().remove("TableSplitter1"); std::vector<std::string> outputwsnames = filter.getProperty("OutputWorkspaceNames"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { - AnalysisDataService::Instance().remove(outputwsnames[i]); + for (const auto & outputwsname : outputwsnames) { + AnalysisDataService::Instance().remove(outputwsname); } return; @@ -1033,10 +1033,10 @@ public: std::vector<std::string> outputwsnames = filter.getProperty("OutputWorkspaceNames"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { + for (const auto & outputwsname : outputwsnames) { EventWorkspace_sptr childworkspace = boost::dynamic_pointer_cast<EventWorkspace>( - AnalysisDataService::Instance().retrieve(outputwsnames[i])); + AnalysisDataService::Instance().retrieve(outputwsname)); TS_ASSERT(childworkspace); // there is 1 sample logs that is excluded from propagating to the child // workspaces. LogB is not TSP, so it won't be excluded even if it is @@ -1051,8 +1051,8 @@ public: // clean workspaces AnalysisDataService::Instance().remove("Test12"); AnalysisDataService::Instance().remove("TableSplitter2"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { - AnalysisDataService::Instance().remove(outputwsnames[i]); + for (const auto & outputwsname : outputwsnames) { + AnalysisDataService::Instance().remove(outputwsname); } return; @@ -1587,8 +1587,7 @@ public: // 2. Add rows const auto &detectorInfo = inpws->detectorInfo(); const auto detids = detectorInfo.detectorIDs(); - for (size_t i = 0; i < detids.size(); ++i) { - int detid = detids[i]; + for (int detid : detids) { double factor = 0.75; TableRow newrow = corrtable->appendRow(); newrow << detid << factor; diff --git a/Framework/Algorithms/test/GroupWorkspacesTest.h b/Framework/Algorithms/test/GroupWorkspacesTest.h index 0b9fa7e31c0..b9f4c2abec1 100644 --- a/Framework/Algorithms/test/GroupWorkspacesTest.h +++ b/Framework/Algorithms/test/GroupWorkspacesTest.h @@ -196,8 +196,8 @@ public: private: void addTestMatrixWorkspacesToADS(const std::vector<std::string> &inputs) { - for (auto it = inputs.begin(); it != inputs.end(); ++it) { - addTestMatrixWorkspaceToADS(*it); + for (const auto & input : inputs) { + addTestMatrixWorkspaceToADS(input); } } @@ -258,9 +258,9 @@ private: const std::vector<std::string> &members) { auto &ads = Mantid::API::AnalysisDataService::Instance(); - for (auto it = members.begin(); it != members.end(); ++it) { - if (ads.doesExist(*it)) - ads.remove(*it); + for (const auto & member : members) { + if (ads.doesExist(member)) + ads.remove(member); } if (ads.doesExist(groupName)) ads.remove(groupName); diff --git a/Framework/Algorithms/test/MaskBinsFromTableTest.h b/Framework/Algorithms/test/MaskBinsFromTableTest.h index 4bf775b5486..6d894d28648 100644 --- a/Framework/Algorithms/test/MaskBinsFromTableTest.h +++ b/Framework/Algorithms/test/MaskBinsFromTableTest.h @@ -183,8 +183,8 @@ public: speclist.push_back(6); speclist.push_back(7); speclist.push_back(8); - for (size_t iws = 0; iws < speclist.size(); ++iws) { - auto &yvec = WS->y(speclist[iws]); + for (int iws : speclist) { + auto &yvec = WS->y(iws); for (size_t bin = 0; bin < yvec.size(); ++bin) { if (bin >= 4 && bin < 7) { TS_ASSERT_EQUALS(yvec[bin], 0.0); diff --git a/Framework/Algorithms/test/MedianDetectorTestTest.h b/Framework/Algorithms/test/MedianDetectorTestTest.h index cfccc53ddd1..81be253a63a 100644 --- a/Framework/Algorithms/test/MedianDetectorTestTest.h +++ b/Framework/Algorithms/test/MedianDetectorTestTest.h @@ -180,8 +180,8 @@ public: 1, 0, 15, 4, 0, 0.001, 2e-10, 0, 8, 0, 1e-4, 1, 7, 11}; m_YSum = 0; - for (int i = 0; i < specLength - 1; i++) { - m_YSum += yArray[i]; + for (double i : yArray) { + m_YSum += i; } // most error values will be small so that they wont affect the tests diff --git a/Framework/Algorithms/test/PDDetermineCharacterizationsTest.h b/Framework/Algorithms/test/PDDetermineCharacterizationsTest.h index 95d3c084391..4da29ea57d1 100644 --- a/Framework/Algorithms/test/PDDetermineCharacterizationsTest.h +++ b/Framework/Algorithms/test/PDDetermineCharacterizationsTest.h @@ -213,8 +213,8 @@ public: const std::vector<Property *> &expectedProps = expected->getProperties(); - for (std::size_t i = 0; i < expectedProps.size(); ++i) { - const std::string name = expectedProps[i]->name(); + for (auto expectedProp : expectedProps) { + const std::string name = expectedProp->name(); TS_ASSERT_EQUALS(expected->getPropertyValue(name), observed->getPropertyValue(name)); } diff --git a/Framework/Algorithms/test/RebinByTimeAtSampleTest.h b/Framework/Algorithms/test/RebinByTimeAtSampleTest.h index aaf90573ec8..481148a9648 100644 --- a/Framework/Algorithms/test/RebinByTimeAtSampleTest.h +++ b/Framework/Algorithms/test/RebinByTimeAtSampleTest.h @@ -31,8 +31,7 @@ createSinglePulseEventWorkspace(const V3D &sourcePosition, // Make fake events for (size_t pix = 0; pix < numberspectra; pix++) { - for (size_t i = 0; i < allSpectraTOF.size(); i++) { - const double tof = allSpectraTOF[i]; + for (double tof : allSpectraTOF) { uint64_t pulseTime(0); // Pulse time is always zero. Same pulse. retVal->getSpectrum(pix) += TofEvent(tof, pulseTime); } diff --git a/Framework/Algorithms/test/RebinTest.h b/Framework/Algorithms/test/RebinTest.h index 00ea719f481..17cb8232c61 100644 --- a/Framework/Algorithms/test/RebinTest.h +++ b/Framework/Algorithms/test/RebinTest.h @@ -424,9 +424,8 @@ public: // turn the mask list into an array like the Y values MantidVec weights(outY.size(), 0); - for (MatrixWorkspace::MaskList::const_iterator it = mask.begin(); - it != mask.end(); ++it) { - weights[it->first] = it->second; + for (auto it : mask) { + weights[it.first] = it.second; } // the degree of masking must be the same as the reduction in the y-value, @@ -484,9 +483,8 @@ public: // turn the mask list into an array like the Y values MantidVec weights(outY.size(), 0); - for (MatrixWorkspace::MaskList::const_iterator it = mask.begin(); - it != mask.end(); ++it) { - weights[it->first] = it->second; + for (auto it : mask) { + weights[it.first] = it.second; } // the degree of masking must be the same as the reduction in the y-value, diff --git a/Framework/Algorithms/test/RemoveBackgroundTest.h b/Framework/Algorithms/test/RemoveBackgroundTest.h index c01c9209a07..93cea273688 100644 --- a/Framework/Algorithms/test/RemoveBackgroundTest.h +++ b/Framework/Algorithms/test/RemoveBackgroundTest.h @@ -195,8 +195,8 @@ public: auto clone = cloneSourceWS(); // set negative values to signal auto &Y = clone->dataY(0); - for (size_t i = 0; i < Y.size(); i++) { - Y[i] = -1000; + for (double & i : Y) { + i = -1000; } // Create zero background workspace // Create the workspace diff --git a/Framework/Algorithms/test/SassenaFFTTest.h b/Framework/Algorithms/test/SassenaFFTTest.h index 4c15d0aa2fc..5f5f5c4032b 100644 --- a/Framework/Algorithms/test/SassenaFFTTest.h +++ b/Framework/Algorithms/test/SassenaFFTTest.h @@ -144,10 +144,10 @@ private: double sum = 0.0; double average = 0.0; MantidVec::iterator itx = xv.begin(); - for (MantidVec::iterator it = yv.begin(); it != yv.end(); ++it) { + for (double & it : yv) { factor = exp(exponentFactor * (*itx)); - sum += (*it) * factor; - average += (*it) * (*itx) * factor; + sum += it * factor; + average += it * (*itx) * factor; ++itx; } average /= sum; @@ -186,9 +186,9 @@ private: xv = ws->readX(i); MantidVec::iterator itx = xv.begin(); double sum = 0.0; - for (MantidVec::iterator it = yv.begin(); it != yv.end(); ++it) { + for (double & it : yv) { factor = exp(exponentFactor * (*itx)); - sum += (*it) * factor; + sum += it * factor; ++itx; } sum *= dx / static_cast<double>(nbins); diff --git a/Framework/Algorithms/test/Stitch1DTest.h b/Framework/Algorithms/test/Stitch1DTest.h index 1e787942a34..fab1d86938b 100644 --- a/Framework/Algorithms/test/Stitch1DTest.h +++ b/Framework/Algorithms/test/Stitch1DTest.h @@ -384,8 +384,7 @@ public: } // Check that the output E-Values are correct. Output Error values should // all be zero - for (auto itr = stitched_e.begin(); itr != stitched_e.end(); ++itr) { - double temp = *itr; + for (double temp : stitched_e) { TS_ASSERT_EQUALS(temp, 0); } // Check that the output X-Values are correct. @@ -416,8 +415,7 @@ public: } // Check that the output E-Values are correct. Output Error values should // all be zero - for (auto itr = stitched_e.begin(); itr != stitched_e.end(); ++itr) { - double temp = *itr; + for (double temp : stitched_e) { TS_ASSERT_EQUALS(temp, 0); } // Check that the output X-Values are correct. @@ -449,8 +447,7 @@ public: } // Check that the output E-Values are correct. Output Error values should // all be zero - for (auto itr = stitched_e.begin(); itr != stitched_e.end(); ++itr) { - double temp = *itr; + for (double temp : stitched_e) { TS_ASSERT_EQUALS(temp, 0); } // Check that the output X-Values are correct. @@ -482,8 +479,7 @@ public: } // Check that the output E-Values are correct. Output Error values should // all be zero - for (auto itr = stitched_e.begin(); itr != stitched_e.end(); ++itr) { - double temp = *itr; + for (double temp : stitched_e) { TS_ASSERT_EQUALS(temp, 0); } // Check that the output X-Values are correct. diff --git a/Framework/Algorithms/test/UnGroupWorkspaceTest.h b/Framework/Algorithms/test/UnGroupWorkspaceTest.h index 70a5ea9404c..75515d1f21c 100644 --- a/Framework/Algorithms/test/UnGroupWorkspaceTest.h +++ b/Framework/Algorithms/test/UnGroupWorkspaceTest.h @@ -102,8 +102,8 @@ private: auto newGroup = boost::make_shared<Mantid::API::WorkspaceGroup>(); auto &ads = Mantid::API::AnalysisDataService::Instance(); - for (auto it = inputs.begin(); it != inputs.end(); ++it) { - auto ws = addTestMatrixWorkspaceToADS(*it); + for (const auto & input : inputs) { + auto ws = addTestMatrixWorkspaceToADS(input); newGroup->addWorkspace(ws); } ads.add(name, newGroup); @@ -120,9 +120,9 @@ private: void removeFromADS(const std::vector<std::string> &members) { auto &ads = Mantid::API::AnalysisDataService::Instance(); - for (auto it = members.begin(); it != members.end(); ++it) { - if (ads.doesExist(*it)) - ads.remove(*it); + for (const auto & member : members) { + if (ads.doesExist(member)) + ads.remove(member); } } }; diff --git a/Framework/Crystal/src/LoadIsawPeaks.cpp b/Framework/Crystal/src/LoadIsawPeaks.cpp index 194e3125fea..70993a16c5d 100644 --- a/Framework/Crystal/src/LoadIsawPeaks.cpp +++ b/Framework/Crystal/src/LoadIsawPeaks.cpp @@ -213,8 +213,8 @@ std::string LoadIsawPeaks::readHeader(PeaksWorkspace_sptr outWS, boost::erase_all(bankName, bankPart); int bank = 0; Strings::convert(bankName, bank); - for (size_t j = 0; j < det.size(); j++) { - if (bank == det[j]) { + for (int j : det) { + if (bank == j) { bank = 0; continue; } diff --git a/Framework/Crystal/src/SCDCalibratePanels.cpp b/Framework/Crystal/src/SCDCalibratePanels.cpp index 7ec8c15ed7b..3753d39bc10 100644 --- a/Framework/Crystal/src/SCDCalibratePanels.cpp +++ b/Framework/Crystal/src/SCDCalibratePanels.cpp @@ -102,9 +102,9 @@ void SCDCalibratePanels::exec() { std::vector<std::string> parameter_workspaces( MyBankNames.size() + MyPanels.size(), "params_"); int i = 0; - for (auto iBank = MyPanels.begin(); iBank != MyPanels.end(); ++iBank) { - fit_workspaces[i] += *iBank; - parameter_workspaces[i] += *iBank; + for (auto & MyPanel : MyPanels) { + fit_workspaces[i] += MyPanel; + parameter_workspaces[i] += MyPanel; i++; } if (snapPanels) { @@ -122,9 +122,9 @@ void SCDCalibratePanels::exec() { << " degrees\n"; } - for (auto iBank = MyBankNames.begin(); iBank != MyBankNames.end(); ++iBank) { - fit_workspaces[i] += *iBank; - parameter_workspaces[i] += *iBank; + for (auto & MyBankName : MyBankNames) { + fit_workspaces[i] += MyBankName; + parameter_workspaces[i] += MyBankName; i++; } if (bankPanels) { diff --git a/Framework/Crystal/test/ConnectedComponentLabelingTest.h b/Framework/Crystal/test/ConnectedComponentLabelingTest.h index 81beb4d05b4..8e976b9f2be 100644 --- a/Framework/Crystal/test/ConnectedComponentLabelingTest.h +++ b/Framework/Crystal/test/ConnectedComponentLabelingTest.h @@ -410,9 +410,8 @@ public: clusterThreeIndexes.end()); // Add elevated signal to the workspace at cluster indexes. - for (auto it = allClusterIndexes.begin(); it != allClusterIndexes.end(); - ++it) { - inWS->setSignalAt(*it, raisedSignal); + for (unsigned long & allClusterIndexe : allClusterIndexes) { + inWS->setSignalAt(allClusterIndexe, raisedSignal); } // ---------- Run the cluster finding diff --git a/Framework/Crystal/test/PredictPeaksTest.h b/Framework/Crystal/test/PredictPeaksTest.h index ef297ab7108..4e36e48f695 100644 --- a/Framework/Crystal/test/PredictPeaksTest.h +++ b/Framework/Crystal/test/PredictPeaksTest.h @@ -37,9 +37,9 @@ public: PeaksWorkspace_sptr hklPW; if (hkls.size() > 0) { hklPW = PeaksWorkspace_sptr(new PeaksWorkspace()); - for (size_t i = 0; i < hkls.size(); i++) { + for (const auto & hkl : hkls) { Peak p(inst, detid, 1.0); - p.setHKL(hkls[i]); + p.setHKL(hkl); hklPW->addPeak(p); } } diff --git a/Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp b/Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp index 2485a0cc188..e94f12b4927 100644 --- a/Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp +++ b/Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp @@ -430,8 +430,8 @@ void EstimateFitParameters::execConcrete() { if (m_function->isActive(i)) { TableRow row = table->appendRow(); row << m_function->parameterName(i); - for (size_t j = 0; j < output.size(); ++j) { - row << output[j][ia]; + for (auto & j : output) { + row << j[ia]; } ++ia; } diff --git a/Framework/CurveFitting/src/FuncMinimizers/TrustRegionMinimizer.cpp b/Framework/CurveFitting/src/FuncMinimizers/TrustRegionMinimizer.cpp index 2b4c732e712..9386efa3c2d 100644 --- a/Framework/CurveFitting/src/FuncMinimizers/TrustRegionMinimizer.cpp +++ b/Framework/CurveFitting/src/FuncMinimizers/TrustRegionMinimizer.cpp @@ -1274,10 +1274,9 @@ void solveSubproblem(int n, double radius, double f, inform.obj *= pow(scale_c, 2) / scale_h; inform.multiplier *= scale_h; inform.pole *= scale_h; - for (size_t i = 0; i < inform.history.size(); - ++i) { // do i = 1, inform.len_history - inform.history[i].lambda *= scale_h; - inform.history[i].x_norm *= scale_c / scale_h; + for (auto & i : inform.history) { // do i = 1, inform.len_history + i.lambda *= scale_h; + i.x_norm *= scale_c / scale_h; } } diff --git a/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h b/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h index 0f761eab369..d072227eb6c 100644 --- a/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h +++ b/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h @@ -515,10 +515,10 @@ public: 1.950190, 1.613562, 1.335208, 1.104734, 0.914043, 0.756362, 0.000000}; - for (size_t i = 0; i < vecY.size(); ++i) { + for (double i : vecY) { double e = 1.0; - if (vecY[i] > 1.0) - e = sqrt(vecY[i]); + if (i > 1.0) + e = sqrt(i); vecE.push_back(e); } @@ -687,8 +687,8 @@ public: vecy.push_back(0.03096179); vece.push_back(0.00105191); - for (size_t i = 0; i < vecy.size(); ++i) - vecy[i] -= 0.02295189; + for (double & i : vecy) + i -= 0.02295189; return; } diff --git a/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h b/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h index 557a80dc32e..8ba433096f7 100644 --- a/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h +++ b/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h @@ -496,10 +496,10 @@ public: TS_ASSERT(fits->getNames().size() == 2); auto wsNames = fits->getNames(); - for (size_t i = 0; i < wsNames.size(); ++i) { + for (const auto & wsName : wsNames) { auto fit = AnalysisDataService::Instance().retrieveWS<const MatrixWorkspace>( - wsNames[i]); + wsName); TS_ASSERT(fit); TS_ASSERT(fit->getNumberHistograms() == 5); } diff --git a/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h b/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h index 233c1a20055..b6b7d4a40fe 100644 --- a/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h +++ b/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h @@ -308,9 +308,9 @@ public: hkl << hkls[ipk][i]; cout << hkls[ipk][i] << ", "; } - for (size_t ipm = 0; ipm < peakparams[ipk].size(); ++ipm) { - hkl << peakparams[ipk][ipm]; - cout << peakparams[ipk][ipm]; + for (double ipm : peakparams[ipk]) { + hkl << ipm; + cout << ipm; } cout << '\n'; } @@ -416,10 +416,10 @@ public: // 2. Add peak parameters' name and values map<string, vector<double>>::iterator finditer; - for (size_t ipn = 0; ipn < paramnames.size(); ++ipn) { + for (const auto & paramname : paramnames) { API::TableRow newrow = geomws->appendRow(); - std::string parname = paramnames[ipn]; - double parvalue = parameters[paramnames[ipn]]; + std::string parname = paramname; + double parvalue = parameters[paramname]; newrow << parname << parvalue; double parmin = -DBL_MAX; double parmax = DBL_MAX; diff --git a/Framework/CurveFitting/test/Functions/ChebfunBaseTest.h b/Framework/CurveFitting/test/Functions/ChebfunBaseTest.h index 23331503944..db19d23152d 100644 --- a/Framework/CurveFitting/test/Functions/ChebfunBaseTest.h +++ b/Framework/CurveFitting/test/Functions/ChebfunBaseTest.h @@ -115,8 +115,7 @@ private: ChebfunBase base(n, start, end); auto p = base.fit(fun); auto x = base.linspace(2 * n); - for (size_t i = 0; i < x.size(); ++i) { - double xi = x[i]; + for (double xi : x) { TS_ASSERT_DELTA(base.eval(xi, p), fun(xi), 1e-4); } } @@ -148,8 +147,7 @@ private: std::vector<double> p, a; auto base = ChebfunBase::bestFit(start, end, fun, p, a); auto x = base->linspace(2 * base->size()); - for (size_t i = 0; i < x.size(); ++i) { - double xi = x[i]; + for (double xi : x) { TS_ASSERT_DELTA(base->eval(xi, p), fun(xi), 1e-14); } TS_ASSERT_EQUALS(base->size(), expected_n); @@ -169,8 +167,7 @@ private: base->derivative(a, da); dp = base->calcP(da); auto x = base->linspace(2 * base->size()); - for (size_t i = 0; i < x.size(); ++i) { - double xi = x[i]; + for (double xi : x) { // std::cerr << xi << ' ' << base->eval(xi,dp) - Cos(xi) << '\n'; TS_ASSERT_DELTA(base->eval(xi, dp), deriv(xi), 1e-13); } @@ -182,8 +179,8 @@ private: auto base = ChebfunBase::bestFit(start, end, fun, p, a); auto roots = base->roots(a); TS_ASSERT_EQUALS(n_roots, roots.size()); - for (size_t i = 0; i < roots.size(); ++i) { - TS_ASSERT_DELTA(base->eval(roots[i], p), 0.0, tol); + for (double root : roots) { + TS_ASSERT_DELTA(base->eval(root, p), 0.0, tol); } } }; diff --git a/Framework/CurveFitting/test/Functions/ProcessBackgroundTest.h b/Framework/CurveFitting/test/Functions/ProcessBackgroundTest.h index acd2ddcd4f0..c1dfa668cb2 100644 --- a/Framework/CurveFitting/test/Functions/ProcessBackgroundTest.h +++ b/Framework/CurveFitting/test/Functions/ProcessBackgroundTest.h @@ -446,8 +446,8 @@ public: MersenneTwister mt(1234, 0.0, 1000000.0); std::vector<double> bkgdpts(10000); - for (auto it = bkgdpts.begin(); it != bkgdpts.end(); it++) { - *it = mt.nextValue(); + for (double & bkgdpt : bkgdpts) { + bkgdpt = mt.nextValue(); } sbg.initialize(); diff --git a/Framework/CurveFitting/test/Functions/SimpleChebfunTest.h b/Framework/CurveFitting/test/Functions/SimpleChebfunTest.h index f3b4482f107..f2ee2336d68 100644 --- a/Framework/CurveFitting/test/Functions/SimpleChebfunTest.h +++ b/Framework/CurveFitting/test/Functions/SimpleChebfunTest.h @@ -159,9 +159,9 @@ private: } } auto &xp = cheb.xPoints(); - for (size_t i = 0; i < xp.size(); ++i) { + for (double i : xp) { // std::cerr << xp[i] << ' ' << cheb(xp[i]) - fun(xp[i]) << '\n'; - TS_ASSERT_DELTA(cheb(xp[i]), fun(xp[i]), accur2); + TS_ASSERT_DELTA(cheb(i), fun(i), accur2); } } }; diff --git a/Framework/CurveFitting/test/IPeakFunctionCentreParameterNameTest.h b/Framework/CurveFitting/test/IPeakFunctionCentreParameterNameTest.h index 2d19fed5347..50958494a89 100644 --- a/Framework/CurveFitting/test/IPeakFunctionCentreParameterNameTest.h +++ b/Framework/CurveFitting/test/IPeakFunctionCentreParameterNameTest.h @@ -33,10 +33,9 @@ public: /* Test that all functions give the expected result. */ void testAllFunctions() { - for (auto it = m_expectedResults.begin(); it != m_expectedResults.end(); - ++it) { - const std::string &peakFunctionName = it->first; - const std::string ¢reParameterName = it->second; + for (auto & m_expectedResult : m_expectedResults) { + const std::string &peakFunctionName = m_expectedResult.first; + const std::string ¢reParameterName = m_expectedResult.second; IPeakFunction_sptr fn = boost::dynamic_pointer_cast<IPeakFunction>( FunctionFactory::Instance().createFunction(peakFunctionName)); diff --git a/Framework/CurveFitting/test/IPeakFunctionIntensityTest.h b/Framework/CurveFitting/test/IPeakFunctionIntensityTest.h index cec758e09c5..e2483577cd3 100644 --- a/Framework/CurveFitting/test/IPeakFunctionIntensityTest.h +++ b/Framework/CurveFitting/test/IPeakFunctionIntensityTest.h @@ -91,12 +91,11 @@ private: std::vector<std::string> registeredFunctions = FunctionFactory::Instance().getFunctionNames<IPeakFunction>(); - for (auto it = registeredFunctions.begin(); it != registeredFunctions.end(); - ++it) { - if (blackList.count(*it) == 0) { + for (auto & registeredFunction : registeredFunctions) { + if (blackList.count(registeredFunction) == 0) { IPeakFunction_sptr peakFunction = boost::dynamic_pointer_cast<IPeakFunction>( - FunctionFactory::Instance().createFunction(*it)); + FunctionFactory::Instance().createFunction(registeredFunction)); if (peakFunction) { peakFunctions.push_back(peakFunction); @@ -110,16 +109,16 @@ private: void initializePeakFunctions(const std::vector<IPeakFunction_sptr> &peaks, const ParameterSet ¶meters) const { - for (auto it = peaks.begin(); it != peaks.end(); ++it) { - (*it)->setCentre(parameters.center); + for (const auto & peak : peaks) { + peak->setCentre(parameters.center); // for Ikeda-Carpenter it's not allowed to set Fwhm try { - (*it)->setFwhm(parameters.fwhm); + peak->setFwhm(parameters.fwhm); } catch (std::invalid_argument) { } - (*it)->setHeight(parameters.height); + peak->setHeight(parameters.height); } } @@ -137,8 +136,8 @@ private: getIntensities(const std::vector<IPeakFunction_sptr> &peaks) const { std::vector<double> intensities; - for (auto it = peaks.begin(); it != peaks.end(); ++it) { - intensities.push_back((*it)->intensity()); + for (const auto & peak : peaks) { + intensities.push_back(peak->intensity()); } return intensities; diff --git a/Framework/DataHandling/src/LoadMask.cpp b/Framework/DataHandling/src/LoadMask.cpp index ebf95f91f86..633cbbbca75 100644 --- a/Framework/DataHandling/src/LoadMask.cpp +++ b/Framework/DataHandling/src/LoadMask.cpp @@ -531,9 +531,7 @@ void LoadMask::processMaskOnWorkspaceIndex(bool mask, // 3. Set mask auto spec0 = maskedSpecID[0]; auto prev_masks = spec0; - for (size_t i = 0; i < maskedSpecID.size(); i++) { - - auto spec2mask = maskedSpecID[i]; + for (int spec2mask : maskedSpecID) { s2iter = s2imap.find(spec2mask); if (s2iter == s2imap.end()) { @@ -703,18 +701,18 @@ void LoadMask::convertSpMasksToDetIDs(const API::MatrixWorkspace &sourceWS, sourceWS.getDetectorIDToWorkspaceIndexMap(false); std::multimap<size_t, Mantid::detid_t> spectr2index_map; - for (auto it = sourceDetMap.begin(); it != sourceDetMap.end(); it++) { + for (auto & it : sourceDetMap) { spectr2index_map.insert( - std::pair<size_t, Mantid::detid_t>(it->second, it->first)); + std::pair<size_t, Mantid::detid_t>(it.second, it.first)); } spec2index_map new_map; - for (size_t i = 0; i < maskedSpecID.size(); i++) { + for (int i : maskedSpecID) { // find spectra number from spectra ID for the source workspace - const auto itSpec = s2imap.find(maskedSpecID[i]); + const auto itSpec = s2imap.find(i); if (itSpec == s2imap.end()) { throw std::runtime_error( "Can not find spectra with ID: " + - boost::lexical_cast<std::string>(maskedSpecID[i]) + + boost::lexical_cast<std::string>(i) + " in the workspace" + sourceWS.getName()); } size_t specN = itSpec->second; diff --git a/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp b/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp index 725bcfd9be1..b672bc6e373 100644 --- a/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp +++ b/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp @@ -669,20 +669,17 @@ MatrixWorkspace_sptr LoadSpiceXML2DDet::createMatrixWorkspaceVersion2( } // END-FOR (xml nodes) // Add the property to output workspace - for (std::map<std::string, std::string>::iterator miter = str_log_map.begin(); - miter != str_log_map.end(); ++miter) { + for (auto & miter : str_log_map) { outws->mutableRun().addProperty( - new PropertyWithValue<std::string>(miter->first, miter->second)); + new PropertyWithValue<std::string>(miter.first, miter.second)); } - for (std::map<std::string, int>::iterator miter = int_log_map.begin(); - miter != int_log_map.end(); ++miter) { + for (auto & miter : int_log_map) { outws->mutableRun().addProperty( - new PropertyWithValue<int>(miter->first, miter->second)); + new PropertyWithValue<int>(miter.first, miter.second)); } - for (std::map<std::string, double>::iterator miter = dbl_log_map.begin(); - miter != dbl_log_map.end(); ++miter) { + for (auto & miter : dbl_log_map) { outws->mutableRun().addProperty( - new PropertyWithValue<double>(miter->first, miter->second)); + new PropertyWithValue<double>(miter.first, miter.second)); } // Raise exception if no detector node is found @@ -713,10 +710,10 @@ LoadSpiceXML2DDet::parseDetectorNode(const std::string &detvaluestr, // file records data in column major) size_t num_empty_line = 0; size_t num_weird_line = 0; - for (size_t iline = 0; iline < vecLines.size(); ++iline) { - if (vecLines[iline].empty()) + for (auto & vecLine : vecLines) { + if (vecLine.empty()) ++num_empty_line; - else if (vecLines[iline].size() < 100) + else if (vecLine.size() < 100) ++num_weird_line; } size_t num_pixel_x = vecLines.size() - num_empty_line - num_weird_line; diff --git a/Framework/DataHandling/src/ParallelEventLoader.cpp b/Framework/DataHandling/src/ParallelEventLoader.cpp index 90a7522fa79..d8c240ba489 100644 --- a/Framework/DataHandling/src/ParallelEventLoader.cpp +++ b/Framework/DataHandling/src/ParallelEventLoader.cpp @@ -59,11 +59,11 @@ std::vector<int32_t> bankOffsetsSpectrumNumbers( const auto &specNums = ws.indexInfo().spectrumNumbers(); int32_t spectrumIndex{0}; // *global* index std::vector<int32_t> bankOffsets(bankNames.size(), 0); - for (size_t i = 0; i < specNums.size(); ++i) { + for (auto i : specNums) { // In contrast to the case of event ID = detector ID we know that any // spectrum number has a corresponding event ID, i.e., we do not need // special handling for monitors. - specnum_t specNum = static_cast<specnum_t>(specNums[i]); + specnum_t specNum = static_cast<specnum_t>(i); // See comment in bankOffsets regarding this offset computation. if (idToBank.count(specNum) == 1) { size_t bank = idToBank.at(specNum); diff --git a/Framework/DataHandling/src/SaveAscii2.cpp b/Framework/DataHandling/src/SaveAscii2.cpp index f254010925e..b8199fa5104 100644 --- a/Framework/DataHandling/src/SaveAscii2.cpp +++ b/Framework/DataHandling/src/SaveAscii2.cpp @@ -268,8 +268,8 @@ void SaveAscii2::exec() { } } else { Progress progress(this, 0.0, 1.0, idx.size()); - for (auto i = idx.begin(); i != idx.end(); ++i) { - writeSpectrum(*i, file); + for (int i : idx) { + writeSpectrum(i, file); progress.report(); } } diff --git a/Framework/DataHandling/src/SaveGSS.cpp b/Framework/DataHandling/src/SaveGSS.cpp index d9873b66173..1c5d47665fb 100644 --- a/Framework/DataHandling/src/SaveGSS.cpp +++ b/Framework/DataHandling/src/SaveGSS.cpp @@ -442,9 +442,8 @@ void SaveGSS::generateInstrumentHeader(std::stringstream &out, // write user header first if (m_user_specified_gsas_header.size() > 0) { - for (auto iter = m_user_specified_gsas_header.begin(); - iter != m_user_specified_gsas_header.end(); ++iter) { - out << *iter << "\n"; + for (const auto & iter : m_user_specified_gsas_header) { + out << iter << "\n"; } } diff --git a/Framework/DataHandling/test/FindDetectorsParTest.h b/Framework/DataHandling/test/FindDetectorsParTest.h index a55f1b77af5..8bf40a8bbc5 100644 --- a/Framework/DataHandling/test/FindDetectorsParTest.h +++ b/Framework/DataHandling/test/FindDetectorsParTest.h @@ -490,8 +490,8 @@ private: cont[2] = " 2. 3. -4. 5. 6. 2"; std::ofstream testFile(fileName); - for (size_t i = 0; i < cont.size(); i++) { - testFile << cont[i] << '\n'; + for (const auto & i : cont) { + testFile << i << '\n'; } testFile.close(); } @@ -503,8 +503,8 @@ private: cont[3] = "3. 4. -5. 6. 7. 3"; std::ofstream testFile(fileName); - for (size_t i = 0; i < cont.size(); i++) { - testFile << cont[i] << '\n'; + for (const auto & i : cont) { + testFile << i << '\n'; } testFile.close(); } @@ -516,8 +516,8 @@ private: cont[3] = "10 0 5.000 6.000 7.000 8.0000 3"; std::ofstream testFile(fileName); - for (size_t i = 0; i < cont.size(); i++) { - testFile << cont[i] << '\n'; + for (const auto & i : cont) { + testFile << i << '\n'; } testFile.close(); } @@ -527,8 +527,8 @@ private: cont[1] = "10 0 5.000 6.000 7.000 8.0000 1"; std::ofstream testFile(fileName); - for (size_t i = 0; i < cont.size(); i++) { - testFile << cont[i] << '\n'; + for (const auto & i : cont) { + testFile << i << '\n'; } testFile.close(); } diff --git a/Framework/DataHandling/test/LoadCalFileTest.h b/Framework/DataHandling/test/LoadCalFileTest.h index 2dfcf9897d6..3b0d6c53981 100644 --- a/Framework/DataHandling/test/LoadCalFileTest.h +++ b/Framework/DataHandling/test/LoadCalFileTest.h @@ -125,8 +125,8 @@ public: } void tearDown() override { - for (size_t i = 0; i < loadAlgPtrArray.size(); i++) { - delete loadAlgPtrArray[i]; + for (auto & i : loadAlgPtrArray) { + delete i; } loadAlgPtrArray.clear(); diff --git a/Framework/DataHandling/test/LoadDetectorInfoTest.h b/Framework/DataHandling/test/LoadDetectorInfoTest.h index d7fe7bcb642..cb1efcc3d79 100644 --- a/Framework/DataHandling/test/LoadDetectorInfoTest.h +++ b/Framework/DataHandling/test/LoadDetectorInfoTest.h @@ -301,8 +301,8 @@ public: // read the parameters from some random detectors, they're parameters are // all set to the same thing - for (int i = 0; i < NUMRANDOM; ++i) { - const size_t detIndex = detInfo.indexOf(DETECTS[i]); + for (int i : DETECTS) { + const size_t detIndex = detInfo.indexOf(i); const auto &det = detInfo.detector(detIndex); Parameter_sptr par = pmap.getRecursive(&det, "TubePressure"); diff --git a/Framework/DataHandling/test/LoadEventNexusTest.h b/Framework/DataHandling/test/LoadEventNexusTest.h index 5dc3e8407b3..5c1864b6538 100644 --- a/Framework/DataHandling/test/LoadEventNexusTest.h +++ b/Framework/DataHandling/test/LoadEventNexusTest.h @@ -295,9 +295,9 @@ public: double max = events.begin()->tof(); double min = events.begin()->tof(); - for (size_t j = 0; j < events.size(); ++j) { - max = events[j].tof() > max ? events[j].tof() : max; - min = events[j].tof() < min ? events[j].tof() : min; + for (auto & event : events) { + max = event.tof() > max ? event.tof() : max; + min = event.tof() < min ? event.tof() : min; } TSM_ASSERT("The max TOF in the workspace should be equal to or less than " "the filtered cut-off", diff --git a/Framework/DataHandling/test/LoadEventPreNexus2Test.h b/Framework/DataHandling/test/LoadEventPreNexus2Test.h index 35bb8cd208d..60ae2b3d852 100644 --- a/Framework/DataHandling/test/LoadEventPreNexus2Test.h +++ b/Framework/DataHandling/test/LoadEventPreNexus2Test.h @@ -135,8 +135,8 @@ public: Types::Core::DateAndTime start = it->first; std::vector<TofEvent> events1 = ew->getSpectrum(1000).getEvents(); - for (size_t i = 0; i < events1.size(); i++) { - std::cout << (events1[i].pulseTime() - start) << " sec \n"; + for (auto & i : events1) { + std::cout << (i.pulseTime() - start) << " sec \n"; } } diff --git a/Framework/DataHandling/test/LoadMaskTest.h b/Framework/DataHandling/test/LoadMaskTest.h index dc3f1db1fcf..9e10583d305 100644 --- a/Framework/DataHandling/test/LoadMaskTest.h +++ b/Framework/DataHandling/test/LoadMaskTest.h @@ -532,8 +532,8 @@ public: ss << "</detids>\n"; } - for (size_t i = 0; i < banks.size(); i++) { - ss << "<component>bank" << banks[i] << "</component>\n"; + for (int bank : banks) { + ss << "<component>bank" << bank << "</component>\n"; } // 4. End of file @@ -552,8 +552,8 @@ public: std::stringstream ss; // 1. Single spectra - for (size_t i = 0; i < singlespectra.size(); i++) { - ss << singlespectra[i] << " "; + for (int i : singlespectra) { + ss << i << " "; } ss << '\n'; diff --git a/Framework/DataHandling/test/LoadNexusMonitorsTest.h b/Framework/DataHandling/test/LoadNexusMonitorsTest.h index 7051fab7658..262f5ff2aba 100644 --- a/Framework/DataHandling/test/LoadNexusMonitorsTest.h +++ b/Framework/DataHandling/test/LoadNexusMonitorsTest.h @@ -167,8 +167,8 @@ public: // Count output workspaces int ws_count = 0; auto props = ld1.getProperties(); - for (auto iter = props.begin(); iter != props.end(); ++iter) - if ((*iter)->type() == "Workspace") + for (auto & prop : props) + if (prop->type() == "Workspace") ws_count++; // Version 1 has an issue that produces additional output workspaces for @@ -191,8 +191,8 @@ public: // Count output workspaces ws_count = 0; props = ld2.getProperties(); - for (auto iter = props.begin(); iter != props.end(); ++iter) - if ((*iter)->type() == "Workspace") + for (auto & prop : props) + if (prop->type() == "Workspace") ws_count++; // Version 2 always produces one OutputWorkspace, which may be a group diff --git a/Framework/DataHandling/test/LoadTest.h b/Framework/DataHandling/test/LoadTest.h index 55305d0dbeb..9a2622c1999 100644 --- a/Framework/DataHandling/test/LoadTest.h +++ b/Framework/DataHandling/test/LoadTest.h @@ -112,16 +112,16 @@ public: const char *loadraw_props[NUMPROPS] = { "SpectrumMin", "SpectrumMax", "SpectrumList", "Cache", "LoadLogFiles"}; // Basic load has no additional loader properties - for (size_t i = 0; i < NUMPROPS; ++i) { - TS_ASSERT_EQUALS(loader.existsProperty(loadraw_props[i]), false); + for (auto & loadraw_prop : loadraw_props) { + TS_ASSERT_EQUALS(loader.existsProperty(loadraw_prop), false); } // After setting the file property, the algorithm should have aquired the // appropriate properties TS_ASSERT_THROWS_NOTHING( loader.setPropertyValue("Filename", "IRS38633.raw")); // Now - for (size_t i = 0; i < NUMPROPS; ++i) { - TS_ASSERT_EQUALS(loader.existsProperty(loadraw_props[i]), true); + for (auto & loadraw_prop : loadraw_props) { + TS_ASSERT_EQUALS(loader.existsProperty(loadraw_prop), true); } // Did it find the right loader diff --git a/Framework/DataHandling/test/SaveAscii2Test.h b/Framework/DataHandling/test/SaveAscii2Test.h index c3b86dacfdc..dd0602f2785 100644 --- a/Framework/DataHandling/test/SaveAscii2Test.h +++ b/Framework/DataHandling/test/SaveAscii2Test.h @@ -68,8 +68,8 @@ public: std::getline(in, binlines); boost::split(binstr, binlines, boost::is_any_of(",")); - for (size_t i = 0; i < binstr.size(); i++) { - bins.push_back(boost::lexical_cast<double>(binstr.at(i))); + for (const auto & i : binstr) { + bins.push_back(boost::lexical_cast<double>(i)); } TS_ASSERT_EQUALS(bins[0], 0); TS_ASSERT_EQUALS(bins[1], 2); @@ -78,8 +78,8 @@ public: std::getline(in, binlines); bins.clear(); boost::split(binstr, binlines, boost::is_any_of(",")); - for (size_t i = 0; i < binstr.size(); i++) { - bins.push_back(boost::lexical_cast<double>(binstr.at(i))); + for (const auto & i : binstr) { + bins.push_back(boost::lexical_cast<double>(i)); } TS_ASSERT_EQUALS(bins[0], 1.66667); TS_ASSERT_EQUALS(bins[1], 8.66667); @@ -165,8 +165,8 @@ public: std::getline(in, binlines); boost::split(binstr, binlines, boost::is_any_of(",")); - for (size_t i = 0; i < binstr.size(); i++) { - bins.push_back(boost::lexical_cast<double>(binstr.at(i))); + for (const auto & i : binstr) { + bins.push_back(boost::lexical_cast<double>(i)); } TS_ASSERT_EQUALS(bins[0], 0); TS_ASSERT_EQUALS(bins[1], 2); @@ -175,8 +175,8 @@ public: std::getline(in, binlines); bins.clear(); boost::split(binstr, binlines, boost::is_any_of(",")); - for (size_t i = 0; i < binstr.size(); i++) { - bins.push_back(boost::lexical_cast<double>(binstr.at(i))); + for (const auto & i : binstr) { + bins.push_back(boost::lexical_cast<double>(i)); } TS_ASSERT_EQUALS(bins[0], 1.66667); TS_ASSERT_EQUALS(bins[1], 8.66667); @@ -589,8 +589,8 @@ public: std::getline(in, binlines); boost::split(binstr, binlines, boost::is_any_of(",")); - for (size_t i = 0; i < binstr.size(); i++) { - bins.push_back(boost::lexical_cast<double>(binstr.at(i))); + for (const auto & i : binstr) { + bins.push_back(boost::lexical_cast<double>(i)); } TS_ASSERT_EQUALS(bins[0], 0); TS_ASSERT_EQUALS(bins[1], 4); @@ -599,8 +599,8 @@ public: std::getline(in, binlines); bins.clear(); boost::split(binstr, binlines, boost::is_any_of(",")); - for (size_t i = 0; i < binstr.size(); i++) { - bins.push_back(boost::lexical_cast<double>(binstr.at(i))); + for (const auto & i : binstr) { + bins.push_back(boost::lexical_cast<double>(i)); } TS_ASSERT_EQUALS(bins[0], 1.66667); TS_ASSERT_EQUALS(bins[1], 17.3333); diff --git a/Framework/DataHandling/test/SavePHXTest.h b/Framework/DataHandling/test/SavePHXTest.h index 1bb461aabe3..036142ea726 100644 --- a/Framework/DataHandling/test/SavePHXTest.h +++ b/Framework/DataHandling/test/SavePHXTest.h @@ -139,8 +139,8 @@ public: sample_value[0] = (float)spTW->rowCount(); } else { size_t ii = 0; - for (size_t i = 0; i < column_name.size(); i++) { - sample_value[ii] = (spTW->cell_cast<float>(ic - 1, column_name[i])); + for (const auto & i : column_name) { + sample_value[ii] = (spTW->cell_cast<float>(ic - 1, i)); ii++; if (ii == 1) ii = 2; // scip second column in the file, which contains 0; diff --git a/Framework/DataObjects/src/PeaksWorkspace.cpp b/Framework/DataObjects/src/PeaksWorkspace.cpp index eab92ec1da6..9e771d91dd9 100644 --- a/Framework/DataObjects/src/PeaksWorkspace.cpp +++ b/Framework/DataObjects/src/PeaksWorkspace.cpp @@ -162,8 +162,8 @@ void PeaksWorkspace::removePeaks(std::vector<int> badPeaks) { std::remove_if(peaks.begin(), peaks.end(), [&ip, badPeaks](Peak &pk) { (void)pk; ip++; - for (auto ibp = badPeaks.begin(); ibp != badPeaks.end(); ++ibp) { - if (*ibp == ip) + for (int badPeak : badPeaks) { + if (badPeak == ip) return true; } return false; diff --git a/Framework/DataObjects/src/Workspace2D.cpp b/Framework/DataObjects/src/Workspace2D.cpp index 169ce00da4c..086697eff98 100644 --- a/Framework/DataObjects/src/Workspace2D.cpp +++ b/Framework/DataObjects/src/Workspace2D.cpp @@ -46,10 +46,10 @@ Workspace2D::~Workspace2D() { PARALLEL_FOR_IF(Kernel::threadSafe(*this)) for (int64_t i = 0; i < static_cast<int64_t>(data.size()); i++) { #else - for (size_t i = 0; i < data.size(); ++i) { + for (auto & i : data) { #endif // Clear out the memory - delete data[i]; + delete i; } } @@ -107,8 +107,8 @@ void Workspace2D::init(const HistogramData::Histogram &histogram) { Histogram1D spec(initializedHistogram.xMode(), initializedHistogram.yMode()); spec.setHistogram(initializedHistogram); - for (size_t i = 0; i < data.size(); i++) { - data[i] = new Histogram1D(spec); + for (auto & i : data) { + i = new Histogram1D(spec); } // Add axes that reference the data diff --git a/Framework/DataObjects/test/EventListTest.h b/Framework/DataObjects/test/EventListTest.h index 7d1e65d52de..a1a682fe440 100644 --- a/Framework/DataObjects/test/EventListTest.h +++ b/Framework/DataObjects/test/EventListTest.h @@ -1826,9 +1826,8 @@ public: } // Clean the pointers - for (std::map<int, EventList *>::iterator im = outputs.begin(); - im != outputs.end(); ++im) { - delete im->second; + for (auto & output : outputs) { + delete output.second; } return; @@ -1874,9 +1873,8 @@ public: } // Clean the pointers - for (std::map<int, EventList *>::iterator im = outputs.begin(); - im != outputs.end(); ++im) { - delete im->second; + for (auto & output : outputs) { + delete output.second; } return; @@ -2312,9 +2310,8 @@ public: TS_ASSERT_EQUALS(e7->getNumberEvents(), 1); // Clean the pointers - for (std::map<int, EventList *>::iterator im = outputs.begin(); - im != outputs.end(); ++im) { - delete im->second; + for (auto & output : outputs) { + delete output.second; } return; @@ -2385,9 +2382,8 @@ public: // TS_ASSERT_EQUALS(e7->getNumberEvents(), 1); // Clean the pointers - for (std::map<int, EventList *>::iterator im = outputs.begin(); - im != outputs.end(); ++im) { - delete im->second; + for (auto & output : outputs) { + delete output.second; } return; diff --git a/Framework/DataObjects/test/MDBoxFlatTreeTest.h b/Framework/DataObjects/test/MDBoxFlatTreeTest.h index 3b3cfc2c991..8dbdd1fecb2 100644 --- a/Framework/DataObjects/test/MDBoxFlatTreeTest.h +++ b/Framework/DataObjects/test/MDBoxFlatTreeTest.h @@ -93,8 +93,8 @@ public: if (!Boxes[i]->isBox()) gridIndices.push_back(i); } - for (size_t i = 0; i < gridIndices.size(); ++i) { - delete Boxes[gridIndices[i]]; + for (unsigned long gridIndice : gridIndices) { + delete Boxes[gridIndice]; } // Clean up file diff --git a/Framework/DataObjects/test/MDBoxSaveableTest.h b/Framework/DataObjects/test/MDBoxSaveableTest.h index 12c374388df..fdb9b463667 100644 --- a/Framework/DataObjects/test/MDBoxSaveableTest.h +++ b/Framework/DataObjects/test/MDBoxSaveableTest.h @@ -840,8 +840,7 @@ public: size_t numOnDisk = 0; uint64_t eventsOnDisk = 0; uint64_t maxFilePos = 0; - for (size_t i = 0; i < boxes.size(); i++) { - API::IMDNode *box = boxes[i]; + for (auto box : boxes) { TS_ASSERT_EQUALS(box->getNPoints(), num_repeat); auto mdbox = dynamic_cast<MDBox<MDE, 2> *>(box); TS_ASSERT(mdbox); diff --git a/Framework/DataObjects/test/MDBoxTest.h b/Framework/DataObjects/test/MDBoxTest.h index 0f64cf5f143..359b7432189 100644 --- a/Framework/DataObjects/test/MDBoxTest.h +++ b/Framework/DataObjects/test/MDBoxTest.h @@ -585,8 +585,8 @@ public: coord_t centroid[2] = {0, 0}; signal_t signal = 0.0; b.centroidSphere(sphere, 400., centroid, signal); - for (size_t d = 0; d < 2; d++) - centroid[d] /= static_cast<coord_t>(signal); + for (float & d : centroid) + d /= static_cast<coord_t>(signal); // This should be the weighted centroid TS_ASSERT_DELTA(signal, 6.000, 0.001); @@ -595,11 +595,11 @@ public: // --- Reset and reduce the radius ------ signal = 0; - for (size_t d = 0; d < 2; d++) - centroid[d] = 0.0; + for (float & d : centroid) + d = 0.0; b.centroidSphere(sphere, 16., centroid, signal); - for (size_t d = 0; d < 2; d++) - centroid[d] /= static_cast<coord_t>(signal); + for (float & d : centroid) + d /= static_cast<coord_t>(signal); // Only one event was contained TS_ASSERT_DELTA(signal, 2.000, 0.001); TS_ASSERT_DELTA(centroid[0], 2.000, 0.001); diff --git a/Framework/DataObjects/test/MDGridBoxTest.h b/Framework/DataObjects/test/MDGridBoxTest.h index 0ae4ef00585..c75b390cc5a 100644 --- a/Framework/DataObjects/test/MDGridBoxTest.h +++ b/Framework/DataObjects/test/MDGridBoxTest.h @@ -261,10 +261,10 @@ public: new MDGridBox<MDLeanEvent<1>, 1>(*box, newBoxController); auto boxes = box1->getBoxes(); - for (size_t i = 0; i < boxes.size(); ++i) { + for (auto & boxe : boxes) { TSM_ASSERT_EQUALS( "All child boxes should have the same box controller as the parent.", - newBoxController, boxes[i]->getBoxController()); + newBoxController, boxe->getBoxController()); } delete newBoxController; delete box1; @@ -298,8 +298,8 @@ public: // be // taken care of manually size_t indices[5] = {0, 1, 12, 13, 14}; - for (size_t i = 0; i < 5; ++i) - delete boxes[indices[i]]; + for (unsigned long indice : indices) + delete boxes[indice]; delete g; delete bcc; } @@ -329,9 +329,9 @@ public: // Check the boxes std::vector<MDBoxBase<MDLeanEvent<3>, 3> *> boxes = g->getBoxes(); TS_ASSERT_EQUALS(boxes.size(), 10 * 5 * 2); - for (size_t i = 0; i < boxes.size(); i++) { + for (auto & boxe : boxes) { MDBox<MDLeanEvent<3>, 3> *box = - dynamic_cast<MDBox<MDLeanEvent<3>, 3> *>(boxes[i]); + dynamic_cast<MDBox<MDLeanEvent<3>, 3> *>(boxe); TS_ASSERT(box); } MDBox<MDLeanEvent<3>, 3> *box; @@ -602,8 +602,8 @@ public: parent->getBoxes(boxes, 3, false, function); TS_ASSERT_EQUALS(boxes.size(), 54); // The boxes extents make sense - for (size_t i = 0; i < boxes.size(); i++) { - TS_ASSERT(boxes[i]->getExtents(0).getMax() >= 1.51); + for (auto & boxe : boxes) { + TS_ASSERT(boxe->getExtents(0).getMax() >= 1.51); } // --- Now leaf-only --- @@ -611,8 +611,8 @@ public: parent->getBoxes(boxes, 3, true, function); TS_ASSERT_EQUALS(boxes.size(), 40); // The boxes extents make sense - for (size_t i = 0; i < boxes.size(); i++) { - TS_ASSERT(boxes[i]->getExtents(0).getMax() >= 1.51); + for (auto & boxe : boxes) { + TS_ASSERT(boxe->getExtents(0).getMax() >= 1.51); } // Limit by another plane @@ -622,18 +622,18 @@ public: boxes.clear(); parent->getBoxes(boxes, 3, false, function); TS_ASSERT_EQUALS(boxes.size(), 33); - for (size_t i = 0; i < boxes.size(); i++) { - TS_ASSERT(boxes[i]->getExtents(0).getMax() >= 1.51); - TS_ASSERT(boxes[i]->getExtents(0).getMin() <= 2.99); + for (auto & boxe : boxes) { + TS_ASSERT(boxe->getExtents(0).getMax() >= 1.51); + TS_ASSERT(boxe->getExtents(0).getMin() <= 2.99); } // Same, leaf only boxes.clear(); parent->getBoxes(boxes, 3, true, function); TS_ASSERT_EQUALS(boxes.size(), 24); - for (size_t i = 0; i < boxes.size(); i++) { - TS_ASSERT(boxes[i]->getExtents(0).getMax() >= 1.51); - TS_ASSERT(boxes[i]->getExtents(0).getMin() <= 2.99); + for (auto & boxe : boxes) { + TS_ASSERT(boxe->getExtents(0).getMax() >= 1.51); + TS_ASSERT(boxe->getExtents(0).getMin() <= 2.99); } // ----- Infinitely thin plane for an implicit function ------------ @@ -675,11 +675,11 @@ public: parent->getBoxes(boxes, 3, false, function); TS_ASSERT_EQUALS(boxes.size(), 46); // The boxes extents make sense - for (size_t i = 0; i < boxes.size(); i++) { - TS_ASSERT(boxes[i]->getExtents(0).getMax() >= 2.00); - TS_ASSERT(boxes[i]->getExtents(0).getMin() <= 3.00); - TS_ASSERT(boxes[i]->getExtents(1).getMax() >= 2.00); - TS_ASSERT(boxes[i]->getExtents(1).getMin() <= 3.00); + for (auto & boxe : boxes) { + TS_ASSERT(boxe->getExtents(0).getMax() >= 2.00); + TS_ASSERT(boxe->getExtents(0).getMin() <= 3.00); + TS_ASSERT(boxe->getExtents(1).getMax() >= 2.00); + TS_ASSERT(boxe->getExtents(1).getMin() <= 3.00); } // -- Leaf only --- @@ -690,11 +690,11 @@ public: 16 + 4 * 4 + 4); // 16 in the center one + 4x4 at the 4 edges + 4 at the corners // The boxes extents make sense - for (size_t i = 0; i < boxes.size(); i++) { - TS_ASSERT(boxes[i]->getExtents(0).getMax() >= 2.00); - TS_ASSERT(boxes[i]->getExtents(0).getMin() <= 3.00); - TS_ASSERT(boxes[i]->getExtents(1).getMax() >= 2.00); - TS_ASSERT(boxes[i]->getExtents(1).getMin() <= 3.00); + for (auto & boxe : boxes) { + TS_ASSERT(boxe->getExtents(0).getMax() >= 2.00); + TS_ASSERT(boxe->getExtents(0).getMin() <= 3.00); + TS_ASSERT(boxe->getExtents(1).getMax() >= 2.00); + TS_ASSERT(boxe->getExtents(1).getMin() <= 3.00); } // clean up behind @@ -835,12 +835,12 @@ public: // Get all the boxes contained std::vector<MDBoxBase<MDLeanEvent<2>, 2> *> boxes = b->getBoxes(); TS_ASSERT_EQUALS(boxes.size(), 100); - for (size_t i = 0; i < boxes.size(); i++) { - TS_ASSERT_EQUALS(boxes[i]->getNPoints(), 1); - TS_ASSERT_EQUALS(boxes[i]->getSignal(), 2.0); - TS_ASSERT_EQUALS(boxes[i]->getErrorSquared(), 2.0); - TS_ASSERT_EQUALS(boxes[i]->getSignalNormalized(), 2.0); - TS_ASSERT_EQUALS(boxes[i]->getErrorSquaredNormalized(), 2.0); + for (auto & boxe : boxes) { + TS_ASSERT_EQUALS(boxe->getNPoints(), 1); + TS_ASSERT_EQUALS(boxe->getSignal(), 2.0); + TS_ASSERT_EQUALS(boxe->getErrorSquared(), 2.0); + TS_ASSERT_EQUALS(boxe->getSignalNormalized(), 2.0); + TS_ASSERT_EQUALS(boxe->getErrorSquaredNormalized(), 2.0); } // Now try to add bad events (outside bounds) @@ -1083,8 +1083,7 @@ public: // many events std::vector<ibox_t *> boxes = b->getBoxes(); TS_ASSERT_EQUALS(boxes.size(), 100); - for (size_t i = 0; i < boxes.size(); i++) { - ibox_t *box = boxes[i]; + for (auto box : boxes) { TS_ASSERT_EQUALS(box->getNPoints(), num_repeat); TS_ASSERT(dynamic_cast<gbox_t *>(box)); @@ -1405,8 +1404,8 @@ public: signal); // Normalized if (signal != 0.0) { - for (size_t d = 0; d < 2; d++) - centroid[d] /= static_cast<coord_t>(signal); + for (float & d : centroid) + d /= static_cast<coord_t>(signal); } TSM_ASSERT_DELTA(message, signal, 1.0 * numExpected, 1e-5); @@ -1630,8 +1629,8 @@ public: rng, u); for (size_t i = 0; i < num; ++i) { double centers[3]; - for (size_t d = 0; d < 3; d++) - centers[d] = gen(); + for (double & center : centers) + center = gen(); // Create and add the event. events.push_back(MDLeanEvent<3>(1.0, 1.0, centers)); } @@ -1730,12 +1729,12 @@ public: coord_t centroid[3]; for (size_t i = 0; i < 100; i++) { signal = 0; - for (size_t d = 0; d < 3; d++) - centroid[d] = 0.0; + for (float & d : centroid) + d = 0.0; box3b->centroidSphere(sphere, radius * radius, centroid, signal); if (signal != 0.0) { - for (size_t d = 0; d < 3; d++) - centroid[d] /= static_cast<coord_t>(signal); + for (float & d : centroid) + d /= static_cast<coord_t>(signal); } } diff --git a/Framework/DataObjects/test/MDHistoWorkspaceIteratorTest.h b/Framework/DataObjects/test/MDHistoWorkspaceIteratorTest.h index cc63960592d..eb9707829b2 100644 --- a/Framework/DataObjects/test/MDHistoWorkspaceIteratorTest.h +++ b/Framework/DataObjects/test/MDHistoWorkspaceIteratorTest.h @@ -681,9 +681,8 @@ public: neighbourIndexes = it->findNeighbourIndexesFaceTouching(); TS_ASSERT_EQUALS(4, neighbourIndexes.size()); std::vector<size_t> expected_neighbours = {0, 2, 5, 17}; - for (auto i = expected_neighbours.begin(); i != expected_neighbours.end(); - ++i) { - TS_ASSERT(doesContainIndex(neighbourIndexes, *i)); + for (unsigned long & expected_neighbour : expected_neighbours) { + TS_ASSERT(doesContainIndex(neighbourIndexes, expected_neighbour)); } // Move to index 21 @@ -694,9 +693,8 @@ public: // Is completely enclosed expected_neighbours = {17, 20, 22, 25, 5, 37}; - for (auto i = expected_neighbours.begin(); i != expected_neighbours.end(); - ++i) { - TS_ASSERT(doesContainIndex(neighbourIndexes, *i)); + for (unsigned long & expected_neighbour : expected_neighbours) { + TS_ASSERT(doesContainIndex(neighbourIndexes, expected_neighbour)); } // Move to index 63. The last index. @@ -706,9 +704,8 @@ public: // Is on edge expected_neighbours = {47, 59, 62}; - for (auto i = expected_neighbours.begin(); i != expected_neighbours.end(); - ++i) { - TS_ASSERT(doesContainIndex(neighbourIndexes, *i)); + for (unsigned long & expected_neighbour : expected_neighbours) { + TS_ASSERT(doesContainIndex(neighbourIndexes, expected_neighbour)); } delete it; @@ -762,9 +759,8 @@ public: TS_ASSERT_EQUALS(11, neighbourIndexes.size()); std::vector<size_t> expected_neighbours = {0, 2, 4, 5, 6, 16, 17, 18, 20, 21, 22, 22}; - for (auto i = expected_neighbours.begin(); i != expected_neighbours.end(); - ++i) { - TS_ASSERT(doesContainIndex(neighbourIndexes, *i)); + for (unsigned long & expected_neighbour : expected_neighbours) { + TS_ASSERT(doesContainIndex(neighbourIndexes, expected_neighbour)); } // Move to index 21 @@ -776,9 +772,8 @@ public: expected_neighbours = {0, 1, 2, 4, 5, 6, 8, 9, 10, 16, 17, 18, 22, 20, 24, 25, 26, 32, 33, 34, 37, 38, 36, 41, 40, 42}; - for (auto i = expected_neighbours.begin(); i != expected_neighbours.end(); - ++i) { - TS_ASSERT(doesContainIndex(neighbourIndexes, *i)); + for (unsigned long & expected_neighbour : expected_neighbours) { + TS_ASSERT(doesContainIndex(neighbourIndexes, expected_neighbour)); } // Move to index 63. The last index. @@ -788,9 +783,8 @@ public: // Is on edge expected_neighbours = {42, 43, 46, 47, 58, 59, 62}; - for (auto i = expected_neighbours.begin(); i != expected_neighbours.end(); - ++i) { - TS_ASSERT(doesContainIndex(neighbourIndexes, *i)); + for (unsigned long & expected_neighbour : expected_neighbours) { + TS_ASSERT(doesContainIndex(neighbourIndexes, expected_neighbour)); } delete it; diff --git a/Framework/DataObjects/test/PeakTest.h b/Framework/DataObjects/test/PeakTest.h index 9c3404718fc..82ded86e3f9 100644 --- a/Framework/DataObjects/test/PeakTest.h +++ b/Framework/DataObjects/test/PeakTest.h @@ -601,8 +601,7 @@ private: void check_Contributing_Detectors(const Peak &peak, const std::vector<int> &expected) { auto peakIDs = peak.getContributingDetIDs(); - for (auto it = expected.begin(); it != expected.end(); ++it) { - const int id = *it; + for (int id : expected) { TSM_ASSERT_EQUALS("Expected " + boost::lexical_cast<std::string>(id) + " in contribution list", 1, peakIDs.count(id)) diff --git a/Framework/Geometry/src/Rendering/vtkGeometryCacheReader.cpp b/Framework/Geometry/src/Rendering/vtkGeometryCacheReader.cpp index e773eadcf65..ac7dce31204 100644 --- a/Framework/Geometry/src/Rendering/vtkGeometryCacheReader.cpp +++ b/Framework/Geometry/src/Rendering/vtkGeometryCacheReader.cpp @@ -128,8 +128,8 @@ void vtkGeometryCacheReader::readPoints(Poco::XML::Element *pEle, if (pEle->getAttribute("format") == "ascii") { // Read from Ascii std::stringstream buf; buf << pEle->innerText(); - for (size_t i = 0; i < points.size(); i++) { - buf >> points[i]; + for (double & point : points) { + buf >> point; } } // Read from binary otherwise @@ -155,8 +155,8 @@ void vtkGeometryCacheReader::readTriangles(Poco::XML::Element *pEle, if (pEle->getAttribute("format") == "ascii") { // Read from Ascii std::stringstream buf; buf << pEle->innerText(); - for (size_t i = 0; i < faces.size(); i++) { - buf >> faces[i]; + for (unsigned int & face : faces) { + buf >> face; } } // Read from binary otherwise diff --git a/Framework/Geometry/test/CSGObjectTest.h b/Framework/Geometry/test/CSGObjectTest.h index 6a343e1d357..bdbfe99de76 100644 --- a/Framework/Geometry/test/CSGObjectTest.h +++ b/Framework/Geometry/test/CSGObjectTest.h @@ -1270,11 +1270,11 @@ private: SurfLine.push_back(SCompT(73, "s 0.6 0 0 0.4")); // Note that the testObject now manages the "new Plane" - for (auto vc = SurfLine.cbegin(); vc != SurfLine.cend(); ++vc) { - auto A = Geometry::SurfaceFactory::Instance()->processLine(vc->second); + for (const auto & vc : SurfLine) { + auto A = Geometry::SurfaceFactory::Instance()->processLine(vc.second); TSM_ASSERT("Expected a non-null surface from the factory", A); - A->setName(vc->first); - SMap.insert(STYPE::value_type(vc->first, + A->setName(vc.first); + SMap.insert(STYPE::value_type(vc.first, boost::shared_ptr<Surface>(A.release()))); } diff --git a/Framework/Geometry/test/CenteringGroupTest.h b/Framework/Geometry/test/CenteringGroupTest.h index 16667f7f017..d48eed4c235 100644 --- a/Framework/Geometry/test/CenteringGroupTest.h +++ b/Framework/Geometry/test/CenteringGroupTest.h @@ -65,10 +65,9 @@ private: TSM_ASSERT_EQUALS("Unexpected number of operations for " + symbol, ops.size(), expectedOperations.size()); - for (auto it = expectedOperations.begin(); it != expectedOperations.end(); - ++it) { - TSM_ASSERT("Operation " + (*it).identifier() + " not found in " + symbol, - symOpExistsInCollection(*it, ops)); + for (const auto & expectedOperation : expectedOperations) { + TSM_ASSERT("Operation " + expectedOperation.identifier() + " not found in " + symbol, + symOpExistsInCollection(expectedOperation, ops)); } CenteringGroup_const_sptr centeringGroup = diff --git a/Framework/Geometry/test/CompositeBraggScattererTest.h b/Framework/Geometry/test/CompositeBraggScattererTest.h index cb65396fb39..50755c0d8ee 100644 --- a/Framework/Geometry/test/CompositeBraggScattererTest.h +++ b/Framework/Geometry/test/CompositeBraggScattererTest.h @@ -130,9 +130,9 @@ public: spaceGroup->getEquivalentPositions(V3D(0.2, 0.3, 0.4)); CompositeBraggScatterer_sptr coll = CompositeBraggScatterer::create(); - for (auto pos = positions.begin(); pos != positions.end(); ++pos) { + for (auto & position : positions) { std::ostringstream strm; - strm << (*pos); + strm << position; coll->addScatterer(getInitializedScatterer("Si", strm.str(), 0.01267)); } diff --git a/Framework/Geometry/test/GroupTransformationTest.h b/Framework/Geometry/test/GroupTransformationTest.h index e583286acb0..71792678165 100644 --- a/Framework/Geometry/test/GroupTransformationTest.h +++ b/Framework/Geometry/test/GroupTransformationTest.h @@ -51,9 +51,9 @@ public: */ std::unordered_set<std::string> elements; std::vector<SymmetryOperation> ops = transformed.getSymmetryOperations(); - for (auto op = ops.begin(); op != ops.end(); ++op) { + for (auto & op : ops) { SymmetryElement_sptr el = - SymmetryElementFactory::Instance().createSymElement(*op); + SymmetryElementFactory::Instance().createSymElement(op); // Check for identity SymmetryElementIdentity_sptr identity = diff --git a/Framework/Geometry/test/IndexingUtilsTest.h b/Framework/Geometry/test/IndexingUtilsTest.h index 200bd61e8ec..f63fc709e95 100644 --- a/Framework/Geometry/test/IndexingUtilsTest.h +++ b/Framework/Geometry/test/IndexingUtilsTest.h @@ -29,8 +29,8 @@ public: {-0.90478, -0.50667, 0.51072}, {-0.50387, -0.58561, 0.43502}}; // Dec 2011: Change convention for Q = 2 pi / wavelength - for (size_t i = 0; i < q_vectors.size(); i++) - q_vectors[i] *= (2.0 * M_PI); + for (auto & q_vector : q_vectors) + q_vector *= (2.0 * M_PI); return q_vectors; } @@ -232,8 +232,8 @@ public: void test_Optimize_Direction() { std::vector<int> index_values; int correct_indices[] = {1, 4, 2, 0, 1, 3, 0, -1, 0, -1, -2, -3}; - for (size_t i = 0; i < 12; i++) { - index_values.push_back(correct_indices[i]); + for (int correct_indice : correct_indices) { + index_values.push_back(correct_indice); } std::vector<V3D> q_vectors = getNatroliteQs(); @@ -372,8 +372,8 @@ public: {2.66668320, 5.29605670, 7.9653444}}; std::vector<V3D> directions; - for (size_t i = 0; i < 5; i++) - directions.emplace_back(vectors[i][0], vectors[i][1], vectors[i][2]); + for (auto & vector : vectors) + directions.emplace_back(vector[0], vector[1], vector[2]); double required_tolerance = 0.12; size_t a_index = 0; @@ -410,8 +410,8 @@ public: {2.66668320, 5.29605670, 7.9653444}}; std::vector<V3D> directions; - for (size_t i = 0; i < 5; i++) - directions.emplace_back(vectors[i][0], vectors[i][1], vectors[i][2]); + for (auto & vector : vectors) + directions.emplace_back(vector[0], vector[1], vector[2]); std::vector<V3D> q_vectors = getNatroliteQs(); double required_tolerance = 0.12; @@ -756,8 +756,8 @@ public: TS_ASSERT_DELTA(direction_list[7].Z(), -0.211325, 1e-5); double dot_prod; - for (size_t i = 0; i < direction_list.size(); i++) { - dot_prod = axis.scalar_prod(direction_list[i]); + for (const auto & i : direction_list) { + dot_prod = axis.scalar_prod(i); TS_ASSERT_DELTA(dot_prod, 0, 1e-10); } } diff --git a/Framework/Geometry/test/PointGroupTest.h b/Framework/Geometry/test/PointGroupTest.h index 5976f6c1351..a822cebbea2 100644 --- a/Framework/Geometry/test/PointGroupTest.h +++ b/Framework/Geometry/test/PointGroupTest.h @@ -289,11 +289,11 @@ public: std::vector<PointGroup_sptr> pointgroups = getAllPointGroups(); - for (size_t i = 0; i < pointgroups.size(); ++i) { - TSM_ASSERT_EQUALS(pointgroups[i]->getSymbol() + + for (auto & pointgroup : pointgroups) { + TSM_ASSERT_EQUALS(pointgroup->getSymbol() + ": Unexpected crystal system.", - pointgroups[i]->crystalSystem(), - crystalSystemsMap[pointgroups[i]->getSymbol()]); + pointgroup->crystalSystem(), + crystalSystemsMap[pointgroup->getSymbol()]); } } @@ -446,8 +446,8 @@ private: t.reset(); int h = 0; for (size_t i = 0; i < 1000; ++i) { - for (auto hkl = hkls.begin(); hkl != hkls.end(); ++hkl) { - bool eq = pointGroup->isEquivalent(base, *hkl); + for (auto & hkl : hkls) { + bool eq = pointGroup->isEquivalent(base, hkl); if (eq) { ++h; } diff --git a/Framework/Geometry/test/ReflectionConditionTest.h b/Framework/Geometry/test/ReflectionConditionTest.h index c8841ae0fee..f55d5272e1f 100644 --- a/Framework/Geometry/test/ReflectionConditionTest.h +++ b/Framework/Geometry/test/ReflectionConditionTest.h @@ -58,11 +58,11 @@ public: centeringSymbols.insert("H"); std::vector<ReflectionCondition_sptr> refs = getAllReflectionConditions(); - for (auto it = refs.begin(); it != refs.end(); ++it) { - TSM_ASSERT_DIFFERS((*it)->getSymbol(), - centeringSymbols.find((*it)->getSymbol()), + for (auto & ref : refs) { + TSM_ASSERT_DIFFERS(ref->getSymbol(), + centeringSymbols.find(ref->getSymbol()), centeringSymbols.end()); - centeringSymbols.erase((*it)->getSymbol()); + centeringSymbols.erase(ref->getSymbol()); } // All centering symbols are present if the set is empty. diff --git a/Framework/Geometry/test/SpaceGroupTest.h b/Framework/Geometry/test/SpaceGroupTest.h index 4aa4df38b14..1e3dec0ca6e 100644 --- a/Framework/Geometry/test/SpaceGroupTest.h +++ b/Framework/Geometry/test/SpaceGroupTest.h @@ -66,8 +66,8 @@ public: SpaceGroup spaceGroup(167, "R-3c", *(group * centering)); std::vector<V3D> byOperator = spaceGroup * V3D(0.3, 0.0, 0.25); - for (size_t i = 0; i < byOperator.size(); ++i) { - byOperator[i] = getWrappedVector(byOperator[i]); + for (auto & i : byOperator) { + i = getWrappedVector(i); } std::sort(byOperator.begin(), byOperator.end()); @@ -86,8 +86,8 @@ public: SpaceGroup spaceGroup = getSpaceGroupR3m(); std::vector<V3D> byOperator = spaceGroup * V3D(0.5, 0.0, 0.0); - for (size_t i = 0; i < byOperator.size(); ++i) { - byOperator[i] = getWrappedVector(byOperator[i]); + for (auto & i : byOperator) { + i = getWrappedVector(i); } std::sort(byOperator.begin(), byOperator.end()); diff --git a/Framework/Geometry/test/SymmetryOperationFactoryTest.h b/Framework/Geometry/test/SymmetryOperationFactoryTest.h index 7e425a0df07..22f7693a8d7 100644 --- a/Framework/Geometry/test/SymmetryOperationFactoryTest.h +++ b/Framework/Geometry/test/SymmetryOperationFactoryTest.h @@ -125,8 +125,8 @@ public: // Clear factory std::vector<std::string> allSymbols = SymmetryOperationFactory::Instance().subscribedSymbols(); - for (auto it = allSymbols.begin(); it != allSymbols.end(); ++it) { - SymmetryOperationFactory::Instance().unsubscribeSymOp(*it); + for (auto & allSymbol : allSymbols) { + SymmetryOperationFactory::Instance().unsubscribeSymOp(allSymbol); } // Subscribe two symmetry operations @@ -146,8 +146,8 @@ public: SymmetryOperationFactory::Instance().unsubscribeSymOp("-x,-y,-z"); // Restore factory - for (auto it = allSymbols.begin(); it != allSymbols.end(); ++it) { - SymmetryOperationFactory::Instance().subscribeSymOp(*it); + for (auto & allSymbol : allSymbols) { + SymmetryOperationFactory::Instance().subscribeSymOp(allSymbol); } } }; diff --git a/Framework/Kernel/test/ConfigServiceTest.h b/Framework/Kernel/test/ConfigServiceTest.h index bd2f247a1d1..d51807166c6 100644 --- a/Framework/Kernel/test/ConfigServiceTest.h +++ b/Framework/Kernel/test/ConfigServiceTest.h @@ -352,9 +352,9 @@ public: ConfigService::Instance().getInstrumentDirectory()); // check all of the directory entries actually exist - for (auto it = directories.begin(); it != directories.end(); ++it) { - Poco::File directory(*it); - TSM_ASSERT(*it + " does not exist", directory.exists()); + for (auto & directorie : directories) { + Poco::File directory(directorie); + TSM_ASSERT(directorie + " does not exist", directory.exists()); } } diff --git a/Framework/Kernel/test/DiskBufferISaveableTest.h b/Framework/Kernel/test/DiskBufferISaveableTest.h index 873796a94bc..0d93d39bee3 100644 --- a/Framework/Kernel/test/DiskBufferISaveableTest.h +++ b/Framework/Kernel/test/DiskBufferISaveableTest.h @@ -90,14 +90,14 @@ public: } void tearDown() override { - for (size_t i = 0; i < data.size(); i++) { - delete data[i]; - data[i] = NULL; + for (auto & i : data) { + delete i; + i = NULL; } - for (size_t i = 0; i < bigData.size(); i++) { - delete bigData[i]; - bigData[i] = NULL; + for (auto & i : bigData) { + delete i; + i = NULL; } ISaveableTester::fakeFile = ""; } @@ -435,9 +435,9 @@ public: void test_smallCache_writeBuffer() { CPUTimer tim; DiskBuffer dbuf(3); - for (size_t i = 0; i < data.size(); i++) { - dbuf.toWrite(data[i]); - data[i]->setBusy(false); + for (auto & i : data) { + dbuf.toWrite(i); + i->setBusy(false); } std::cout << " Elapsed : " << tim << " to load " << num << " into MRU.\n"; } @@ -445,13 +445,13 @@ public: void test_smallCache_no_writeBuffer() { CPUTimer tim; DiskBuffer dbuf(0); - for (size_t i = 0; i < data.size(); i++) { - data[i]->setBusy(true); // Items won't do any real saving + for (auto & i : data) { + i->setBusy(true); // Items won't do any real saving } - for (int i = 0; i < int(data.size()); i++) { - dbuf.toWrite(data[i]); - data[i]->setBusy(false); + for (auto & i : data) { + dbuf.toWrite(i); + i->setBusy(false); } std::cout << " Elapsed : " << tim << " to load " << num << " into MRU (no write cache).\n"; @@ -460,9 +460,9 @@ public: void test_largeCache_writeBuffer() { CPUTimer tim; DiskBuffer dbuf(1000); - for (int i = 0; i < int(data.size()); i++) { - dbuf.toWrite(data[i]); - data[i]->setBusy(false); + for (auto & i : data) { + dbuf.toWrite(i); + i->setBusy(false); } std::cout << tim << " to load " << num << " into MRU.\n"; } @@ -470,9 +470,9 @@ public: void test_largeCache_noWriteBuffer() { CPUTimer tim; DiskBuffer dbuf(0); - for (int i = 0; i < int(data.size()); i++) { - dbuf.toWrite(data[i]); - data[i]->setBusy(false); + for (auto & i : data) { + dbuf.toWrite(i); + i->setBusy(false); } std::cout << " Elapsed : " << tim << " to load " << num << " into MRU (no write buffer).\n"; diff --git a/Framework/Kernel/test/DiskBufferTest.h b/Framework/Kernel/test/DiskBufferTest.h index 426c375731d..625b3f048a0 100644 --- a/Framework/Kernel/test/DiskBufferTest.h +++ b/Framework/Kernel/test/DiskBufferTest.h @@ -115,9 +115,9 @@ public: } void tearDown() override { - for (size_t i = 0; i < data.size(); i++) { - delete data[i]; - data[i] = NULL; + for (auto & i : data) { + delete i; + i = NULL; } } void xest_nothing() { @@ -171,8 +171,8 @@ public: ////-------------------------------------------------------------------------------- ///** Sorts by file position when writing to a file */ void test_writesOutInFileOrder() { - for (size_t i = 0; i < data.size(); i++) { - data[i]->setDataChanged(); + for (auto & i : data) { + i->setDataChanged(); } // Room for 2 objects of size 2 in the to-write cache DiskBuffer dbuf(2 * 2); @@ -796,9 +796,9 @@ public: void test_withFakeSeeking_withWriteBuffer() { CPUTimer tim; DiskBuffer dbuf(10); - for (int i = 0; i < int(dataSeek.size()); i++) { + for (auto & i : dataSeek) { // Pretend you just loaded the data - dataSeek[i]->load(dbuf); + i->load(dbuf); } std::cout << tim << " to load " << dataSeek.size() << " into MRU with fake seeking. \n"; @@ -809,9 +809,9 @@ public: void test_withFakeSeeking_noWriteBuffer() { CPUTimer tim; DiskBuffer dbuf(0); - for (int i = 0; i < int(dataSeek.size()); i++) { + for (auto & i : dataSeek) { // Pretend you just loaded the data - dataSeek[i]->load(dbuf); + i->load(dbuf); } std::cout << tim << " to load " << dataSeek.size() << " into MRU with fake seeking. \n"; @@ -823,10 +823,10 @@ public: CPUTimer tim; DiskBuffer dbuf(20); dbuf.setFileLength(dataSeek.size()); - for (int i = 0; i < int(dataSeek.size()); i++) { + for (auto & i : dataSeek) { // Pretend you just loaded the data - dataSeek[i]->grow(dbuf, true); - dbuf.toWrite(dataSeek[i]); + i->grow(dbuf, true); + dbuf.toWrite(i); } std::cout << "About to flush the cache to finish writes.\n"; dbuf.flushCache(); @@ -840,10 +840,10 @@ public: void test_withFakeSeeking_growingData_savingWithoutUsingMRU() { CPUTimer tim; DiskBuffer dbuf(dataSeek.size()); - for (int i = 0; i < int(dataSeek.size()); i++) { + for (auto & i : dataSeek) { // Pretend you just loaded the data - dataSeek[i]->grow(dbuf, false); - dataSeek[i]->save(); + i->grow(dbuf, false); + i->save(); } std::cout << tim << " to grow " << dataSeek.size() << " into MRU with fake seeking. \n"; diff --git a/Framework/Kernel/test/FileDescriptorTest.h b/Framework/Kernel/test/FileDescriptorTest.h index ec7856f06e1..d2b6f00072d 100644 --- a/Framework/Kernel/test/FileDescriptorTest.h +++ b/Framework/Kernel/test/FileDescriptorTest.h @@ -23,14 +23,14 @@ public: auto &cfg = Mantid::Kernel::ConfigService::Instance(); cfg.reset(); const auto &dataPaths = cfg.getDataSearchDirs(); - for (auto it = dataPaths.begin(); it != dataPaths.end(); ++it) { - Poco::Path nxsPath(*it, "CNCS_7860_event.nxs"); + for (const auto & dataPath : dataPaths) { + Poco::Path nxsPath(dataPath, "CNCS_7860_event.nxs"); if (Poco::File(nxsPath).exists()) m_testNexusPath = nxsPath.toString(); - Poco::Path nonNxsPath(*it, "CSP79590.raw"); + Poco::Path nonNxsPath(dataPath, "CSP79590.raw"); if (Poco::File(nonNxsPath).exists()) m_testNonNexusPath = nonNxsPath.toString(); - Poco::Path asciiPath(*it, "AsciiExample.txt"); + Poco::Path asciiPath(dataPath, "AsciiExample.txt"); if (Poco::File(asciiPath).exists()) m_testAsciiPath = asciiPath.toString(); diff --git a/Framework/Kernel/test/GlobTest.h b/Framework/Kernel/test/GlobTest.h index 1908edbff8e..c2ff7e21d6c 100644 --- a/Framework/Kernel/test/GlobTest.h +++ b/Framework/Kernel/test/GlobTest.h @@ -34,9 +34,8 @@ public: TS_ASSERT(files.size() > 0); size_t matches = 0; - for (std::set<std::string>::const_iterator f = files.begin(); - f != files.end(); ++f) { - Poco::Path path = *f; + for (const auto & file : files) { + Poco::Path path = file; std::string project = path[path.depth() - 1]; if (project == "API") ++matches; @@ -96,9 +95,8 @@ public: TS_ASSERT(files.size() > 0); size_t matches = 0; - for (std::set<std::string>::const_iterator f = files.begin(); - f != files.end(); ++f) { - Poco::Path path = *f; + for (const auto & file : files) { + Poco::Path path = file; std::string project = path[path.depth() - 1]; if (project == "API") ++matches; diff --git a/Framework/Kernel/test/InterpolationTest.h b/Framework/Kernel/test/InterpolationTest.h index a2ed45e607b..a54e36bb57a 100644 --- a/Framework/Kernel/test/InterpolationTest.h +++ b/Framework/Kernel/test/InterpolationTest.h @@ -206,13 +206,13 @@ public: Interpolation interpolationOne; interpolationOne.addPoint(200, 2.0); - for (size_t i = 0; i < m_tableXValues.size(); ++i) { + for (double m_tableXValue : m_tableXValues) { // When there are zero values in the interpolation, it returns 0.0 - checkValue(interpolationZero, m_tableXValues[i], 0.0, + checkValue(interpolationZero, m_tableXValue, 0.0, "zero interpolation values"); // With one value, it returns this one value for any x. - checkValue(interpolationOne, m_tableXValues[i], 2.0, + checkValue(interpolationOne, m_tableXValue, 2.0, "one interpolation value"); } } diff --git a/Framework/Kernel/test/MutexTest.h b/Framework/Kernel/test/MutexTest.h index b823f9e03fc..a7398f7569d 100644 --- a/Framework/Kernel/test/MutexTest.h +++ b/Framework/Kernel/test/MutexTest.h @@ -24,8 +24,7 @@ void reader() { Poco::ScopedReadRWLock lock(_access); // std::cout << "Read launching\n"; // do work here, without anyone having exclusive access - for (size_t i = 0; i < shared_data.size(); i++) { - double val = shared_data[i]; + for (double val : shared_data) { UNUSED_ARG(val) } // std::cout << "Read finished\n"; @@ -38,8 +37,8 @@ void unconditional_writer() { // do work here, with exclusive access shared_data.resize(shared_data.size() + 1, 2.345); // Dumb thing to slow down the writer - for (size_t i = 0; i < shared_data.size(); i++) - shared_data[i] = 4.567; + for (double & i : shared_data) + i = 4.567; // std::cout << "Write finished\n"; } diff --git a/Framework/Kernel/test/NDPseudoRandomNumberGeneratorTest.h b/Framework/Kernel/test/NDPseudoRandomNumberGeneratorTest.h index 18de5157a0f..197da2111b8 100644 --- a/Framework/Kernel/test/NDPseudoRandomNumberGeneratorTest.h +++ b/Framework/Kernel/test/NDPseudoRandomNumberGeneratorTest.h @@ -38,8 +38,8 @@ public: const double start(2.1), end(3.4); NDGenerator_sptr ndRand = createTestGenerator(12345, start, end); std::vector<double> firstPoint = ndRand->nextPoint(); - for (size_t i = 0; i < firstPoint.size(); ++i) { - TS_ASSERT(firstPoint[i] >= start && firstPoint[i] <= end); + for (double i : firstPoint) { + TS_ASSERT(i >= start && i <= end); } } diff --git a/Framework/Kernel/test/NexusDescriptorTest.h b/Framework/Kernel/test/NexusDescriptorTest.h index bf8f8944637..696985dc9b4 100644 --- a/Framework/Kernel/test/NexusDescriptorTest.h +++ b/Framework/Kernel/test/NexusDescriptorTest.h @@ -28,16 +28,16 @@ public: NexusDescriptorTest() { using Mantid::Kernel::ConfigService; auto dataPaths = ConfigService::Instance().getDataSearchDirs(); - for (auto it = dataPaths.begin(); it != dataPaths.end(); ++it) { - Poco::Path hdf5Path(*it, "CNCS_7860_event.nxs"); + for (auto & dataPath : dataPaths) { + Poco::Path hdf5Path(dataPath, "CNCS_7860_event.nxs"); if (Poco::File(hdf5Path).exists()) m_testHDF5Path = hdf5Path.toString(); - Poco::Path hdf4Path(*it, "argus0026287.nxs"); + Poco::Path hdf4Path(dataPath, "argus0026287.nxs"); if (Poco::File(hdf4Path).exists()) m_testHDF4Path = hdf4Path.toString(); - Poco::Path nonhdf5Path(*it, "CSP79590.raw"); + Poco::Path nonhdf5Path(dataPath, "CSP79590.raw"); if (Poco::File(nonhdf5Path).exists()) m_testNonHDFPath = nonhdf5Path.toString(); diff --git a/Framework/Kernel/test/PropertyManagerTest.h b/Framework/Kernel/test/PropertyManagerTest.h index 926c339d284..4548303b8db 100644 --- a/Framework/Kernel/test/PropertyManagerTest.h +++ b/Framework/Kernel/test/PropertyManagerTest.h @@ -90,12 +90,12 @@ public: TS_ASSERT_EQUALS(manager.propertyCount(), 3); const std::vector<Property *> &props = manager.getProperties(); - for (auto iter = props.begin(); iter != props.end(); ++iter) { - Property *prop = *iter; + for (auto iter : props) { + Property *prop = iter; std::string msg = "Property " + prop->name() + " has not been changed to a FilteredTimeSeries"; auto filteredProp = - dynamic_cast<FilteredTimeSeriesProperty<double> *>(*iter); + dynamic_cast<FilteredTimeSeriesProperty<double> *>(iter); TSM_ASSERT(msg, filteredProp); } diff --git a/Framework/Kernel/test/PropertyWithValueTest.h b/Framework/Kernel/test/PropertyWithValueTest.h index 0dd1155b140..f6ece0cd2a9 100644 --- a/Framework/Kernel/test/PropertyWithValueTest.h +++ b/Framework/Kernel/test/PropertyWithValueTest.h @@ -690,9 +690,9 @@ public: auto values = property.allowedValues(); auto possibilities = OptionalBool::strToEmumMap(); TSM_ASSERT_EQUALS("3 states allowed", possibilities.size(), values.size()); - for (auto it = values.begin(); it != values.end(); ++it) { + for (auto & value : values) { TSM_ASSERT("value not a known state", - possibilities.find(*it) != possibilities.end()); + possibilities.find(value) != possibilities.end()); } } diff --git a/Framework/Kernel/test/SobolSequenceTest.h b/Framework/Kernel/test/SobolSequenceTest.h index 0a61b278d64..f1cd582dc04 100644 --- a/Framework/Kernel/test/SobolSequenceTest.h +++ b/Framework/Kernel/test/SobolSequenceTest.h @@ -87,10 +87,10 @@ private: {0.75, 0.25, 0.75, 0.25, 0.75}, {0.25, 0.75, 0.25, 0.75, 0.25}, }; - for (std::size_t i = 0; i < 3; ++i) { + for (auto & expectedValue : expectedValues) { const std::vector<double> randPoint = randGen.nextPoint(); for (std::size_t j = 0; j < 5; ++j) { - TS_ASSERT_DELTA(randPoint[j], expectedValues[i][j], 1e-12); + TS_ASSERT_DELTA(randPoint[j], expectedValue[j], 1e-12); } } } diff --git a/Framework/Kernel/test/ThreadSchedulerTest.h b/Framework/Kernel/test/ThreadSchedulerTest.h index 587bb4e5707..dd55283e826 100644 --- a/Framework/Kernel/test/ThreadSchedulerTest.h +++ b/Framework/Kernel/test/ThreadSchedulerTest.h @@ -87,8 +87,8 @@ public: // And ThreadScheduler does not delete popped tasks in this way TS_ASSERT_EQUALS(ThreadSchedulerTest_numDestructed, 0); - for (size_t i = 0; i < 4; i++) { - delete tasks[i]; + for (auto & task : tasks) { + delete task; } } diff --git a/Framework/Kernel/test/UsageServiceTest.h b/Framework/Kernel/test/UsageServiceTest.h index fbf3fbf4f1b..20e3b45b795 100644 --- a/Framework/Kernel/test/UsageServiceTest.h +++ b/Framework/Kernel/test/UsageServiceTest.h @@ -101,11 +101,11 @@ public: } auto features = root["features"]; - for (Json::ArrayIndex i = 0; i < features.size(); i++) { - std::string name = features[i]["name"].asString(); - std::string type = features[i]["type"].asString(); - bool internal = features[i]["internal"].asBool(); - size_t count = features[i]["count"].asUInt(); + for (auto & feature : features) { + std::string name = feature["name"].asString(); + std::string type = feature["type"].asString(); + bool internal = feature["internal"].asBool(); + size_t count = feature["count"].asUInt(); bool correct = false; diff --git a/Framework/LiveData/src/Kafka/private/Schema/flatbuffers/flatbuffers.h b/Framework/LiveData/src/Kafka/private/Schema/flatbuffers/flatbuffers.h index 2c57e5aa153..6ce57b8f32b 100644 --- a/Framework/LiveData/src/Kafka/private/Schema/flatbuffers/flatbuffers.h +++ b/Framework/LiveData/src/Kafka/private/Schema/flatbuffers/flatbuffers.h @@ -757,11 +757,11 @@ FLATBUFFERS_FINAL_CLASS auto vt_use = GetSize(); // See if we already have generated a vtable with this exact same // layout before. If so, make it point to the old one, remove this one. - for (auto it = vtables_.begin(); it != vtables_.end(); ++it) { - auto vt2 = reinterpret_cast<voffset_t *>(buf_.data_at(*it)); + for (unsigned int & vtable : vtables_) { + auto vt2 = reinterpret_cast<voffset_t *>(buf_.data_at(vtable)); auto vt2_size = *vt2; if (vt1_size != vt2_size || memcmp(vt2, vt1, vt1_size)) continue; - vt_use = *it; + vt_use = vtable; buf_.pop(GetSize() - vtableoffsetloc); break; } diff --git a/Framework/LiveData/test/LoadLiveDataTest.h b/Framework/LiveData/test/LoadLiveDataTest.h index 028cf8db44b..a552491427b 100644 --- a/Framework/LiveData/test/LoadLiveDataTest.h +++ b/Framework/LiveData/test/LoadLiveDataTest.h @@ -180,8 +180,8 @@ public: TS_ASSERT_EQUALS(ws1->getNumberHistograms(), 2); double total; total = 0; - for (auto it = ws1->readY(0).begin(); it != ws1->readY(0).end(); it++) - total += *it; + for (double it : ws1->readY(0)) + total += it; TS_ASSERT_DELTA(total, 100.0, 1e-4); // Next one adds the histograms together @@ -191,8 +191,8 @@ public: // The new total signal is 200.0 total = 0; - for (auto it = ws1->readY(0).begin(); it != ws1->readY(0).end(); it++) - total += *it; + for (double it : ws1->readY(0)) + total += it; TS_ASSERT_DELTA(total, 200.0, 1e-4); TSM_ASSERT("Workspace being added stayed the same pointer", ws1 == ws2); diff --git a/Framework/MDAlgorithms/test/LoadMDTest.h b/Framework/MDAlgorithms/test/LoadMDTest.h index 00394b57497..9247ee9a1ff 100644 --- a/Framework/MDAlgorithms/test/LoadMDTest.h +++ b/Framework/MDAlgorithms/test/LoadMDTest.h @@ -253,8 +253,8 @@ public: typename std::vector<API::IMDNode *> boxes; ws->getBox()->getBoxes(boxes, 1000, false); - for (size_t i = 0; i < boxes.size(); i++) { - MDBox<MDE, nd> *box = dynamic_cast<MDBox<MDE, nd> *>(boxes[i]); + for (auto & boxe : boxes) { + MDBox<MDE, nd> *box = dynamic_cast<MDBox<MDE, nd> *>(boxe); if (box) { TSM_ASSERT("Large box should not be in memory", box->getISaveable()->getDataMemorySize() == 0); diff --git a/Framework/MDAlgorithms/test/MDTransfModQTest.h b/Framework/MDAlgorithms/test/MDTransfModQTest.h index 8d4abe7cf82..1178b956b15 100644 --- a/Framework/MDAlgorithms/test/MDTransfModQTest.h +++ b/Framework/MDAlgorithms/test/MDTransfModQTest.h @@ -108,8 +108,8 @@ public: // the detectors parameters MDTransf.calcYDepCoordinates(locCoord, i); - for (size_t k = 0; k < range.size(); k++) { - MDTransf.calcMatrixCoord(range[k], locCoord, signal, errorSq); + for (double k : range) { + MDTransf.calcMatrixCoord(k, locCoord, signal, errorSq); for (size_t j = 0; j < nDims; j++) { if (locCoord[j] < minCoord[j]) minCoord[j] = locCoord[j]; diff --git a/Framework/MDAlgorithms/test/MDTransfQ3DTest.h b/Framework/MDAlgorithms/test/MDTransfQ3DTest.h index cfe87617ea4..9e544bdfbab 100644 --- a/Framework/MDAlgorithms/test/MDTransfQ3DTest.h +++ b/Framework/MDAlgorithms/test/MDTransfQ3DTest.h @@ -116,8 +116,8 @@ public: // testing purposes here auto &TwoTheta = const_cast<std::vector<double> &>( WSDescr.m_PreprDetTable->getColVector<double>("TwoTheta")); - for (size_t i = 0; i < TwoTheta.size(); i++) { - TwoTheta[i] = 0; + for (double & i : TwoTheta) { + i = 0; } TSM_ASSERT_THROWS_NOTHING("should initialize properly: ", diff --git a/Framework/MDAlgorithms/test/MergeMDFilesTest.h b/Framework/MDAlgorithms/test/MergeMDFilesTest.h index b62604f3fb8..3ce1e665ca3 100644 --- a/Framework/MDAlgorithms/test/MergeMDFilesTest.h +++ b/Framework/MDAlgorithms/test/MergeMDFilesTest.h @@ -102,11 +102,11 @@ public: } // Cleanup generated input files - for (size_t i = 0; i < inWorkspaces.size(); i++) { - if (inWorkspaces[i]->getBoxController()->isFileBacked()) { + for (auto & inWorkspace : inWorkspaces) { + if (inWorkspace->getBoxController()->isFileBacked()) { std::string fileName = - inWorkspaces[i]->getBoxController()->getFileIO()->getFileName(); - inWorkspaces[i]->clearFileBacked(false); + inWorkspace->getBoxController()->getFileIO()->getFileName(); + inWorkspace->clearFileBacked(false); Poco::File(fileName).remove(); } } diff --git a/Framework/MDAlgorithms/test/ReplicateMDTest.h b/Framework/MDAlgorithms/test/ReplicateMDTest.h index 56b24e96f43..5b31f6aa02d 100644 --- a/Framework/MDAlgorithms/test/ReplicateMDTest.h +++ b/Framework/MDAlgorithms/test/ReplicateMDTest.h @@ -77,8 +77,8 @@ MDHistoWorkspace_sptr makeHistoWorkspace(const std::vector<int> &shape, // Generate the axis order 0, 1, 2 ... in reverse std::vector<int> axes(outWs->getNumDims()); Decreasing op(outWs->getNumDims()); - for (auto it = axes.begin(); it != axes.end(); ++it) { - *it = static_cast<int>(op()); + for (int & axe : axes) { + axe = static_cast<int>(op()); } IAlgorithm *transpose = diff --git a/Framework/MDAlgorithms/test/TobyFitYVectorTest.h b/Framework/MDAlgorithms/test/TobyFitYVectorTest.h index 249061f556a..c1300285c2a 100644 --- a/Framework/MDAlgorithms/test/TobyFitYVectorTest.h +++ b/Framework/MDAlgorithms/test/TobyFitYVectorTest.h @@ -45,8 +45,8 @@ public: "DetectorArea", "DetectionTime"}; TobyFitYVector yVector; - for (unsigned int i = 0; i < 8; ++i) { - yVector.setAttribute(attrs[i], IFunction::Attribute(false)); + for (auto & attr : attrs) { + yVector.setAttribute(attr, IFunction::Attribute(false)); } std::vector<double> randNums(yVector.requiredRandomNums(), 0.5); diff --git a/Framework/MDAlgorithms/test/TransformMDTest.h b/Framework/MDAlgorithms/test/TransformMDTest.h index 6ecf6571f7b..dfa6a35e8ad 100644 --- a/Framework/MDAlgorithms/test/TransformMDTest.h +++ b/Framework/MDAlgorithms/test/TransformMDTest.h @@ -64,8 +64,7 @@ public: } std::vector<API::IMDNode *> boxes; ws2->getBox()->getBoxes(boxes, 1000, true); - for (size_t i = 0; i < boxes.size(); i++) { - API::IMDNode *box = boxes[i]; + for (auto box : boxes) { TSM_ASSERT_LESS_THAN("Box extents was offset", 20.0, box->getExtents(0).getMin()); // More detailed tests are in MDBox, MDBoxBase and MDGridBox. diff --git a/Framework/PythonInterface/mantid/dataobjects/src/Exports/Workspace2D.cpp b/Framework/PythonInterface/mantid/dataobjects/src/Exports/Workspace2D.cpp index ec12497997c..3428d41720e 100644 --- a/Framework/PythonInterface/mantid/dataobjects/src/Exports/Workspace2D.cpp +++ b/Framework/PythonInterface/mantid/dataobjects/src/Exports/Workspace2D.cpp @@ -72,8 +72,8 @@ public: const auto &spectrumDefinition = (*spectrumDefinitions)[i]; std::vector<size_t> detectorIndices; - for (size_t j = 0; j < spectrumDefinition.size(); ++j) { - size_t detectorIndex = spectrumDefinition[j].first; + for (const auto & j : spectrumDefinition) { + size_t detectorIndex = j.first; detectorIndices.emplace_back(std::move(detectorIndex)); } @@ -133,8 +133,7 @@ public: ws.setBinEdges(i, std::move(binEdgeData)); SpectrumDefinition specDef; - for (size_t j = 0; j < detectorIndices.size(); ++j) { - size_t detectorIndex = detectorIndices[j]; + for (unsigned long detectorIndex : detectorIndices) { specDef.add(detectorIndex); } spectrumDefinitions.emplace_back(std::move(specDef)); diff --git a/Framework/RemoteAlgorithms/test/AbortRemoteJob2Test.h b/Framework/RemoteAlgorithms/test/AbortRemoteJob2Test.h index 747c3af568c..abe11c33947 100644 --- a/Framework/RemoteAlgorithms/test/AbortRemoteJob2Test.h +++ b/Framework/RemoteAlgorithms/test/AbortRemoteJob2Test.h @@ -98,9 +98,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); AbortRemoteJob2 ab; diff --git a/Framework/RemoteAlgorithms/test/AbortRemoteJobTest.h b/Framework/RemoteAlgorithms/test/AbortRemoteJobTest.h index 3bf0389ec81..736f7e6754c 100644 --- a/Framework/RemoteAlgorithms/test/AbortRemoteJobTest.h +++ b/Framework/RemoteAlgorithms/test/AbortRemoteJobTest.h @@ -96,9 +96,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); AbortRemoteJob ab; diff --git a/Framework/RemoteAlgorithms/test/Authenticate2Test.h b/Framework/RemoteAlgorithms/test/Authenticate2Test.h index 8e048de0530..06598bbd37e 100644 --- a/Framework/RemoteAlgorithms/test/Authenticate2Test.h +++ b/Framework/RemoteAlgorithms/test/Authenticate2Test.h @@ -99,9 +99,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); Authenticate2 auth; diff --git a/Framework/RemoteAlgorithms/test/AuthenticateTest.h b/Framework/RemoteAlgorithms/test/AuthenticateTest.h index 1014fded63a..a97743e4ac5 100644 --- a/Framework/RemoteAlgorithms/test/AuthenticateTest.h +++ b/Framework/RemoteAlgorithms/test/AuthenticateTest.h @@ -99,9 +99,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); Authenticate auth; diff --git a/Framework/RemoteAlgorithms/test/DownloadRemoteFile2Test.h b/Framework/RemoteAlgorithms/test/DownloadRemoteFile2Test.h index 41ded2ee0ca..f363a03a0dc 100644 --- a/Framework/RemoteAlgorithms/test/DownloadRemoteFile2Test.h +++ b/Framework/RemoteAlgorithms/test/DownloadRemoteFile2Test.h @@ -104,9 +104,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); DownloadRemoteFile2 dl; diff --git a/Framework/RemoteAlgorithms/test/DownloadRemoteFileTest.h b/Framework/RemoteAlgorithms/test/DownloadRemoteFileTest.h index 4b18bde6ea7..6a4ea25a11d 100644 --- a/Framework/RemoteAlgorithms/test/DownloadRemoteFileTest.h +++ b/Framework/RemoteAlgorithms/test/DownloadRemoteFileTest.h @@ -104,9 +104,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); DownloadRemoteFile dl; diff --git a/Framework/RemoteAlgorithms/test/Logout2Test.h b/Framework/RemoteAlgorithms/test/Logout2Test.h index 1b337710d58..e82b20c07bb 100644 --- a/Framework/RemoteAlgorithms/test/Logout2Test.h +++ b/Framework/RemoteAlgorithms/test/Logout2Test.h @@ -72,9 +72,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); // test that job managers are created correctly for different facilities - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); Logout2 lo; diff --git a/Framework/RemoteAlgorithms/test/QueryAllRemoteJobs2Test.h b/Framework/RemoteAlgorithms/test/QueryAllRemoteJobs2Test.h index b845d38a213..974ddcf5de7 100644 --- a/Framework/RemoteAlgorithms/test/QueryAllRemoteJobs2Test.h +++ b/Framework/RemoteAlgorithms/test/QueryAllRemoteJobs2Test.h @@ -81,9 +81,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); QueryAllRemoteJobs2 qar; diff --git a/Framework/RemoteAlgorithms/test/QueryAllRemoteJobsTest.h b/Framework/RemoteAlgorithms/test/QueryAllRemoteJobsTest.h index 1d00df8c2c2..24b019db26a 100644 --- a/Framework/RemoteAlgorithms/test/QueryAllRemoteJobsTest.h +++ b/Framework/RemoteAlgorithms/test/QueryAllRemoteJobsTest.h @@ -81,9 +81,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); QueryAllRemoteJobs qar; diff --git a/Framework/RemoteAlgorithms/test/QueryRemoteFile2Test.h b/Framework/RemoteAlgorithms/test/QueryRemoteFile2Test.h index 691e371466f..24bf506ac8a 100644 --- a/Framework/RemoteAlgorithms/test/QueryRemoteFile2Test.h +++ b/Framework/RemoteAlgorithms/test/QueryRemoteFile2Test.h @@ -91,9 +91,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); QueryRemoteFile2 qrf; diff --git a/Framework/RemoteAlgorithms/test/QueryRemoteFileTest.h b/Framework/RemoteAlgorithms/test/QueryRemoteFileTest.h index 46d71b39742..a5815b0fb52 100644 --- a/Framework/RemoteAlgorithms/test/QueryRemoteFileTest.h +++ b/Framework/RemoteAlgorithms/test/QueryRemoteFileTest.h @@ -91,9 +91,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); QueryRemoteFile qrf; diff --git a/Framework/RemoteAlgorithms/test/QueryRemoteJob2Test.h b/Framework/RemoteAlgorithms/test/QueryRemoteJob2Test.h index d8863c6d5d8..86e883c8816 100644 --- a/Framework/RemoteAlgorithms/test/QueryRemoteJob2Test.h +++ b/Framework/RemoteAlgorithms/test/QueryRemoteJob2Test.h @@ -90,9 +90,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); QueryRemoteJob2 qr; diff --git a/Framework/RemoteAlgorithms/test/QueryRemoteJobTest.h b/Framework/RemoteAlgorithms/test/QueryRemoteJobTest.h index c5d2ea8d430..6a69b96c347 100644 --- a/Framework/RemoteAlgorithms/test/QueryRemoteJobTest.h +++ b/Framework/RemoteAlgorithms/test/QueryRemoteJobTest.h @@ -88,9 +88,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); QueryRemoteJob qr; diff --git a/Framework/RemoteAlgorithms/test/StartRemoteTransaction2Test.h b/Framework/RemoteAlgorithms/test/StartRemoteTransaction2Test.h index ffadba3eac9..1bedb44460e 100644 --- a/Framework/RemoteAlgorithms/test/StartRemoteTransaction2Test.h +++ b/Framework/RemoteAlgorithms/test/StartRemoteTransaction2Test.h @@ -91,9 +91,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); StartRemoteTransaction2 start; diff --git a/Framework/RemoteAlgorithms/test/StartRemoteTransactionTest.h b/Framework/RemoteAlgorithms/test/StartRemoteTransactionTest.h index 27a2dfa80f5..e11385298fe 100644 --- a/Framework/RemoteAlgorithms/test/StartRemoteTransactionTest.h +++ b/Framework/RemoteAlgorithms/test/StartRemoteTransactionTest.h @@ -91,9 +91,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); StartRemoteTransaction start; diff --git a/Framework/RemoteAlgorithms/test/StopRemoteTransaction2Test.h b/Framework/RemoteAlgorithms/test/StopRemoteTransaction2Test.h index 9153fe74d25..964b3c5c9bd 100644 --- a/Framework/RemoteAlgorithms/test/StopRemoteTransaction2Test.h +++ b/Framework/RemoteAlgorithms/test/StopRemoteTransaction2Test.h @@ -93,9 +93,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); StopRemoteTransaction2 stop; diff --git a/Framework/RemoteAlgorithms/test/StopRemoteTransactionTest.h b/Framework/RemoteAlgorithms/test/StopRemoteTransactionTest.h index 75c87b5ddeb..ec615a436b6 100644 --- a/Framework/RemoteAlgorithms/test/StopRemoteTransactionTest.h +++ b/Framework/RemoteAlgorithms/test/StopRemoteTransactionTest.h @@ -93,9 +93,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); StopRemoteTransaction stop; diff --git a/Framework/RemoteAlgorithms/test/SubmitRemoteJob2Test.h b/Framework/RemoteAlgorithms/test/SubmitRemoteJob2Test.h index 8e1ef644caf..21d70f84905 100644 --- a/Framework/RemoteAlgorithms/test/SubmitRemoteJob2Test.h +++ b/Framework/RemoteAlgorithms/test/SubmitRemoteJob2Test.h @@ -157,9 +157,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); diff --git a/Framework/RemoteAlgorithms/test/SubmitRemoteJobTest.h b/Framework/RemoteAlgorithms/test/SubmitRemoteJobTest.h index 520cb3d0ca8..4f6feaa998c 100644 --- a/Framework/RemoteAlgorithms/test/SubmitRemoteJobTest.h +++ b/Framework/RemoteAlgorithms/test/SubmitRemoteJobTest.h @@ -157,9 +157,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); diff --git a/Framework/RemoteAlgorithms/test/UploadRemoteFile2Test.h b/Framework/RemoteAlgorithms/test/UploadRemoteFile2Test.h index ebdd6c318fd..afa835e060d 100644 --- a/Framework/RemoteAlgorithms/test/UploadRemoteFile2Test.h +++ b/Framework/RemoteAlgorithms/test/UploadRemoteFile2Test.h @@ -124,9 +124,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); diff --git a/Framework/RemoteAlgorithms/test/UploadRemoteFileTest.h b/Framework/RemoteAlgorithms/test/UploadRemoteFileTest.h index 2b0f241c2a6..4f6e5f4d2fe 100644 --- a/Framework/RemoteAlgorithms/test/UploadRemoteFileTest.h +++ b/Framework/RemoteAlgorithms/test/UploadRemoteFileTest.h @@ -124,9 +124,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto & testFacilitie : testFacilities) { + const std::string facName = testFacilitie.first; + const std::string compName = testFacilitie.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); diff --git a/Framework/SINQ/test/PoldiFitPeaks1D2Test.h b/Framework/SINQ/test/PoldiFitPeaks1D2Test.h index e4fd2201eee..d57dc748f2f 100644 --- a/Framework/SINQ/test/PoldiFitPeaks1D2Test.h +++ b/Framework/SINQ/test/PoldiFitPeaks1D2Test.h @@ -100,8 +100,8 @@ public: std::vector<Property *> properties = fitPeaks1D.getProperties(); std::unordered_set<std::string> names; - for (size_t i = 0; i < properties.size(); ++i) { - names.insert(properties[i]->name()); + for (auto & propertie : properties) { + names.insert(propertie->name()); } TS_ASSERT_EQUALS(names.count("InputWorkspace"), 1); diff --git a/Framework/SINQ/test/PoldiFitPeaks1DTest.h b/Framework/SINQ/test/PoldiFitPeaks1DTest.h index 5fef57ec078..ced33c07ade 100644 --- a/Framework/SINQ/test/PoldiFitPeaks1DTest.h +++ b/Framework/SINQ/test/PoldiFitPeaks1DTest.h @@ -102,8 +102,8 @@ public: std::vector<Property *> properties = fitPeaks1D.getProperties(); std::unordered_set<std::string> names; - for (size_t i = 0; i < properties.size(); ++i) { - names.insert(properties[i]->name()); + for (auto & propertie : properties) { + names.insert(propertie->name()); } TS_ASSERT_EQUALS(names.count("InputWorkspace"), 1); diff --git a/Framework/SINQ/test/PoldiIndexKnownCompoundsTest.h b/Framework/SINQ/test/PoldiIndexKnownCompoundsTest.h index b0906c2fa91..053f06a7d7c 100644 --- a/Framework/SINQ/test/PoldiIndexKnownCompoundsTest.h +++ b/Framework/SINQ/test/PoldiIndexKnownCompoundsTest.h @@ -669,9 +669,9 @@ private: } void storeRandomWorkspaces(const std::vector<std::string> &wsNames) { - for (auto it = wsNames.begin(); it != wsNames.end(); ++it) { + for (const auto & wsName : wsNames) { WorkspaceCreationHelper::storeWS( - *it, WorkspaceCreationHelper::create1DWorkspaceRand(10, true)); + wsName, WorkspaceCreationHelper::create1DWorkspaceRand(10, true)); } } @@ -684,8 +684,8 @@ private: } void removeRandomWorkspaces(const std::vector<std::string> &wsNames) { - for (auto it = wsNames.begin(); it != wsNames.end(); ++it) { - WorkspaceCreationHelper::removeWS(*it); + for (const auto & wsName : wsNames) { + WorkspaceCreationHelper::removeWS(wsName); } } diff --git a/Framework/SINQ/test/PoldiPeakSearchTest.h b/Framework/SINQ/test/PoldiPeakSearchTest.h index 6cf85b25ef8..4b670f6df36 100644 --- a/Framework/SINQ/test/PoldiPeakSearchTest.h +++ b/Framework/SINQ/test/PoldiPeakSearchTest.h @@ -123,10 +123,9 @@ public: std::vector<double> testXData(testYData.size()); double x = 0.0; - for (std::vector<double>::iterator iterX = testXData.begin(); - iterX != testXData.end(); ++iterX) { + for (double & iterX : testXData) { x += 1.0; - *iterX = x; + iterX = x; } std::list<std::vector<double>::const_iterator> maxima = diff --git a/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h b/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h index 48098cfef3b..44a94d0db42 100644 --- a/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h +++ b/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h @@ -363,8 +363,8 @@ public: TS_ASSERT_THROWS_NOTHING(list_files = repo->listFiles()); TS_ASSERT(list_files.size() == 5); // check that all the files at the central repository are inside - for (int i = 0; i < 5; i++) - TSM_ASSERT_THROWS_NOTHING(test_entries[i], repo->info(test_entries[i])); + for (auto & test_entrie : test_entries) + TSM_ASSERT_THROWS_NOTHING(test_entrie, repo->info(test_entrie)); } /** @@ -478,9 +478,8 @@ public: TS_ASSERT_THROWS_NOTHING(list_of_files = repo->listFiles()); std::cout << "After update, the files are: "; - for (std::vector<string>::iterator it = list_of_files.begin(); - it != list_of_files.end(); it++) { - std::cout << *it << ", "; + for (auto & list_of_file : list_of_files) { + std::cout << list_of_file << ", "; } std::cout << '\n'; TS_ASSERT(list_of_files.size() == 1); -- GitLab