useStlAlgorithm: ranges algorithms + justifica returnDanglingLifetime
This commit is contained in:
1 parent
d7db02bafd
commit
822bed0748
5 files changed
+15
-25
No files matched your search
@@ -87,7 +87,7 @@ auto EntityManager::add(std::unique_ptr<Entity> entity) -> Entity* {
|
||||
entity->setEntityManager(this);
|
||||
Entity* raw = entity.get();
|
||||
entities_.push_back(std::move(entity));
|
||||
// cppcheck-suppress returnDanglingLifetime
|
||||
// cppcheck-suppress returnDanglingLifetime -- fals positiu: std::move transfereix ownership del unique_ptr al vector, però l'objecte apuntat per `raw` no es mou ni es destrueix. El punter continua vàlid mentre el vector el posseesca.
|
||||
return raw;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ auto EntityManager::addSarcophagus(std::unique_ptr<Sarcophagus> sarc) -> Sarcoph
|
||||
Sarcophagus* raw = sarc.get();
|
||||
entities_.push_back(std::move(sarc));
|
||||
++total_sarcs_;
|
||||
// cppcheck-suppress returnDanglingLifetime
|
||||
// cppcheck-suppress returnDanglingLifetime -- fals positiu: std::move transfereix ownership al vector però l'objecte no es mou. `raw` continua vàlid (vegeu `add` més amunt).
|
||||
return raw;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user