stlab.adobe.com Adobe Systems Incorporated
clamp.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2005-2008 Adobe Systems Incorporated
3  Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
4  or a copy at http://stlab.adobe.com/licenses.html)
5 */
6 /**************************************************************************************************/
7 
8 #ifndef ADOBE_ALGORITHM_CLAMP_HPP
9 #define ADOBE_ALGORITHM_CLAMP_HPP
10 
11 #include <cassert>
12 
14 #include <adobe/functional.hpp>
15 
16 namespace adobe {
17 
18 /**************************************************************************************************/
37 /**************************************************************************************************/
38 
45 template <typename T, typename R>
46 inline const T& clamp(const T& x, const T& min, const T& max, R r)
47 {
48  return select_1_ac(min, x, max, r);
49 }
50 
57 template <typename T>
58 inline const T& clamp(const T& x, const T& min, const T& max)
59 {
60  return select_1_ac(min, x, max, adobe::less());
61 }
62 
68 template <typename T, typename R>
69 inline const T& clamp_unordered(const T& x, const T& min, const T& max, R r)
70 { return select_1(min, x, max, r); }
71 
77 template <typename T>
78 inline const T& clamp_unordered(const T& x, const T& min, const T& max)
79 { return select_1(min, x, max, adobe::less()); }
80 
81 /**************************************************************************************************/
82 
83 } // namespace adobe
84 
85 #endif

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google