Skip to content

Commit 5ebc734

Browse files
authored
Merge pull request #47320 from iarspider/gcc14-nodiscard
Fix improper use of std::unique and std::remove
2 parents afa07e5 + 1f409e6 commit 5ebc734

File tree

11 files changed

+24
-12
lines changed

11 files changed

+24
-12
lines changed

DQM/HLTEvF/plugins/TrigObjTnPHistColl.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ void TrigObjTnPHistColl::FilterSelector::mergeTrigKeys(trigger::Keys& keys,
122122

123123
void TrigObjTnPHistColl::FilterSelector::cleanTrigKeys(trigger::Keys& keys) {
124124
std::sort(keys.begin(), keys.end());
125-
std::unique(keys.begin(), keys.end());
125+
auto last = std::unique(keys.begin(), keys.end());
126+
keys.erase(last, keys.end());
126127
while (!keys.empty() && keys.back() == std::numeric_limits<trigger::size_type>::max()) {
127128
keys.pop_back();
128129
}

DQMOffline/RecoB/src/BTagDifferentialPlot.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ void BTagDifferentialPlot::bookHisto(DQMStore::IBooker& ibook) {
222222
stream << constVariableValue.second << "_"
223223
<< "_Vs_" << diffVariableName;
224224
commonName += stream.str();
225-
std::remove(commonName.begin(), commonName.end(), ' ');
225+
auto last = std::remove(commonName.begin(), commonName.end(), ' ');
226+
commonName.erase(last, commonName.end());
226227
std::replace(commonName.begin(), commonName.end(), '.', 'v');
227228

228229
std::string label(commonName);

DQMOffline/RecoB/src/EtaPtBin.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ std::string EtaPtBin::buildDescriptionString(const bool& etaActive_,
3434

3535
std::string descr(stream.str());
3636
// remove blanks which are introduced when adding doubles
37-
std::remove(descr.begin(), descr.end(), ' ');
37+
auto last = std::remove(descr.begin(), descr.end(), ' ');
38+
descr.erase(last, descr.end());
3839
std::replace(descr.begin(), descr.end(), '.', 'v');
3940

4041
return descr;

PhysicsTools/PatAlgos/plugins/PATElectronProducer.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,8 @@ void PATElectronProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
724724

725725
//remove duplicates
726726
std::sort(selectedCells.begin(), selectedCells.end());
727-
std::unique(selectedCells.begin(), selectedCells.end());
727+
auto last = std::unique(selectedCells.begin(), selectedCells.end());
728+
selectedCells.erase(last, selectedCells.end());
728729

729730
// Retrieve the corresponding RecHits
730731

@@ -968,7 +969,8 @@ void PATElectronProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
968969

969970
//remove duplicates
970971
std::sort(selectedCells.begin(), selectedCells.end());
971-
std::unique(selectedCells.begin(), selectedCells.end());
972+
auto last = std::unique(selectedCells.begin(), selectedCells.end());
973+
selectedCells.erase(last, selectedCells.end());
972974

973975
// Retrieve the corresponding RecHits
974976

PhysicsTools/PatAlgos/plugins/PATPhotonProducer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,8 @@ void PATPhotonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetu
417417

418418
//remove duplicates
419419
std::sort(selectedCells.begin(), selectedCells.end());
420-
std::unique(selectedCells.begin(), selectedCells.end());
420+
auto last = std::unique(selectedCells.begin(), selectedCells.end());
421+
selectedCells.erase(last, selectedCells.end());
421422

422423
// Retrieve the corresponding RecHits
423424

RecoEcal/EgammaClusterProducers/src/InterestingDetIdCollectionProducer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ void InterestingDetIdCollectionProducer::produce(edm::StreamID,
194194

195195
//unify the vector
196196
std::sort(indexToStore.begin(), indexToStore.end());
197-
std::unique(indexToStore.begin(), indexToStore.end());
197+
auto last = std::unique(indexToStore.begin(), indexToStore.end());
198+
indexToStore.erase(last, indexToStore.end());
198199

199200
iEvent.put(std::make_unique<DetIdCollection>(indexToStore), interestingDetIdCollection_);
200201
}

RecoEcal/EgammaClusterProducers/src/InterestingDetIdFromSuperClusterProducer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ void InterestingDetIdFromSuperClusterProducer::produce(edm::StreamID,
193193

194194
//unify the vector
195195
std::sort(indexToStore.begin(), indexToStore.end());
196-
std::unique(indexToStore.begin(), indexToStore.end());
196+
auto last = std::unique(indexToStore.begin(), indexToStore.end());
197+
indexToStore.erase(last, indexToStore.end());
197198

198199
auto detIdCollection = std::make_unique<DetIdCollection>(indexToStore);
199200

RecoEcal/EgammaClusterProducers/src/ReducedRecHitCollectionProducer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ void ReducedRecHitCollectionProducer::produce(edm::Event& iEvent, const edm::Eve
117117
}
118118

119119
std::sort(xtalsToStore.begin(), xtalsToStore.end());
120-
std::unique(xtalsToStore.begin(), xtalsToStore.end());
120+
auto last = std::unique(xtalsToStore.begin(), xtalsToStore.end());
121+
xtalsToStore.erase(last, xtalsToStore.end());
121122

122123
// std::cout << "New Collection " << reducedHitsCollection_ << " size is " << miniRecHitCollection->size() << " original is " << recHitsHandle->size() << std::endl;
123124
iEvent.put(std::move(miniRecHitCollection), reducedHitsCollection_);

RecoEgamma/EgammaIsolationAlgos/plugins/EgammaIsoESDetIdCollectionProducer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ void EgammaIsoESDetIdCollectionProducer::produce(edm::StreamID, edm::Event& iEve
114114

115115
//unify the vector
116116
std::sort(indexToStore.begin(), indexToStore.end());
117-
std::unique(indexToStore.begin(), indexToStore.end());
117+
auto last = std::unique(indexToStore.begin(), indexToStore.end());
118+
indexToStore.erase(last, indexToStore.end());
118119

119120
auto detIdCollection = std::make_unique<DetIdCollection>(indexToStore);
120121

RecoEgamma/EgammaIsolationAlgos/plugins/EgammaIsoHcalDetIdCollectionProducer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ void EgammaIsoHcalDetIdCollectionProducer::produce(edm::Event& iEvent, const edm
125125

126126
//unify the vector
127127
std::sort(indexToStore.begin(), indexToStore.end());
128-
std::unique(indexToStore.begin(), indexToStore.end());
128+
auto last = std::unique(indexToStore.begin(), indexToStore.end());
129+
indexToStore.erase(last, indexToStore.end());
129130

130131
auto detIdCollection = std::make_unique<DetIdCollection>(indexToStore);
131132

0 commit comments

Comments
 (0)