xtd 0.2.0
__polymorphic_equator.hpp
Go to the documentation of this file.
1
4
5#pragma once
7#if !defined(__XTD_CORE_INTERNAL__)
8#error "Do not include this file: Internal use only"
9#endif
11
12#include "../iequatable.hpp"
13#include "../object.hpp"
14#include <functional>
15#include <type_traits>
16
18template<typename type_t, typename bool_t>
19struct __object_equtor__ {};
20
21template<typename type_t>
22struct __object_equtor__<type_t, std::true_type> {
23 bool operator()(const type_t& a, const type_t& b) const {return static_cast<const xtd::object&>(a).equals(b);}
24};
25
26template<typename type_t>
27struct __object_equtor__<type_t, std::false_type> {
28 bool operator()(const type_t& a, const type_t& b) const {return std::equal_to<type_t> {}(a, b);}
29};
30
31template<typename type_t, typename bool_t>
32struct __iequatable_equator__ {};
33
34template<typename type_t>
35struct __iequatable_equator__<type_t, std::true_type> {
36 bool operator()(const type_t& a, const type_t& b) const {return static_cast<const xtd::iequatable<type_t>&>(a).equals(b);}
37};
38
39template<typename type_t>
40struct __iequatable_equator__<type_t, std::false_type> {
41 bool operator()(const type_t& a, const type_t& b) const {return __object_equtor__<type_t, typename std::is_base_of<xtd::object, type_t>::type> {}(a, b);}
42};
43
44template<class type_t, class bool_t>
45struct __polymorphic_equator__ {};
46
47template<class type_t>
48struct __polymorphic_equator__<type_t, std::true_type> {
49 bool operator()(const type_t& a, const type_t& b) const {return __iequatable_equator__<type_t, typename std::is_base_of<xtd::iequatable<type_t>, type_t>::type> {}(a, b);}
50};
51
52template<class type_t>
53struct __polymorphic_equator__<type_t, std::false_type> {
54 bool operator()(const type_t& a, const type_t& b) const {return std::equal_to<type_t> {}(a, b);}
55};
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
@ a
The A key.
@ b
The B key.