From bbabaa0dba6b2106c570f92f429a759d322aba6b Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Mon, 5 Feb 2024 20:44:00 +0100 Subject: Removed use of deprecated std::unary_function --- src/inventory.cpp | 15 ++++++--------- 1 file 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 +#include -struct SlotUsed : public std::unary_function +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; -- cgit v1.2.3-70-g09d2