From: Kahrl Date: Sat, 11 Jan 2014 18:46:37 +0000 (+0100) Subject: Add operator!= to Inventory(List), make operator== a const method X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=51e6feb17c5929c60b5e8b87cb02c0d22ddb6ff5;p=zefram%2Fminetest%2Fminetest_engine.git Add operator!= to Inventory(List), make operator== a const method --- diff --git a/src/inventory.cpp b/src/inventory.cpp index f4a87bec..1f55c530 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -562,7 +562,7 @@ InventoryList & InventoryList::operator = (const InventoryList &other) return *this; } -bool InventoryList::operator == (const InventoryList &other) +bool InventoryList::operator == (const InventoryList &other) const { if(m_size != other.m_size) return false; @@ -875,7 +875,7 @@ Inventory & Inventory::operator = (const Inventory &other) return *this; } -bool Inventory::operator == (const Inventory &other) +bool Inventory::operator == (const Inventory &other) const { if(m_lists.size() != other.m_lists.size()) return false; diff --git a/src/inventory.h b/src/inventory.h index cd592a17..52b776db 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -182,7 +182,11 @@ public: InventoryList(const InventoryList &other); InventoryList & operator = (const InventoryList &other); - bool operator == (const InventoryList &other); + bool operator == (const InventoryList &other) const; + bool operator != (const InventoryList &other) const + { + return !(*this == other); + } const std::string &getName() const; u32 getSize() const; @@ -258,8 +262,12 @@ public: Inventory(IItemDefManager *itemdef); Inventory(const Inventory &other); Inventory & operator = (const Inventory &other); - bool operator == (const Inventory &other); - + bool operator == (const Inventory &other) const; + bool operator != (const Inventory &other) const + { + return !(*this == other); + } + void serialize(std::ostream &os) const; void deSerialize(std::istream &is);