xtd 0.2.0
Loading...
Searching...
No Matches
icomparable.h
Go to the documentation of this file.
1
4#pragma once
5#include "interface.h"
6#include "types.h"
7
9namespace xtd {
16 template <typename type_t>
18 public:
20
31 virtual int32 compare_to(const type_t& obj) const noexcept = 0;
33
35 friend bool operator <(const type_t& a, const type_t& b) noexcept {return a.compare_to(b) < 0;}
36 friend bool operator <=(const type_t& a, const type_t& b) noexcept {return a.compare_to(b) <= 0;}
37 friend bool operator >(const type_t& a, const type_t& b) noexcept {return a.compare_to(b) > 0;}
38 friend bool operator >=(const type_t& a, const type_t& b) noexcept {return a.compare_to(b) >= 0;}
39 template<typename object_t>
40 friend bool operator <(const type_t& a, const icomparable<object_t>& b) noexcept {return dynamic_cast<const type_t*>(&b) && a.compare_to(dynamic_cast<const type_t&>(b)) < 0;}
41 template<typename object_t>
42 friend bool operator <=(const type_t& a, const icomparable<object_t>& b) noexcept {return dynamic_cast<const type_t*>(&b) && a.compare_to(dynamic_cast<const type_t&>(b)) <= 0;}
43 template<typename object_t>
44 friend bool operator >(const type_t& a, const icomparable<object_t>& b) noexcept {return dynamic_cast<const type_t*>(&b) && a.compare_to(dynamic_cast<const type_t&>(b)) > 0;}
45 template<typename object_t>
46 friend bool operator >=(const type_t& a, const icomparable<object_t>& b) noexcept {return dynamic_cast<const type_t*>(&b) && a.compare_to(dynamic_cast<const type_t&>(b)) >= 0;}
48 };
49}
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.h:17
virtual int32 compare_to(const type_t &obj) const noexcept=0
Compares the current instance with another object of the same type.
#define interface_
This keyword is use to represent an interface.
Definition interface.h:58
int_least32_t int32
Represents a 32-bit signed integer.
Definition types.h:131
@ a
The A key.
@ b
The B key.
Contains xtd::interface interface.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd fundamental types.