xtd 0.2.0
Loading...
Searching...
No Matches
comparer.hpp
Go to the documentation of this file.
1
4#pragma once
6#include "icomparer.hpp"
8#include "../../object.hpp"
9#include "../../ptr.hpp"
10
12namespace xtd {
14 namespace collections {
16 namespace generic {
32 template<class type_t>
34 public:
36
39 using first_argument_type = type_t;
41 using second_argument_type = type_t;
45
47
52
54
66 [[nodiscard]] auto compare(const first_argument_type& x, const second_argument_type& y) const -> result_type override {
67 if constexpr(xtd::helpers::strictly_ordered<first_argument_type> || std::derived_from<first_argument_type, xtd::icomparable<first_argument_type>>) return helpers::comparer<type_t> {}(x, y);
68 else xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "Failed to compare two elements in the array.");
69 }
70
71 //static ptr<comparer<type_t>> create (xtd::comparison<type_t> comparison) {
72 // return {};
73 //}
75
76 protected:
78
81 comparer() = default;
83 };
84
86 template<class type_t>
89 }
90 }
91}
Provides a base class for implementations of the xtd::collections::generic::icomparer <type_t> generi...
Definition comparer.hpp:33
comparer()=default
Initializes a new instance of the xtd::collections::generic::comparer <type_t> class.
xtd::int32 result_type
Definition comparer.hpp:43
xtd::any_object first_argument_type
Definition comparer.hpp:39
auto compare(const first_argument_type &x, const second_argument_type &y) const -> result_type override
Compares two entities and returns a value indicating whether one is less than, equal to,...
Definition comparer.hpp:66
static const comparer< xtd::any_object > default_comparer
Definition comparer.hpp:50
xtd::any_object second_argument_type
Definition comparer.hpp:41
Exposes a method that compares two objects.
Definition icomparer.hpp:30
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
Concept strictly ordered.
Definition strictly_ordered.hpp:28
Contains xtd::collections::generic::helpers::comparer struct.
Contains xtd::collections::generic::icomparer <type_t> interface.
@ invalid_operation
The operation is not valid.
Definition exception_case.hpp:65
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
@ y
The Y key.
Definition console_key.hpp:136
@ x
The X key.
Definition console_key.hpp:134
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::object class.
Contains xtd::ptr type.
Implements a function object for compare data.
Definition comparer.hpp:32
Contains xtd::helpers::throw_helper class.