Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 21, 2015, 7:05:53 PM (9 years ago)
Author:
muemart
Message:

Run clang-modernize -loop-convert

  • Again, not all possible loops were converted
  • It can do pretty cool transformations, but I had to fix a few compile errors, so there might be some runtime errors lurking around too
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/orxonox/weaponsystem/WeaponPack.cc

    r10768 r10821  
    7676    void WeaponPack::fire(unsigned int weaponmode)
    7777    {
    78         for (std::vector<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
    79             (*it)->fire(weaponmode);
     78        for (auto & elem : this->weapons_)
     79            (elem)->fire(weaponmode);
    8080    }
    8181
     
    8686    void WeaponPack::reload()
    8787    {
    88         for (std::vector<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
    89             (*it)->reload();
     88        for (auto & elem : this->weapons_)
     89            (elem)->reload();
    9090    }
    9191
     
    114114        unsigned int i = 0;
    115115
    116         for (std::vector<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
     116        for (const auto & elem : this->weapons_)
    117117        {
    118118            if (i == index)
    119                 return (*it);
     119                return (elem);
    120120            ++i;
    121121        }
     
    132132    {
    133133        unsigned int i = 0;
    134         for (std::set<DefaultWeaponmodeLink*>::const_iterator it = this->links_.begin(); it != this->links_.end(); ++it)
     134        for (const auto & elem : this->links_)
    135135        {
    136136            if (i == index)
    137                 return (*it);
     137                return (elem);
    138138
    139139            ++i;
     
    144144    unsigned int WeaponPack::getDesiredWeaponmode(unsigned int firemode) const
    145145    {
    146         for (std::set<DefaultWeaponmodeLink*>::const_iterator it = this->links_.begin(); it != this->links_.end(); ++it)
    147             if ((*it)->getFiremode() == firemode)
    148                 return (*it)->getWeaponmode();
     146        for (const auto & elem : this->links_)
     147            if ((elem)->getFiremode() == firemode)
     148                return (elem)->getWeaponmode();
    149149
    150150        return WeaponSystem::WEAPON_MODE_UNASSIGNED;
Note: See TracChangeset for help on using the changeset viewer.