소스 검색

add LIMIT

ithewei 6 년 전
부모
커밋
85ac09c357
1개의 변경된 파일4개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      hdef.h

+ 4 - 0
hdef.h

@@ -107,6 +107,10 @@ typedef std::map<std::string, std::string> keyval_t;
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 #endif
 
+#ifndef LIMIT
+#define LIMIT(lower, v, upper) MIN(MAX((lower), (v)), (upper))
+#endif
+
 #ifndef ARRAY_SIZE
 #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
 #endif