Use operator overloading best practices.
Not all files covered. Refer to StackOverflow for details: http://stackoverflow.com/a/4421719
This commit is contained in:
+21
-6
@@ -51,14 +51,29 @@ struct DeviceButtonPair
|
||||
InputDevice device;
|
||||
DeviceButton button;
|
||||
DeviceButtonPair( InputDevice d, DeviceButton b ): device(d), button(b){ }
|
||||
bool operator<( const DeviceButtonPair &other ) const
|
||||
{
|
||||
if( device != other.device )
|
||||
return device < other.device;
|
||||
return button < other.button;
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator<(DeviceButtonPair const &lhs, DeviceButtonPair const &rhs)
|
||||
{
|
||||
if (lhs.device != rhs.device)
|
||||
{
|
||||
return lhs.device < rhs.device;
|
||||
}
|
||||
return lhs.button < rhs.button;
|
||||
}
|
||||
inline bool operator>(DeviceButtonPair const &lhs, DeviceButtonPair const &rhs)
|
||||
{
|
||||
return operator<(rhs, lhs);
|
||||
}
|
||||
inline bool operator<=(DeviceButtonPair const &lhs, DeviceButtonPair const &rhs)
|
||||
{
|
||||
return !operator<(rhs, lhs);
|
||||
}
|
||||
inline bool operator>=(DeviceButtonPair const &lhs, DeviceButtonPair const &rhs)
|
||||
{
|
||||
return !operator<(lhs, rhs);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
/* Maintain a set of all interesting buttons: buttons which are being held
|
||||
|
||||
Reference in New Issue
Block a user