xtd 0.2.0
__polymorphic_lesser.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 "../icomparable.hpp"
13#include <functional>
14#include <type_traits>
15
17template<class type_t, class bool_t>
18struct __polymorphic_lesser__ {};
19
20template<class type_t>
21struct __polymorphic_lesser__<type_t, std::true_type> {
22 bool operator()(const type_t& lhs, const type_t& rhs) const {
23 if (dynamic_cast<const xtd::icomparable<type_t>*>(&lhs)) return dynamic_cast<const xtd::icomparable<type_t>&>(lhs).compare_to(rhs) < 0;
24 return std::less<type_t> {}(lhs, rhs);
25 }
26};
27
28template<class type_t>
29struct __polymorphic_lesser__<type_t, std::false_type> {
30 bool operator()(const type_t& lhs, const type_t& rhs) const {return std::less<type_t> {}(lhs, rhs);}
31};
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.hpp:21