L4Re Operating System Framework – Interface and Usage Documentation
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 * This file is part of TUD:OS and distributed under the terms of the
7 * GNU General Public License 2.
8 * Please see the COPYING-GPL-2 file for details.
9 *
10 * As a special exception, you may use this file as part of a free software
11 * library without restriction. Specifically, if other files instantiate
12 * templates or use macros or inline functions from this file, or you compile
13 * this file and link it with other files to produce an executable, this
14 * file does not by itself cause the resulting executable to be covered by
15 * the GNU General Public License. This exception does not however
16 * invalidate any other reasons why the executable file might be covered by
17 * the GNU General Public License.
18 */
19#pragma once
20
25namespace cxx
26{
33 template< typename T1 >
34 inline
35 T1 min(T1 a, T1 b)
36 { return a < b ? a : b; }
37
44 template< typename T1 >
45 inline
46 T1 max(T1 a, T1 b)
47 { return a > b ? a : b; }
48
56 template< typename T1 >
57 inline
58 T1 clamp(T1 v, T1 lo, T1 hi)
59 { return min(hi, max(lo, v)); }
60};
T1 min(T1 a, T1 b)
Get the minimum of a and b.
Definition minmax:35
T1 max(T1 a, T1 b)
Get the maximum of a and b.
Definition minmax:46
T1 clamp(T1 v, T1 lo, T1 hi)
Limit v to the range given by lo and hi.
Definition minmax:58
Our C++ library.
Definition arith:22