L4Re Operating System Framework
Interface and Usage Documentation
Toggle main menu visibility
Main Page
Related Pages
Topics
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
h
i
k
m
o
p
r
s
t
u
w
Functions
a
b
c
k
m
r
s
t
w
Variables
Typedefs
Enumerations
Enumerator
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
~
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Typedefs
_
a
b
c
d
e
f
g
i
k
m
n
o
p
r
s
t
v
w
Enumerations
a
c
d
e
f
i
m
n
p
q
r
s
t
v
Enumerator
a
b
c
d
e
f
g
i
k
l
m
n
o
p
r
s
t
u
w
x
Related Symbols
Files
File List
Globals
All
_
a
b
d
e
f
g
l
m
n
o
p
r
s
Functions
_
b
e
f
g
l
o
p
Typedefs
e
g
l
p
Enumerations
e
l
p
Enumerator
a
d
e
f
l
n
p
r
s
Macros
_
e
g
l
m
p
s
Examples
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
minmax
1
// vi:set ft=cpp: -*- Mode: C++ -*-
2
/*
3
* (c) 2008-2009 Alexander Warg <warg@os.inf.tu-dresden.de>
4
* economic rights: Technische Universität Dresden (Germany)
5
*
6
* License: see LICENSE.spdx (in this directory or the directories above)
7
*/
8
#pragma once
9
10
#include "type_traits"
11
16
namespace
cxx
17
{
18
// trivial, used to terminate the variadic recursion
19
template
<
typename
A>
20
constexpr
A
const
&
21
min(A
const
&a)
22
{
return
a; }
23
34
template
<
typename
A,
typename
...ARGS>
35
constexpr
A
const
&
36
min(A
const
&a1, A
const
&a2, ARGS
const
&...a)
37
{
38
return
min((a1 <= a2) ? a1 : a2, a...);
39
}
36
min(A
const
&a1, A
const
&a2, ARGS
const
&...a) {
…
}
40
51
template
<
typename
A,
typename
...ARGS>
52
constexpr
A
const
&
53
min(cxx::identity_t<A>
const
&a1,
54
cxx::identity_t<A>
const
&a2,
55
ARGS
const
&...a)
56
{
57
return
min<A>((a1 <= a2) ? a1 : a2, a...);
58
}
53
min(cxx::identity_t<A>
const
&a1, {
…
}
59
60
// trivial, used to terminate the variadic recursion
61
template
<
typename
A>
62
constexpr
A
const
&
63
max(A
const
&a)
64
{
return
a; }
65
76
template
<
typename
A,
typename
...ARGS>
77
constexpr
A
const
&
78
max(A
const
&a1, A
const
&a2, ARGS
const
&...a)
79
{
return
max((a1 >= a2) ? a1 : a2, a...); }
78
max(A
const
&a1, A
const
&a2, ARGS
const
&...a) {
…
}
80
91
template
<
typename
A,
typename
...ARGS>
92
constexpr
A
const
&
93
max(cxx::identity_t<A>
const
&a1,
94
cxx::identity_t<A>
const
&a2,
95
ARGS
const
&...a)
96
{
97
return
max<A>((a1 >= a2) ? a1 : a2, a...);
98
}
93
max(cxx::identity_t<A>
const
&a1, {
…
}
99
107
template
<
typename
T1 >
108
inline
109
T1
clamp
(T1 v, T1 lo, T1 hi)
110
{
return
min(hi, max(lo, v)); }
109
T1
clamp
(T1 v, T1 lo, T1 hi) {
…
}
111
};
cxx::clamp
T1 clamp(T1 v, T1 lo, T1 hi)
Limit v to the range given by lo and hi.
Definition
minmax:109
cxx
Our C++ library.
Definition
arith:11
l4
cxx
minmax
Generated on Mon Mar 3 2025 23:08:49 for L4Re Operating System Framework by
1.9.8