Add operator!= to Inventory(List), make operator== a const method
authorKahrl <kahrl@gmx.net>
Sat, 11 Jan 2014 18:46:37 +0000 (19:46 +0100)
committerKahrl <kahrl@gmx.net>
Sat, 11 Jan 2014 18:46:37 +0000 (19:46 +0100)
src/inventory.cpp
src/inventory.h

index f4a87bec12d3587cda5f6bc74ca8e8bac0ab12f1..1f55c5305de3af68ebaa07b2faef631b2bb60c2c 100644 (file)
@@ -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;
index cd592a17ac9cfe0375eac4a13ba77ecf9176c097..52b776db34684bd4a9dff6e7178e0eec959b446d 100644 (file)
@@ -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);