Milena (Olena)
User documentation 2.0a Id
Main Page
Related Pages
Modules
Namespaces
Classes
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerator
Groups
Pages
trait/op/ord.hh
1
// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
2
// (LRDE)
3
//
4
// This file is part of Olena.
5
//
6
// Olena is free software: you can redistribute it and/or modify it under
7
// the terms of the GNU General Public License as published by the Free
8
// Software Foundation, version 2 of the License.
9
//
10
// Olena is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
// General Public License for more details.
14
//
15
// You should have received a copy of the GNU General Public License
16
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
17
//
18
// As a special exception, you may use this file as part of a free
19
// software project without restriction. Specifically, if other files
20
// instantiate templates or use macros or inline functions from this
21
// file, or you compile this file and link it with other files to produce
22
// an executable, this file does not by itself cause the resulting
23
// executable to be covered by the GNU General Public License. This
24
// exception does not however invalidate any other reasons why the
25
// executable file might be covered by the GNU General Public License.
26
27
#ifndef MLN_TRAIT_OP_ORD_HH
28
# define MLN_TRAIT_OP_ORD_HH
29
33
34
# include <mln/trait/op/decl.hh>
35
# include <mln/trait/solve.hh>
36
37
38
namespace
mln
39
{
40
41
// Forward declarations.
42
namespace
internal {
43
template
<
typename
T>
struct
ord_less;
44
template
<
typename
T>
struct
ord_vec;
45
}
46
namespace
util {
47
template
<
typename
T>
bool
ord_strict
(
const
T& lhs,
const
T& rhs);
48
}
49
50
51
namespace
trait
52
{
53
54
namespace
op
55
{
56
57
template
<
typename
T>
58
struct
ord :
public
solve_unary<ord, T>
59
{
60
};
61
62
}
// end of namespace mln::trait::op
63
64
65
template
<
template
<
class
>
class
Category,
typename
T>
66
struct
set_unary_< op::ord, Category, T >
67
{
68
typedef
mln::internal::ord_less<T> ret;
69
};
70
71
72
}
// end of namespace mln::trait
73
74
75
namespace
internal
76
{
77
78
template
<
typename
T>
79
struct
ord_less
80
{
81
bool
strict(
const
T& lhs,
const
T& rhs)
const
;
82
bool
weak(
const
T& lhs,
const
T& rhs)
const
;
83
};
84
85
template
<
typename
T>
86
struct
ord_vec
87
{
88
bool
strict(
const
T& lhs,
const
T& rhs)
const
;
89
bool
weak(
const
T& lhs,
const
T& rhs)
const
;
90
};
91
92
93
# ifndef MLN_INCLUDE_ONLY
94
95
// ord_less
96
97
template
<
typename
T>
98
inline
99
bool
100
ord_less<T>::strict(
const
T& lhs,
const
T& rhs)
const
101
{
102
return
lhs < rhs;
103
}
104
105
template
<
typename
T>
106
inline
107
bool
108
ord_less<T>::weak(
const
T& lhs,
const
T& rhs)
const
109
{
110
return
lhs <= rhs;
111
}
112
113
// ord_vec
114
115
template
<
typename
T>
116
inline
117
bool
118
ord_vec<T>::strict(
const
T& lhs,
const
T& rhs)
const
119
{
120
for
(
unsigned
i = 0; i < T::dim; ++i)
121
{
122
if
(lhs[i] == rhs[i])
123
continue
;
124
return
mln::util::ord_strict
(lhs[i], rhs[i]);
125
}
126
return
false
;
127
}
128
129
template
<
typename
T>
130
inline
131
bool
132
ord_vec<T>::weak(
const
T& lhs,
const
T& rhs)
const
133
{
134
for
(
unsigned
i = 0; i < T::dim; ++i)
135
{
136
if
(lhs[i] == rhs[i])
137
continue
;
138
return
mln::util::ord_strict
(lhs[i], rhs[i]);
139
}
140
return
true
;
141
}
142
143
# endif // ! MLN_INCLUDE_ONLY
144
145
}
// end of namespace mln::trait::internal
146
147
}
// end of namespace mln
148
149
150
# include <mln/util/ord.hh>
151
# include <mln/trait/solve.hh>
152
153
154
#endif // ! MLN_TRAIT_OP_ORD_HH
mln
trait
op
ord.hh
Generated on Thu Nov 8 2012 10:58:17 for Milena (Olena) by
1.8.2-20120930