Files
memgraph/include/utils/total_ordering.hpp
Florijan Stamenkovic 10c7514c8a storage/model - added typed_value system and tests. Modified utils slightly (backward compatible).
Summary: Added TypedValue system.

Test Plan: ???

Reviewers: sale, buda

Reviewed By: buda

Subscribers: pullbot, florijan, buda, sale

Differential Revision: https://phabricator.memgraph.io/D46
2017-02-02 15:48:16 +01:00

30 lines
766 B
C++

#pragma once
/**
* Implements all the logical comparison operators based on '=='
* and '<' operators.
*
* @tparam TLhs First operand type.
* @tparam TRhs Second operand type. Defaults to the same type
* as first operand.
* @tparam TReturn Return type, defaults to bool.
*/
template<typename TLhs, typename TRhs=TLhs, typename TReturn=bool>
struct TotalOrdering {
friend constexpr TReturn operator!=(const TLhs &a, const TRhs &b) {
return !(a == b);
}
friend constexpr TReturn operator<=(const TLhs &a, const TRhs &b) {
return a < b || a == b;
}
friend constexpr TReturn operator>(const TLhs &a, const TRhs &b) {
return !(a <= b);
}
friend constexpr TReturn operator>=(const TLhs &a, const TRhs &b) {
return !(a < b);
}
};