Page MenuHomeWildfire Games
Paste P208

-Wrange-loop-construct
ActivePublic

Authored by elexis on May 27 2020, 1:25 PM.
../../../source/gui/CGUI.cpp:79:43: warning: loop variable 'p' has type 'const std::pair<CStr8, IGUIObject *> &' but is initialized with type 'std::pair<const CStr8, IGUIObject *>' resulting in a copy [-Wrange-loop-construct]
for (const std::pair<CStr, IGUIObject*>& p : m_pAllObjects)
^
../../../source/gui/CGUI.cpp:79:7: note: use non-reference type 'std::pair<CStr8, IGUIObject *>' to keep the copy or type 'const std::pair<const CStr8, IGUIObject *> &' to prevent copying
for (const std::pair<CStr, IGUIObject*>& p : m_pAllObjects)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../source/gui/CGUI.cpp:82:49: warning: loop variable 'p' has type 'const std::pair<CStr8, const CGUISprite *> &' but is initialized with type 'std::pair<const CStr8, const CGUISprite *>' resulting in a copy [-Wrange-loop-construct]
for (const std::pair<CStr, const CGUISprite*>& p : m_Sprites)
^
../../../source/gui/CGUI.cpp:82:7: note: use non-reference type 'std::pair<CStr8, const CGUISprite *>' to keep the copy or type 'const std::pair<const CStr8, const CGUISprite *> &' to prevent copying
for (const std::pair<CStr, const CGUISprite*>& p : m_Sprites)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../source/ps/Hotkey.cpp:60:47: warning: loop variable 'configPair' has type 'const std::pair<CStr8, CConfigValueSet> &' (aka 'const pair<CStr8, vector<CStr8> > &') but is initialized with type 'std::pair<const CStr8, std::vector<CStr8, std::allocator<CStr8> > >' resulting in a copy [-Wrange-loop-construct]
for (const std::pair<CStr, CConfigValueSet>& configPair : g_ConfigDB.GetValuesWithPrefix(CFG_COMMAND, "hotkey."))
^
../../../source/ps/Hotkey.cpp:60:7: note: use non-reference type 'std::pair<CStr8, CConfigValueSet>' (aka 'pair<CStr8, vector<CStr8> >') to keep the copy or type 'const std::pair<const CStr8, std::vector<CStr8, std::allocator<CStr8> > > &' to prevent copying
for (const std::pair<CStr, CConfigValueSet>& configPair : g_ConfigDB.GetValuesWithPrefix(CFG_COMMAND, "hotkey."))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../source/ps/Hotkey.cpp:117:41: warning: loop variable 'p' has type 'const std::pair<int, KeyMapping> &' (aka 'const pair<int, vector<SHotkeyMapping> > &') but is initialized with type 'std::pair<const int, std::vector<SHotkeyMapping, std::allocator<SHotkeyMapping> > >' resulting in a copy [-Wrange-loop-construct]
for (const std::pair<int, KeyMapping>& p : g_HotkeyMap)
^
../../../source/ps/Hotkey.cpp:117:7: note: use non-reference type 'std::pair<int, KeyMapping>' (aka 'pair<int, vector<SHotkeyMapping> >') to keep the copy or type 'const std::pair<const int, std::vector<SHotkeyMapping, std::allocator<SHotkeyMapping> > > &' to prevent copying
for (const std::pair<int, KeyMapping>& p : g_HotkeyMap)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../source/gui/ObjectBases/IGUIObject.cpp:74:44: warning: loop variable 'p' has type 'const std::pair<CStr8, IGUISetting *> &' but is initialized with type 'std::pair<const CStr8, IGUISetting *>' resulting in a copy [-Wrange-loop-construct]
for (const std::pair<CStr, IGUISetting*>& p : m_Settings)
^
../../../source/gui/ObjectBases/IGUIObject.cpp:74:7: note: use non-reference type 'std::pair<CStr8, IGUISetting *>' to keep the copy or type 'const std::pair<const CStr8, IGUISetting *> &' to prevent copying
for (const std::pair<CStr, IGUISetting*>& p : m_Settings)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../source/gui/ObjectBases/IGUIObject.cpp:277:37: warning: loop variable 'p' has type 'const std::pair<CStr8, CStrW> &' but is initialized with type 'const std::pair<const CStr8, CStrW>' resulting in a copy [-Wrange-loop-construct]
for (const std::pair<CStr, CStrW>& p : m_pGUI.GetStyle(StyleName).m_SettingsDefaults)
^
../../../source/gui/ObjectBases/IGUIObject.cpp:277:7: note: use non-reference type 'std::pair<CStr8, CStrW>' to keep the copy or type 'const std::pair<const CStr8, CStrW> &' to prevent copying
for (const std::pair<CStr, CStrW>& p : m_pGUI.GetStyle(StyleName).m_SettingsDefaults)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: source/gui/CGUI.cpp
===================================================================
--- source/gui/CGUI.cpp (revision 23702)
+++ source/gui/CGUI.cpp (working copy)
@@ -76,10 +76,10 @@
CGUI::~CGUI()
{
- for (const std::pair<CStr, IGUIObject*>& p : m_pAllObjects)
+ for (const std::pair<const CStr, IGUIObject*>& p : m_pAllObjects)
delete p.second;
- for (const std::pair<CStr, const CGUISprite*>& p : m_Sprites)
+ for (const std::pair<const CStr, const CGUISprite*>& p : m_Sprites)
delete p.second;
}
Index: source/gui/ObjectBases/IGUIObject.cpp
===================================================================
--- source/gui/ObjectBases/IGUIObject.cpp (revision 23702)
+++ source/gui/ObjectBases/IGUIObject.cpp (working copy)
@@ -71,7 +71,7 @@
IGUIObject::~IGUIObject()
{
- for (const std::pair<CStr, IGUISetting*>& p : m_Settings)
+ for (const std::pair<const CStr, IGUISetting*>& p : m_Settings)
delete p.second;
if (!m_ScriptHandlers.empty())
@@ -274,7 +274,7 @@
// Other styles are reported if they specify a Setting that does not exist,
// so that the XML author is informed and can correct the style.
- for (const std::pair<CStr, CStrW>& p : m_pGUI.GetStyle(StyleName).m_SettingsDefaults)
+ for (const std::pair<const CStr, CStrW>& p : m_pGUI.GetStyle(StyleName).m_SettingsDefaults)
{
if (SettingExists(p.first))
SetSettingFromString(p.first, p.second, true);
Index: source/ps/Hotkey.cpp
===================================================================
--- source/ps/Hotkey.cpp (revision 23702)
+++ source/ps/Hotkey.cpp (working copy)
@@ -57,7 +57,7 @@
// all key combinations that trigger it.
static void LoadConfigBindings()
{
- for (const std::pair<CStr, CConfigValueSet>& configPair : g_ConfigDB.GetValuesWithPrefix(CFG_COMMAND, "hotkey."))
+ for (const std::pair<const CStr, CConfigValueSet>& configPair : g_ConfigDB.GetValuesWithPrefix(CFG_COMMAND, "hotkey."))
{
std::string hotkeyName = configPair.first.substr(7); // strip the "hotkey." prefix
for (const CStr& hotkey : configPair.second)
@@ -114,7 +114,7 @@
// Set up the state of the hotkeys given no key is down.
// i.e. find those hotkeys triggered by all negations.
- for (const std::pair<int, KeyMapping>& p : g_HotkeyMap)
+ for (const std::pair<const int, KeyMapping>& p : g_HotkeyMap)
for (const SHotkeyMapping& hotkey : p.second)
{
if (!hotkey.negated)

Event Timeline

elexis created this paste.May 27 2020, 1:25 PM
elexis created this object with visibility "Public (No Login Required)".