wxwidgets: Hide dumper called "NULL"
[lsnes.git] / include / library / minmax.hpp
blob2fa0c1a7ff7bef3f8480758453b8da7374d5c2c7
1 #ifndef _library__minmax__hpp__included__
2 #define _library__minmax__hpp__included__
4 #include <map>
6 /**
7 * Return minimum of a and b.
8 */
9 template<typename T> T min(T a, T b)
11 return (a < b) ? a : b;
14 /**
15 * Return maximum of a and b.
17 template<typename T> T max(T a, T b)
19 return (a < b) ? b : a;
22 /**
23 * Clip v to [a,b].
25 template<typename T> T clip(T v, T a, T b)
27 return (v < a) ? a : ((v > b) ? b : v);
30 template<typename T, typename U>
31 class pair_assign_helper
33 public:
34 pair_assign_helper(T& _a, U& _b) : a(_a), b(_b) {}
35 const std::pair<T, U>& operator=(const std::pair<T, U>& r)
37 a = r.first;
38 b = r.second;
39 return r;
41 private:
42 T& a;
43 U& b;
46 /**
47 * Create a rvalue from components of pair.
49 template<typename T, typename U>
50 pair_assign_helper<T, U> rpair(T& a, U& b)
52 return pair_assign_helper<T, U>(a, b);
57 #endif