MantisBT - VCMI | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0003142 | VCMI | Other | public | 2020-10-01 00:00 | 2021-01-25 22:38 |
Reporter | jambolo | ||||
Assigned To | MikeLodz | ||||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | resolved | Resolution | fixed | ||
Platform | OS | OS Version | |||
Product Version | |||||
Target Version | Fixed in Version | 1.next | |||
Summary | 0003142: Use of const std::shared_ptr | ||||
Description | There are several instances of "const std:shared_ptr<...>" in the code. There is generally no good reason for const. I suspect that in many cases the intention is to prevent modification of the referenced object. In those cases, "const std:shared_ptr<...>" could be changed to "std:shared_ptr<const ...>" There are also many cases of "const TBonusListPtr" where TBonusListPtr is defined elsewhere by "typedef std::shared_ptr<BonusList> TBonusListPtr". These may have the same issue. In these cases, the following may be better: typedef std::shared_ptr<const BonusList> TConstBonusListPtr Note that "const std:shared_ptr<...> &" is a valid use of const. | ||||
Steps To Reproduce | vcmi\source\lib\battle\CBattleInfoCallback.cpp(752) vcmi\source\lib\battle\CBattleInfoCallback.cpp(775) vcmi\source\lib\CGameState.cpp(1901) vcmi\source\lib\CHeroHandler.cpp(595) vcmi\source\lib\CStack.cpp(145) vcmi\source\lib\HeroBonus.cpp(384) vcmi\source\lib\HeroBonus.cpp(385) vcmi\source\lib\HeroBonus.cpp(497) vcmi\source\lib\HeroBonus.cpp(781) vcmi\source\lib\HeroBonus.cpp(803) vcmi\source\lib\HeroBonus.cpp(939) vcmi\source\lib\HeroBonus.cpp(2129) vcmi\source\lib\HeroBonus.cpp(2152) vcmi\source\lib\HeroBonus.cpp(2189) vcmi\source\lib\HeroBonus.cpp(2215) vcmi\source\lib\HeroBonus.h(550) vcmi\source\lib\HeroBonus.h(553) vcmi\source\lib\HeroBonus.h(554) vcmi\source\lib\HeroBonus.h(571) vcmi\source\lib\HeroBonus.h(665) vcmi\source\lib\HeroBonus.h(710) vcmi\source\lib\HeroBonus.h(770) vcmi\source\lib\HeroBonus.h(782) vcmi\source\lib\HeroBonus.h(1168) vcmi\source\lib\HeroBonus.h(1193) vcmi\source\lib\HeroBonus.h(1208) vcmi\source\lib\HeroBonus.h(1223) vcmi\source\lib\mapObjects\CGTownInstance.cpp(560) vcmi\source\lib\mapObjects\CGTownInstance.cpp(565) vcmi\source\lib\mapObjects\MiscObjects.cpp(1425) vcmi\source\lib\serializer\CTypeList.h(167) vcmi\source\lib\battle\CUnitState.cpp(899) vcmi\source\lib\battle\CUnitState.h(271) vcmi\source\lib\HeroBonus.cpp(645) vcmi\source\lib\HeroBonus.cpp(650) vcmi\source\lib\HeroBonus.cpp(852) vcmi\source\lib\HeroBonus.cpp(905) vcmi\source\lib\HeroBonus.h(703) vcmi\source\lib\HeroBonus.h(707) vcmi\source\lib\HeroBonus.h(708) vcmi\source\lib\HeroBonus.h(769) vcmi\source\lib\HeroBonus.h(780) vcmi\source\lib\mapObjects\CGHeroInstance.cpp(819) | ||||
Additional Information | const std::shared_ptr only makes reset() and swap() inaccessible. "const std:shared_ptr<T> foo" is equivalent to "T * const foo" "std:shared_ptr<const T> foo" is equivalent to "const T * foo" See https://stackoverflow.com/questions/17793333/difference-between-const-shared-ptrt-and-shared-ptrconst-t [^] | ||||
Tags | No tags attached. | ||||
Relationships | |||||
Attached Files | |||||
Issue History | |||||
Date Modified | Username | Field | Change | ||
2020-10-01 00:00 | jambolo | New Issue | |||
2020-10-01 04:03 | jambolo | Note Added: 0007934 | |||
2020-10-01 04:42 | jambolo | Note Deleted: 0007934 | |||
2020-10-02 22:59 | jambolo | Note Added: 0007936 | |||
2020-10-02 23:00 | jambolo | Note Edited: 0007936 | bug_revision_view_page.php?bugnote_id=7936#r3609 | ||
2021-01-25 22:38 | MikeLodz | Status | new => resolved | ||
2021-01-25 22:38 | MikeLodz | Fixed in Version | => 1.next | ||
2021-01-25 22:38 | MikeLodz | Resolution | open => fixed | ||
2021-01-25 22:38 | MikeLodz | Assigned To | => MikeLodz |
Notes | |||||
|
|||||
|
|