Skip to content

Commit

Permalink
Add operator!= to Inventory(List), make operator== a const method
Browse files Browse the repository at this point in the history
  • Loading branch information
kahrl committed Jan 11, 2014
1 parent 84b94eb commit 51e6feb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/inventory.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 11 additions & 3 deletions src/inventory.h
Expand Up @@ -182,7 +182,11 @@ class InventoryList

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;
Expand Down Expand Up @@ -258,8 +262,12 @@ class Inventory
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);

Expand Down

0 comments on commit 51e6feb

Please sign in to comment.