diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-02-05 20:44:00 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-02-05 20:44:00 +0100 |
commit | bbabaa0dba6b2106c570f92f429a759d322aba6b (patch) | |
tree | d24ee8b25c715cd845880087e614f349f441e632 /src | |
parent | 2f2274e959f3452e847800d7496458360f21c341 (diff) | |
download | mana-bbabaa0dba6b2106c570f92f429a759d322aba6b.tar.gz mana-bbabaa0dba6b2106c570f92f429a759d322aba6b.tar.bz2 mana-bbabaa0dba6b2106c570f92f429a759d322aba6b.tar.xz mana-bbabaa0dba6b2106c570f92f429a759d322aba6b.zip |
Removed use of deprecated std::unary_function
Diffstat (limited to 'src')
-rw-r--r-- | src/inventory.cpp | 15 |
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; |