acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
less.h
1#pragma once
2
3
4#include "acme/prototype/collection/iterator.h"
5
6
7template < class TYPE, class ARG_TYPE >
8inline bool LessCompareElements(ARG_TYPE element1, ARG_TYPE element2)
9{
10 return element1 < element2;
11}
12
13
14namespace comparison
15{
16
17 template < class TYPE, class ARG_TYPE = const TYPE & >
18 class less
19 {
20 public:
21
22 inline bool operator() (ARG_TYPE element1, ARG_TYPE element2) const
23 {
24 return ::LessCompareElements < TYPE, ARG_TYPE > (element1, element2);
25 }
26
27
28 };
29
30
31} // namespace comparison
32
33template <bool b> struct StaticAssertionFailed;
34template <> struct StaticAssertionFailed <true> {};
35
36#define STATIC_ASSERT(x) \
37 {StaticAssertionFailed <x> ();}
38
39// https://stackoverflow.com/questions/23367775/pragma-packshow-with-gcc - Morten Jensen
40 /*
41 The static_assert macro will generate an error at compile-time, if the predicate is false
42 but will only work for predicates that are resolvable at compile-time!
43
44 E.g.: to assert the size of a data structure, static_assert(sizeof(struct_t) == 10)
45*/
46#define COMPILE_TIME_ASSERT(COND,MSG) typedef ::i8 static_assertion_##MSG[(!!(COND))*2-1]
47/* token pasting madness: */
48#define COMPILE_TIME_ASSERT3(X,L) COMPILE_TIME_ASSERT(X,at_line_##L) /* add line-number to error message for better warnings, especially GCC will tell the name of the variable as well */
49#define COMPILE_TIME_ASSERT2(X,L) COMPILE_TIME_ASSERT3(X, L) /* expand line-number */
50#define compile_time_assert(X) COMPILE_TIME_ASSERT2(X, __LINE__) /* call with line-number macro */
51
52#define PACKED __attribute__ ((gcc_struct, __packed__))
53
54
55namespace comparison
56{
57
58
59 template < >
60 class less < string , const string & >
61 {
62 public:
63
64
65 inline bool operator()(const string & element1, const string & element2) const
66 {
67
68 return element1 < element2;
69
70 }
71
72 };
73
74
75 template < >
76 class less < wstring, const wstring & >
77 {
78 public:
79
80
81 inline bool operator()(const wstring & element1, const wstring & element2) const
82 {
83
84 return element1 < element2;
85
86 }
87
88 };
89
90
91} // namespace comparison
92
93
94
95
96
97
Definition less.h:19
Definition aaa_want_to_remove_str_wstring.h:94
Definition less.h:33