Skip to content

Commit

Permalink
Merge pull request #5525 from lioncash/overload
Browse files Browse the repository at this point in the history
Device: Provide operator!= counterparts to operator== for DeviceQualifier
  • Loading branch information
lioncash committed Jun 3, 2017
2 parents 4b53093 + 5862d1f commit 0e6bd74
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Source/Core/InputCommon/ControllerInterface/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,21 @@ bool DeviceQualifier::operator==(const Device* const dev) const
return false;
}

bool DeviceQualifier::operator!=(const Device* const dev) const
{
return !operator==(dev);
}

bool DeviceQualifier::operator==(const DeviceQualifier& devq) const
{
return std::tie(cid, name, source) == std::tie(devq.cid, devq.name, devq.source);
}

bool DeviceQualifier::operator!=(const DeviceQualifier& devq) const
{
return !operator==(devq);
}

std::shared_ptr<Device> DeviceContainer::FindDevice(const DeviceQualifier& devq) const
{
std::lock_guard<std::mutex> lk(m_devices_mutex);
Expand Down
6 changes: 5 additions & 1 deletion Source/Core/InputCommon/ControllerInterface/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,12 @@ class DeviceQualifier
void FromDevice(const Device* const dev);
void FromString(const std::string& str);
std::string ToString() const;

bool operator==(const DeviceQualifier& devq) const;
bool operator==(const Device* const dev) const;
bool operator!=(const DeviceQualifier& devq) const;

bool operator==(const Device* dev) const;
bool operator!=(const Device* dev) const;

std::string source;
int cid;
Expand Down

0 comments on commit 0e6bd74

Please sign in to comment.