clamp.hppGo to the documentation of this file.00001
00002
00003
00004
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 }
00084
00085 #endif
|