Embedded Template Library 1.0
compare.h
Go to the documentation of this file.
1
2
3/******************************************************************************
4The MIT License(MIT)
5
6Embedded Template Library.
7https://github.com/ETLCPP/etl
8https://www.etlcpp.com
9
10Copyright(c) 2017 John Wellbelove
11
12Permission is hereby granted, free of charge, to any person obtaining a copy
13of this software and associated documentation files(the "Software"), to deal
14in the Software without restriction, including without limitation the rights
15to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions :
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29******************************************************************************/
30
31#ifndef ETL_COMPARE_INCLUDED
32#define ETL_COMPARE_INCLUDED
33
34#include "platform.h"
35#include "parameter_type.h"
36#include "functional.h"
37
38//*****************************************************************************
42//*****************************************************************************
43
44namespace etl
45{
46 //***************************************************************************
49 //***************************************************************************
50 template <typename T, typename TLess = etl::less<T> >
51 struct compare
52 {
53 typedef typename etl::parameter_type<T>::type first_argument_type;
54 typedef typename etl::parameter_type<T>::type second_argument_type;
55 typedef bool result_type;
56
57 static result_type lt(first_argument_type lhs, second_argument_type rhs)
58 {
59 return TLess()(lhs, rhs);
60 }
61
62 static result_type gt(first_argument_type lhs, second_argument_type rhs)
63 {
64 return TLess()(rhs, lhs);
65 }
66
67 static result_type lte(first_argument_type lhs, second_argument_type rhs)
68 {
69 return !gt(lhs, rhs);
70 }
71
72 static result_type gte(first_argument_type lhs, second_argument_type rhs)
73 {
74 return !lt(lhs, rhs);
75 }
76 };
77}
78
79#endif
bitset_ext
Definition: absolute.h:38
Definition: compare.h:52
etl::conditional< etl::is_fundamental< T >::value||etl::is_pointer< T >::value, T, constT & >::type type
By default fundamental and pointer types are passed by value.
Definition: parameter_type.h:48