stlab.adobe.com Adobe Systems Incorporated

clamp.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2005-2008 Adobe Systems Incorporated
00003     Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004     or a copy at http://stlab.adobe.com/licenses.html)
00005 */
00006 /**************************************************************************************************/
00007 
00008 #ifndef ADOBE_ALGORITHM_CLAMP_HPP
00009 #define ADOBE_ALGORITHM_CLAMP_HPP
00010 
00011 #include <cassert>
00012 
00013 #include <adobe/algorithm/select.hpp>
00014 #include <adobe/functional.hpp>
00015 
00016 namespace adobe {
00017 
00018 /**************************************************************************************************/
00037 /**************************************************************************************************/
00038 
00045 template <typename T, typename R>
00046 inline const T& clamp(const T& x, const T& min, const T& max, R r)
00047 {
00048     return select_1_ac(min, x, max, r);
00049 }
00050 
00057 template <typename T>
00058 inline const T& clamp(const T& x, const T& min, const T& max)
00059 {
00060     return select_1_ac(min, x, max, adobe::less());
00061 }
00062 
00068 template <typename T, typename R>
00069 inline const T& clamp_unordered(const T& x, const T& min, const T& max, R r)
00070 { return select_1(min, x, max, r); }
00071 
00077 template <typename T>
00078 inline const T& clamp_unordered(const T& x, const T& min, const T& max)
00079 { return select_1(min, x, max, adobe::less()); }
00080 
00081 /**************************************************************************************************/
00082 
00083 } // namespace adobe
00084 
00085 #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