summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-05 20:44:00 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-05 20:44:00 +0100
commitbbabaa0dba6b2106c570f92f429a759d322aba6b (patch)
treed24ee8b25c715cd845880087e614f349f441e632
parent2f2274e959f3452e847800d7496458360f21c341 (diff)
downloadmana-bbabaa0dba6b2106c570f92f429a759d322aba6b.tar.gz
mana-bbabaa0dba6b2106c570f92f429a759d322aba6b.tar.bz2
mana-bbabaa0dba6b2106c570f92f429a759d322aba6b.tar.xz
mana-bbabaa0dba6b2106c570f92f429a759d322aba6b.zip
Removed use of deprecated std::unary_function
-rw-r--r--src/inventory.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index a7418175..a92a4377 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -27,14 +27,12 @@
#include "net/net.h"
#include <algorithm>
+#include <functional>
-struct SlotUsed : public std::unary_function<Item*, bool>
+static bool slotUsed(const Item *item)
{
- bool operator()(const Item *item) const
- {
- return item && item->getId() >= 0 && item->getQuantity() > 0;
- }
-};
+ return item && item->getId() >= 0 && item->getQuantity() > 0;
+}
Inventory::Inventory(Type type, int size):
mType(type),
@@ -136,15 +134,14 @@ bool Inventory::contains(Item *item) const
int Inventory::getFreeSlot() const
{
- Item **i = std::find_if(mItems, mItems + mSize,
- std::not1(SlotUsed()));
+ Item **i = std::find_if(mItems, mItems + mSize, std::not_fn(slotUsed));
return (i == mItems + mSize) ? -1 : (i - mItems);
}
int Inventory::getLastUsedSlot() const
{
for (int i = mSize - 1; i >= 0; i--)
- if (SlotUsed()(mItems[i]))
+ if (slotUsed(mItems[i]))
return i;
return -1;