| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- //
- // ptr_compare.hpp
- // pointers
- //
- // Created by Sam Jaffe on 1/5/17.
- //
- #pragma once
- namespace pointers { namespace detail {
- template <typename Self> struct pointer_compare {
- friend bool operator==(Self const & lhs, Self const & rhs) {
- return lhs.get() == rhs.get();
- }
- friend bool operator<(Self const & lhs, Self const & rhs) {
- return lhs.get() < rhs.get();
- }
- friend bool operator!=(Self const & lhs, Self const & rhs) {
- return !(lhs == rhs);
- }
- friend bool operator>(Self const & lhs, Self const & rhs) {
- return rhs < lhs;
- }
- friend bool operator<=(Self const & lhs, Self const & rhs) {
- return !(rhs < lhs);
- }
- friend bool operator>=(Self const & lhs, Self const & rhs) {
- return !(lhs < rhs);
- }
- friend bool operator==(Self const & lhs, std::nullptr_t) { return !lhs; }
- friend bool operator<(Self const & lhs, std::nullptr_t) {
- return lhs.get() < nullptr;
- }
- friend bool operator!=(Self const & lhs, std::nullptr_t) { return !!lhs; }
- friend bool operator>(Self const & lhs, std::nullptr_t) {
- return nullptr < lhs;
- }
- friend bool operator<=(Self const & lhs, std::nullptr_t) {
- return !(nullptr < lhs);
- }
- friend bool operator>=(Self const & lhs, std::nullptr_t) {
- return !(lhs < nullptr);
- }
- friend bool operator==(std::nullptr_t, Self const & rhs) { return !rhs; }
- friend bool operator<(std::nullptr_t, Self const & rhs) {
- return nullptr < rhs.get();
- }
- friend bool operator!=(std::nullptr_t, Self const & rhs) { return !!rhs; }
- friend bool operator>(std::nullptr_t, Self const & rhs) {
- return rhs < nullptr;
- }
- friend bool operator<=(std::nullptr_t, Self const & rhs) {
- return !(rhs < nullptr);
- }
- friend bool operator>=(std::nullptr_t, Self const & rhs) {
- return !(nullptr < rhs);
- }
- };
- }}
|