xtd 0.2.0
Loading...
Searching...
No Matches
equator.hpp
Go to the documentation of this file.
1
4#pragma once
6#include "../../../object.hpp"
8#include <type_traits>
9
11namespace xtd {
13 namespace collections {
15 namespace generic {
17 namespace helpers {
38 template<class value_t>
39 struct equator {
41
44 using first_argument_type = value_t;
46 using second_argument_type = value_t;
48 using result_type = bool;
50
52
55 equator() = default;
58 explicit equator(const xtd::collections::generic::iequality_comparer<value_t>& comparer) : comparer {&comparer} {}
60
62
70 if (&a == &b) return true;
71 if (comparer) return comparer->equals(a, b);
72 if constexpr(std::is_polymorphic_v<first_argument_type> && std::is_base_of_v<xtd::iequatable<first_argument_type>, first_argument_type>) return static_cast<const xtd::iequatable<first_argument_type>&>(a).equals(b);
73 else if constexpr(std::is_polymorphic_v<first_argument_type> && std::is_base_of_v<xtd::object, first_argument_type>) return static_cast<const xtd::object&>(a).equals(b);
74 else if constexpr(std::equality_comparable<first_argument_type>) return a == b;
75 else return false;
76 }
77
78
79 private:
81 };
82 }
83 }
84 }
85}
Defines methods to support the comparison of objects for equality.
Definition iequality_comparer.hpp:34
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
virtual bool equals(const type_t &) const noexcept=0
Indicates whether the current object is equal to another object of the same type.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
virtual bool equals(const object &obj) const noexcept
Determines whether the specified object is equal to the current object.
Contains xtd::collections::generic::iequality_comparer <type_t> interface.
@ a
The A key.
Definition console_key.hpp:88
@ b
The B key.
Definition console_key.hpp:90
Contains xtd::iequatable interface.
The xtd::collections::generic::helpers namespace contains helpers for generic collections,...
Definition allocator.hpp:14
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.
Implements a function object for compare data.
Definition comparer.hpp:32
equator()=default
Initializes a new instance of the hasher.
equator(const xtd::collections::generic::iequality_comparer< value_t > &comparer)
Initializes a new instance of the hasher with specified comparer.
Definition equator.hpp:58
auto operator()(const first_argument_type &a, const second_argument_type &b) const -> result_type
checks if the specified a and b keys are equal.
Definition equator.hpp:69
value_t first_argument_type
Represents the first argument type.
Definition equator.hpp:44
value_t second_argument_type
Represents the second argument type.
Definition equator.hpp:46
bool result_type
Represents the result type.
Definition equator.hpp:48